tigerbeetle-node 0.14.178 → 0.14.180
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/README.md +33 -4
- package/dist/bin/aarch64-linux-gnu/client.node +0 -0
- package/dist/bin/aarch64-linux-musl/client.node +0 -0
- package/dist/bin/aarch64-macos/client.node +0 -0
- package/dist/bin/x86_64-linux-gnu/client.node +0 -0
- package/dist/bin/x86_64-linux-musl/client.node +0 -0
- package/dist/bin/x86_64-macos/client.node +0 -0
- package/dist/bin/x86_64-windows/client.node +0 -0
- package/dist/bindings.d.ts +13 -4
- package/dist/bindings.js +10 -8
- package/dist/bindings.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/dist/test.js +106 -42
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/src/bindings.ts +50 -12
- package/src/index.ts +50 -4
- package/src/node.zig +17 -12
- package/src/test.ts +139 -48
package/README.md
CHANGED
|
@@ -126,6 +126,7 @@ bitwise-or:
|
|
|
126
126
|
* `AccountFlags.linked`
|
|
127
127
|
* `AccountFlags.debits_must_not_exceed_credits`
|
|
128
128
|
* `AccountFlags.credits_must_not_exceed_credits`
|
|
129
|
+
* `AccountFlags.history`
|
|
129
130
|
|
|
130
131
|
|
|
131
132
|
For example, to link two accounts where the first account
|
|
@@ -576,14 +577,42 @@ let filter = {
|
|
|
576
577
|
account_id: 2n,
|
|
577
578
|
timestamp_min: 0n, // No filter by Timestamp.
|
|
578
579
|
timestamp_max: 0n, // No filter by Timestamp.
|
|
579
|
-
limit: 10, // Limit to ten
|
|
580
|
-
flags:
|
|
581
|
-
|
|
582
|
-
|
|
580
|
+
limit: 10, // Limit to ten balances at most.
|
|
581
|
+
flags: AccountFilterFlags.debits | // Include transfer from the debit side.
|
|
582
|
+
AccountFilterFlags.credits | // Include transfer from the credit side.
|
|
583
|
+
AccountFilterFlags.reversed, // Sort by timestamp in reverse-chronological order.
|
|
583
584
|
};
|
|
584
585
|
const account_transfers = await client.getAccountTransfers(filter);
|
|
585
586
|
```
|
|
586
587
|
|
|
588
|
+
## Get Account History
|
|
589
|
+
|
|
590
|
+
NOTE: This is a preview API that is subject to breaking changes once we have
|
|
591
|
+
a stable querying API.
|
|
592
|
+
|
|
593
|
+
Fetches the point-in-time balances of a given account, allowing basic filter and
|
|
594
|
+
pagination capabilities.
|
|
595
|
+
|
|
596
|
+
Only accounts created with the flag
|
|
597
|
+
[`history`](https://docs.tigerbeetle.com/reference/accounts#flagshistory) set retain
|
|
598
|
+
the history of balances.
|
|
599
|
+
|
|
600
|
+
The balances in the response are sorted by `timestamp` in chronological or
|
|
601
|
+
reverse-chronological order.
|
|
602
|
+
|
|
603
|
+
```javascript
|
|
604
|
+
filter = {
|
|
605
|
+
account_id: 2n,
|
|
606
|
+
timestamp_min: 0n, // No filter by Timestamp.
|
|
607
|
+
timestamp_max: 0n, // No filter by Timestamp.
|
|
608
|
+
limit: 10, // Limit to ten balances at most.
|
|
609
|
+
flags: AccountFilterFlags.debits | // Include transfer from the debit side.
|
|
610
|
+
AccountFilterFlags.credits | // Include transfer from the credit side.
|
|
611
|
+
AccountFilterFlags.reversed, // Sort by timestamp in reverse-chronological order.
|
|
612
|
+
};
|
|
613
|
+
const account_balances = await client.getAccountHistory(filter);
|
|
614
|
+
```
|
|
615
|
+
|
|
587
616
|
## Linked Events
|
|
588
617
|
|
|
589
618
|
When the `linked` flag is specified for an account when creating accounts or
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/bindings.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export declare enum AccountFlags {
|
|
|
2
2
|
none = 0,
|
|
3
3
|
linked = 1,
|
|
4
4
|
debits_must_not_exceed_credits = 2,
|
|
5
|
-
credits_must_not_exceed_debits = 4
|
|
5
|
+
credits_must_not_exceed_debits = 4,
|
|
6
|
+
history = 8
|
|
6
7
|
}
|
|
7
8
|
export declare enum TransferFlags {
|
|
8
9
|
none = 0,
|
|
@@ -13,7 +14,7 @@ export declare enum TransferFlags {
|
|
|
13
14
|
balancing_debit = 16,
|
|
14
15
|
balancing_credit = 32
|
|
15
16
|
}
|
|
16
|
-
export declare enum
|
|
17
|
+
export declare enum AccountFilterFlags {
|
|
17
18
|
none = 0,
|
|
18
19
|
debits = 1,
|
|
19
20
|
credits = 2,
|
|
@@ -139,17 +140,25 @@ export declare type CreateTransfersError = {
|
|
|
139
140
|
index: number;
|
|
140
141
|
result: CreateTransferError;
|
|
141
142
|
};
|
|
142
|
-
export declare type
|
|
143
|
+
export declare type AccountFilter = {
|
|
143
144
|
account_id: bigint;
|
|
144
145
|
timestamp_min: bigint;
|
|
145
146
|
timestamp_max: bigint;
|
|
146
147
|
limit: number;
|
|
147
148
|
flags: number;
|
|
148
149
|
};
|
|
150
|
+
export declare type AccountBalance = {
|
|
151
|
+
debits_pending: bigint;
|
|
152
|
+
debits_posted: bigint;
|
|
153
|
+
credits_pending: bigint;
|
|
154
|
+
credits_posted: bigint;
|
|
155
|
+
timestamp: bigint;
|
|
156
|
+
};
|
|
149
157
|
export declare enum Operation {
|
|
150
158
|
create_accounts = 128,
|
|
151
159
|
create_transfers = 129,
|
|
152
160
|
lookup_accounts = 130,
|
|
153
161
|
lookup_transfers = 131,
|
|
154
|
-
get_account_transfers = 132
|
|
162
|
+
get_account_transfers = 132,
|
|
163
|
+
get_account_history = 133
|
|
155
164
|
}
|
package/dist/bindings.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Operation = exports.CreateTransferError = exports.CreateAccountError = exports.
|
|
3
|
+
exports.Operation = exports.CreateTransferError = exports.CreateAccountError = exports.AccountFilterFlags = exports.TransferFlags = exports.AccountFlags = void 0;
|
|
4
4
|
var AccountFlags;
|
|
5
5
|
(function (AccountFlags) {
|
|
6
6
|
AccountFlags[AccountFlags["none"] = 0] = "none";
|
|
7
7
|
AccountFlags[AccountFlags["linked"] = 1] = "linked";
|
|
8
8
|
AccountFlags[AccountFlags["debits_must_not_exceed_credits"] = 2] = "debits_must_not_exceed_credits";
|
|
9
9
|
AccountFlags[AccountFlags["credits_must_not_exceed_debits"] = 4] = "credits_must_not_exceed_debits";
|
|
10
|
+
AccountFlags[AccountFlags["history"] = 8] = "history";
|
|
10
11
|
})(AccountFlags = exports.AccountFlags || (exports.AccountFlags = {}));
|
|
11
12
|
var TransferFlags;
|
|
12
13
|
(function (TransferFlags) {
|
|
@@ -18,13 +19,13 @@ var TransferFlags;
|
|
|
18
19
|
TransferFlags[TransferFlags["balancing_debit"] = 16] = "balancing_debit";
|
|
19
20
|
TransferFlags[TransferFlags["balancing_credit"] = 32] = "balancing_credit";
|
|
20
21
|
})(TransferFlags = exports.TransferFlags || (exports.TransferFlags = {}));
|
|
21
|
-
var
|
|
22
|
-
(function (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})(
|
|
22
|
+
var AccountFilterFlags;
|
|
23
|
+
(function (AccountFilterFlags) {
|
|
24
|
+
AccountFilterFlags[AccountFilterFlags["none"] = 0] = "none";
|
|
25
|
+
AccountFilterFlags[AccountFilterFlags["debits"] = 1] = "debits";
|
|
26
|
+
AccountFilterFlags[AccountFilterFlags["credits"] = 2] = "credits";
|
|
27
|
+
AccountFilterFlags[AccountFilterFlags["reversed"] = 4] = "reversed";
|
|
28
|
+
})(AccountFilterFlags = exports.AccountFilterFlags || (exports.AccountFilterFlags = {}));
|
|
28
29
|
var CreateAccountError;
|
|
29
30
|
(function (CreateAccountError) {
|
|
30
31
|
CreateAccountError[CreateAccountError["ok"] = 0] = "ok";
|
|
@@ -116,5 +117,6 @@ var Operation;
|
|
|
116
117
|
Operation[Operation["lookup_accounts"] = 130] = "lookup_accounts";
|
|
117
118
|
Operation[Operation["lookup_transfers"] = 131] = "lookup_transfers";
|
|
118
119
|
Operation[Operation["get_account_transfers"] = 132] = "get_account_transfers";
|
|
120
|
+
Operation[Operation["get_account_history"] = 133] = "get_account_history";
|
|
119
121
|
})(Operation = exports.Operation || (exports.Operation = {}));
|
|
120
122
|
//# sourceMappingURL=bindings.js.map
|
package/dist/bindings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":";;;AASA,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACtB,+CAAQ,CAAA;IAKR,mDAAiB,CAAA;IAKjB,mGAAyC,CAAA;IAKzC,mGAAyC,CAAA;AAC3C,CAAC,EAjBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAiBvB;AAMD,IAAY,aAgCX;AAhCD,WAAY,aAAa;IACvB,iDAAQ,CAAA;IAKR,qDAAiB,CAAA;IAKjB,uDAAkB,CAAA;IAKlB,mFAAgC,CAAA;IAKhC,mFAAgC,CAAA;IAKhC,wEAA0B,CAAA;IAK1B,0EAA2B,CAAA;AAC7B,CAAC,EAhCW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAgCxB;AAMD,IAAY,wBAiBX;AAjBD,WAAY,wBAAwB;IAClC,uEAAQ,CAAA;IAKR,2EAAiB,CAAA;IAKjB,6EAAkB,CAAA;IAKlB,+EAAmB,CAAA;AACrB,CAAC,EAjBW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAiBnC;AAsJD,IAAY,kBA+GX;AA/GD,WAAY,kBAAkB;IAK5B,uDAAM,CAAA;IAKN,yFAAuB,CAAA;IAKvB,iGAA2B,CAAA;IAK3B,+FAA0B,CAAA;IAK1B,+EAAkB,CAAA;IAKlB,6EAAiB,CAAA;IAKjB,yFAAuB,CAAA;IAKvB,+FAA0B,CAAA;IAK1B,2GAAgC,CAAA;IAKhC,yGAA+B,CAAA;IAK/B,wGAA+B,CAAA;IAK/B,4GAAiC,CAAA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IAKxC,0HAAuC,CAAA;IAKvC,0HAAuC,CAAA;IAKvC,gHAAkC,CAAA;IAKlC,0GAA+B,CAAA;IAK/B,kEAAW,CAAA;IAKX,sGAA6B,CAAA;IAK7B,wGAA8B,CAAA;IAK9B,oGAA4B,CAAA;IAK5B,sGAA6B,CAAA;IAK7B,sFAAqB,CAAA;IAKrB,wFAAsB,CAAA;IAKtB,wFAAsB,CAAA;IAKtB,oFAAoB,CAAA;IAKpB,kFAAmB,CAAA;AACrB,CAAC,EAzRW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAyR9B;AA4CD,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,iEAAqB,CAAA;IACrB,mEAAsB,CAAA;IACtB,iEAAqB,CAAA;IACrB,mEAAsB,CAAA;IACtB,6EAA2B,CAAA;AAC7B,CAAC,EANW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAMpB","sourcesContent":["///////////////////////////////////////////////////////\n// This file was auto-generated by node_bindings.zig //\n// Do not manually modify. //\n///////////////////////////////////////////////////////\n\n\n/**\n* See [AccountFlags](https://docs.tigerbeetle.com/reference/accounts#flags)\n*/\nexport enum AccountFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/accounts#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [debits_must_not_exceed_credits](https://docs.tigerbeetle.com/reference/accounts#flagsdebits_must_not_exceed_credits)\n */\n debits_must_not_exceed_credits = (1 << 1),\n\n /**\n * See [credits_must_not_exceed_debits](https://docs.tigerbeetle.com/reference/accounts#flagscredits_must_not_exceed_debits)\n */\n credits_must_not_exceed_debits = (1 << 2),\n}\n\n\n/**\n* See [TransferFlags](https://docs.tigerbeetle.com/reference/transfers#flags)\n*/\nexport enum TransferFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/transfers#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [pending](https://docs.tigerbeetle.com/reference/transfers#flagspending)\n */\n pending = (1 << 1),\n\n /**\n * See [post_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagspost_pending_transfer)\n */\n post_pending_transfer = (1 << 2),\n\n /**\n * See [void_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagsvoid_pending_transfer)\n */\n void_pending_transfer = (1 << 3),\n\n /**\n * See [balancing_debit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_debit)\n */\n balancing_debit = (1 << 4),\n\n /**\n * See [balancing_credit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_credit)\n */\n balancing_credit = (1 << 5),\n}\n\n\n/**\n* See [GetAccountTransfersFlags](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flags)\n*/\nexport enum GetAccountTransfersFlags {\n none = 0,\n\n /**\n * See [debits](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagsdebits)\n */\n debits = (1 << 0),\n\n /**\n * See [credits](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagscredits)\n */\n credits = (1 << 1),\n\n /**\n * See [reversed](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagsreversed)\n */\n reversed = (1 << 2),\n}\n\n\n/**\n* See [Account](https://docs.tigerbeetle.com/reference/accounts/#)\n*/\nexport type Account = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/accounts/#id)\n */\n id: bigint\n\n /**\n * See [debits_pending](https://docs.tigerbeetle.com/reference/accounts/#debits_pending)\n */\n debits_pending: bigint\n\n /**\n * See [debits_posted](https://docs.tigerbeetle.com/reference/accounts/#debits_posted)\n */\n debits_posted: bigint\n\n /**\n * See [credits_pending](https://docs.tigerbeetle.com/reference/accounts/#credits_pending)\n */\n credits_pending: bigint\n\n /**\n * See [credits_posted](https://docs.tigerbeetle.com/reference/accounts/#credits_posted)\n */\n credits_posted: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/accounts/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/accounts/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/accounts/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [reserved](https://docs.tigerbeetle.com/reference/accounts/#reserved)\n */\n reserved: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/accounts/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/accounts/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/accounts/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/accounts/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [Transfer](https://docs.tigerbeetle.com/reference/transfers/#)\n*/\nexport type Transfer = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/transfers/#id)\n */\n id: bigint\n\n /**\n * See [debit_account_id](https://docs.tigerbeetle.com/reference/transfers/#debit_account_id)\n */\n debit_account_id: bigint\n\n /**\n * See [credit_account_id](https://docs.tigerbeetle.com/reference/transfers/#credit_account_id)\n */\n credit_account_id: bigint\n\n /**\n * See [amount](https://docs.tigerbeetle.com/reference/transfers/#amount)\n */\n amount: bigint\n\n /**\n * See [pending_id](https://docs.tigerbeetle.com/reference/transfers/#pending_id)\n */\n pending_id: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/transfers/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/transfers/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/transfers/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [timeout](https://docs.tigerbeetle.com/reference/transfers/#timeout)\n */\n timeout: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/transfers/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/transfers/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/transfers/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/transfers/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [CreateAccountError](https://docs.tigerbeetle.com/reference/operations/create_accounts#)\n*/\nexport enum CreateAccountError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_accounts#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_field](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_field)\n */\n reserved_field = 4,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_flag)\n */\n reserved_flag = 5,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_zero)\n */\n id_must_not_be_zero = 6,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 7,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_accounts#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 8,\n\n /**\n * See [debits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_pending_must_be_zero)\n */\n debits_pending_must_be_zero = 9,\n\n /**\n * See [debits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_posted_must_be_zero)\n */\n debits_posted_must_be_zero = 10,\n\n /**\n * See [credits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_pending_must_be_zero)\n */\n credits_pending_must_be_zero = 11,\n\n /**\n * See [credits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_posted_must_be_zero)\n */\n credits_posted_must_be_zero = 12,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 13,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#code_must_not_be_zero)\n */\n code_must_not_be_zero = 14,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_flags)\n */\n exists_with_different_flags = 15,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 16,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 17,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 18,\n\n /**\n * See [exists_with_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_ledger)\n */\n exists_with_different_ledger = 19,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_code)\n */\n exists_with_different_code = 20,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists)\n */\n exists = 21,\n}\n\n\n/**\n* See [CreateTransferError](https://docs.tigerbeetle.com/reference/operations/create_transfers#)\n*/\nexport enum CreateTransferError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_transfers#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_transfers#reserved_flag)\n */\n reserved_flag = 4,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_zero)\n */\n id_must_not_be_zero = 5,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 6,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_transfers#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 7,\n\n /**\n * See [debit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_zero)\n */\n debit_account_id_must_not_be_zero = 8,\n\n /**\n * See [debit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_int_max)\n */\n debit_account_id_must_not_be_int_max = 9,\n\n /**\n * See [credit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_zero)\n */\n credit_account_id_must_not_be_zero = 10,\n\n /**\n * See [credit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_int_max)\n */\n credit_account_id_must_not_be_int_max = 11,\n\n /**\n * See [accounts_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_be_different)\n */\n accounts_must_be_different = 12,\n\n /**\n * See [pending_id_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_zero)\n */\n pending_id_must_be_zero = 13,\n\n /**\n * See [pending_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_zero)\n */\n pending_id_must_not_be_zero = 14,\n\n /**\n * See [pending_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_int_max)\n */\n pending_id_must_not_be_int_max = 15,\n\n /**\n * See [pending_id_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_different)\n */\n pending_id_must_be_different = 16,\n\n /**\n * See [timeout_reserved_for_pending_transfer](https://docs.tigerbeetle.com/reference/operations/create_transfers#timeout_reserved_for_pending_transfer)\n */\n timeout_reserved_for_pending_transfer = 17,\n\n /**\n * See [amount_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#amount_must_not_be_zero)\n */\n amount_must_not_be_zero = 18,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 19,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#code_must_not_be_zero)\n */\n code_must_not_be_zero = 20,\n\n /**\n * See [debit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_not_found)\n */\n debit_account_not_found = 21,\n\n /**\n * See [credit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_not_found)\n */\n credit_account_not_found = 22,\n\n /**\n * See [accounts_must_have_the_same_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_have_the_same_ledger)\n */\n accounts_must_have_the_same_ledger = 23,\n\n /**\n * See [transfer_must_have_the_same_ledger_as_accounts](https://docs.tigerbeetle.com/reference/operations/create_transfers#transfer_must_have_the_same_ledger_as_accounts)\n */\n transfer_must_have_the_same_ledger_as_accounts = 24,\n\n /**\n * See [pending_transfer_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_found)\n */\n pending_transfer_not_found = 25,\n\n /**\n * See [pending_transfer_not_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_pending)\n */\n pending_transfer_not_pending = 26,\n\n /**\n * See [pending_transfer_has_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_debit_account_id)\n */\n pending_transfer_has_different_debit_account_id = 27,\n\n /**\n * See [pending_transfer_has_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_credit_account_id)\n */\n pending_transfer_has_different_credit_account_id = 28,\n\n /**\n * See [pending_transfer_has_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_ledger)\n */\n pending_transfer_has_different_ledger = 29,\n\n /**\n * See [pending_transfer_has_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_code)\n */\n pending_transfer_has_different_code = 30,\n\n /**\n * See [exceeds_pending_transfer_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_pending_transfer_amount)\n */\n exceeds_pending_transfer_amount = 31,\n\n /**\n * See [pending_transfer_has_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_amount)\n */\n pending_transfer_has_different_amount = 32,\n\n /**\n * See [pending_transfer_already_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_posted)\n */\n pending_transfer_already_posted = 33,\n\n /**\n * See [pending_transfer_already_voided](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_voided)\n */\n pending_transfer_already_voided = 34,\n\n /**\n * See [pending_transfer_expired](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_expired)\n */\n pending_transfer_expired = 35,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_flags)\n */\n exists_with_different_flags = 36,\n\n /**\n * See [exists_with_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_debit_account_id)\n */\n exists_with_different_debit_account_id = 37,\n\n /**\n * See [exists_with_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_credit_account_id)\n */\n exists_with_different_credit_account_id = 38,\n\n /**\n * See [exists_with_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_amount)\n */\n exists_with_different_amount = 39,\n\n /**\n * See [exists_with_different_pending_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_pending_id)\n */\n exists_with_different_pending_id = 40,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 41,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 42,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 43,\n\n /**\n * See [exists_with_different_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_timeout)\n */\n exists_with_different_timeout = 44,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_code)\n */\n exists_with_different_code = 45,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists)\n */\n exists = 46,\n\n /**\n * See [overflows_debits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_pending)\n */\n overflows_debits_pending = 47,\n\n /**\n * See [overflows_credits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_pending)\n */\n overflows_credits_pending = 48,\n\n /**\n * See [overflows_debits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_posted)\n */\n overflows_debits_posted = 49,\n\n /**\n * See [overflows_credits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_posted)\n */\n overflows_credits_posted = 50,\n\n /**\n * See [overflows_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits)\n */\n overflows_debits = 51,\n\n /**\n * See [overflows_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits)\n */\n overflows_credits = 52,\n\n /**\n * See [overflows_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_timeout)\n */\n overflows_timeout = 53,\n\n /**\n * See [exceeds_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_credits)\n */\n exceeds_credits = 54,\n\n /**\n * See [exceeds_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_debits)\n */\n exceeds_debits = 55,\n}\n\nexport type CreateAccountsError = {\n index: number\n result: CreateAccountError\n}\n\nexport type CreateTransfersError = {\n index: number\n result: CreateTransferError\n}\n\n\n/**\n* See [GetAccountTransfers](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#)\n*/\nexport type GetAccountTransfers = {\n\n /**\n * See [account_id](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#account_id)\n */\n account_id: bigint\n\n /**\n * See [timestamp_min](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#timestamp_min)\n */\n timestamp_min: bigint\n\n /**\n * See [timestamp_max](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#timestamp_max)\n */\n timestamp_max: bigint\n\n /**\n * See [limit](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#limit)\n */\n limit: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flags)\n */\n flags: number\n}\n\nexport enum Operation {\n create_accounts = 128,\n create_transfers = 129,\n lookup_accounts = 130,\n lookup_transfers = 131,\n get_account_transfers = 132,\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":";;;AASA,IAAY,YAsBX;AAtBD,WAAY,YAAY;IACtB,+CAAQ,CAAA;IA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,KAAnB,2BAAmB,QAyR9B;AA4ED,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,iEAAqB,CAAA;IACrB,mEAAsB,CAAA;IACtB,iEAAqB,CAAA;IACrB,mEAAsB,CAAA;IACtB,6EAA2B,CAAA;IAC3B,yEAAyB,CAAA;AAC3B,CAAC,EAPW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAOpB","sourcesContent":["///////////////////////////////////////////////////////\n// This file was auto-generated by node_bindings.zig //\n// Do not manually modify. //\n///////////////////////////////////////////////////////\n\n\n/**\n* See [AccountFlags](https://docs.tigerbeetle.com/reference/accounts#flags)\n*/\nexport enum AccountFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/accounts#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [debits_must_not_exceed_credits](https://docs.tigerbeetle.com/reference/accounts#flagsdebits_must_not_exceed_credits)\n */\n debits_must_not_exceed_credits = (1 << 1),\n\n /**\n * See [credits_must_not_exceed_debits](https://docs.tigerbeetle.com/reference/accounts#flagscredits_must_not_exceed_debits)\n */\n credits_must_not_exceed_debits = (1 << 2),\n\n /**\n * See [history](https://docs.tigerbeetle.com/reference/accounts#flagshistory)\n */\n history = (1 << 3),\n}\n\n\n/**\n* See [TransferFlags](https://docs.tigerbeetle.com/reference/transfers#flags)\n*/\nexport enum TransferFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/transfers#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [pending](https://docs.tigerbeetle.com/reference/transfers#flagspending)\n */\n pending = (1 << 1),\n\n /**\n * See [post_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagspost_pending_transfer)\n */\n post_pending_transfer = (1 << 2),\n\n /**\n * See [void_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagsvoid_pending_transfer)\n */\n void_pending_transfer = (1 << 3),\n\n /**\n * See [balancing_debit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_debit)\n */\n balancing_debit = (1 << 4),\n\n /**\n * See [balancing_credit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_credit)\n */\n balancing_credit = (1 << 5),\n}\n\n\n/**\n* See [AccountFilterFlags](https://docs.tigerbeetle.com/reference/account_filter#flags)\n*/\nexport enum AccountFilterFlags {\n none = 0,\n\n /**\n * See [debits](https://docs.tigerbeetle.com/reference/account_filter#flagsdebits)\n */\n debits = (1 << 0),\n\n /**\n * See [credits](https://docs.tigerbeetle.com/reference/account_filter#flagscredits)\n */\n credits = (1 << 1),\n\n /**\n * See [reversed](https://docs.tigerbeetle.com/reference/account_filter#flagsreversed)\n */\n reversed = (1 << 2),\n}\n\n\n/**\n* See [Account](https://docs.tigerbeetle.com/reference/accounts/#)\n*/\nexport type Account = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/accounts/#id)\n */\n id: bigint\n\n /**\n * See [debits_pending](https://docs.tigerbeetle.com/reference/accounts/#debits_pending)\n */\n debits_pending: bigint\n\n /**\n * See [debits_posted](https://docs.tigerbeetle.com/reference/accounts/#debits_posted)\n */\n debits_posted: bigint\n\n /**\n * See [credits_pending](https://docs.tigerbeetle.com/reference/accounts/#credits_pending)\n */\n credits_pending: bigint\n\n /**\n * See [credits_posted](https://docs.tigerbeetle.com/reference/accounts/#credits_posted)\n */\n credits_posted: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/accounts/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/accounts/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/accounts/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [reserved](https://docs.tigerbeetle.com/reference/accounts/#reserved)\n */\n reserved: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/accounts/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/accounts/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/accounts/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/accounts/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [Transfer](https://docs.tigerbeetle.com/reference/transfers/#)\n*/\nexport type Transfer = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/transfers/#id)\n */\n id: bigint\n\n /**\n * See [debit_account_id](https://docs.tigerbeetle.com/reference/transfers/#debit_account_id)\n */\n debit_account_id: bigint\n\n /**\n * See [credit_account_id](https://docs.tigerbeetle.com/reference/transfers/#credit_account_id)\n */\n credit_account_id: bigint\n\n /**\n * See [amount](https://docs.tigerbeetle.com/reference/transfers/#amount)\n */\n amount: bigint\n\n /**\n * See [pending_id](https://docs.tigerbeetle.com/reference/transfers/#pending_id)\n */\n pending_id: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/transfers/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/transfers/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/transfers/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [timeout](https://docs.tigerbeetle.com/reference/transfers/#timeout)\n */\n timeout: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/transfers/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/transfers/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/transfers/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/transfers/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [CreateAccountError](https://docs.tigerbeetle.com/reference/operations/create_accounts#)\n*/\nexport enum CreateAccountError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_accounts#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_field](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_field)\n */\n reserved_field = 4,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_flag)\n */\n reserved_flag = 5,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_zero)\n */\n id_must_not_be_zero = 6,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 7,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_accounts#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 8,\n\n /**\n * See [debits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_pending_must_be_zero)\n */\n debits_pending_must_be_zero = 9,\n\n /**\n * See [debits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_posted_must_be_zero)\n */\n debits_posted_must_be_zero = 10,\n\n /**\n * See [credits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_pending_must_be_zero)\n */\n credits_pending_must_be_zero = 11,\n\n /**\n * See [credits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_posted_must_be_zero)\n */\n credits_posted_must_be_zero = 12,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 13,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#code_must_not_be_zero)\n */\n code_must_not_be_zero = 14,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_flags)\n */\n exists_with_different_flags = 15,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 16,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 17,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 18,\n\n /**\n * See [exists_with_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_ledger)\n */\n exists_with_different_ledger = 19,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_code)\n */\n exists_with_different_code = 20,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists)\n */\n exists = 21,\n}\n\n\n/**\n* See [CreateTransferError](https://docs.tigerbeetle.com/reference/operations/create_transfers#)\n*/\nexport enum CreateTransferError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_transfers#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_transfers#reserved_flag)\n */\n reserved_flag = 4,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_zero)\n */\n id_must_not_be_zero = 5,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 6,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_transfers#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 7,\n\n /**\n * See [debit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_zero)\n */\n debit_account_id_must_not_be_zero = 8,\n\n /**\n * See [debit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_int_max)\n */\n debit_account_id_must_not_be_int_max = 9,\n\n /**\n * See [credit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_zero)\n */\n credit_account_id_must_not_be_zero = 10,\n\n /**\n * See [credit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_int_max)\n */\n credit_account_id_must_not_be_int_max = 11,\n\n /**\n * See [accounts_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_be_different)\n */\n accounts_must_be_different = 12,\n\n /**\n * See [pending_id_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_zero)\n */\n pending_id_must_be_zero = 13,\n\n /**\n * See [pending_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_zero)\n */\n pending_id_must_not_be_zero = 14,\n\n /**\n * See [pending_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_int_max)\n */\n pending_id_must_not_be_int_max = 15,\n\n /**\n * See [pending_id_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_different)\n */\n pending_id_must_be_different = 16,\n\n /**\n * See [timeout_reserved_for_pending_transfer](https://docs.tigerbeetle.com/reference/operations/create_transfers#timeout_reserved_for_pending_transfer)\n */\n timeout_reserved_for_pending_transfer = 17,\n\n /**\n * See [amount_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#amount_must_not_be_zero)\n */\n amount_must_not_be_zero = 18,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 19,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#code_must_not_be_zero)\n */\n code_must_not_be_zero = 20,\n\n /**\n * See [debit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_not_found)\n */\n debit_account_not_found = 21,\n\n /**\n * See [credit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_not_found)\n */\n credit_account_not_found = 22,\n\n /**\n * See [accounts_must_have_the_same_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_have_the_same_ledger)\n */\n accounts_must_have_the_same_ledger = 23,\n\n /**\n * See [transfer_must_have_the_same_ledger_as_accounts](https://docs.tigerbeetle.com/reference/operations/create_transfers#transfer_must_have_the_same_ledger_as_accounts)\n */\n transfer_must_have_the_same_ledger_as_accounts = 24,\n\n /**\n * See [pending_transfer_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_found)\n */\n pending_transfer_not_found = 25,\n\n /**\n * See [pending_transfer_not_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_pending)\n */\n pending_transfer_not_pending = 26,\n\n /**\n * See [pending_transfer_has_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_debit_account_id)\n */\n pending_transfer_has_different_debit_account_id = 27,\n\n /**\n * See [pending_transfer_has_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_credit_account_id)\n */\n pending_transfer_has_different_credit_account_id = 28,\n\n /**\n * See [pending_transfer_has_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_ledger)\n */\n pending_transfer_has_different_ledger = 29,\n\n /**\n * See [pending_transfer_has_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_code)\n */\n pending_transfer_has_different_code = 30,\n\n /**\n * See [exceeds_pending_transfer_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_pending_transfer_amount)\n */\n exceeds_pending_transfer_amount = 31,\n\n /**\n * See [pending_transfer_has_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_amount)\n */\n pending_transfer_has_different_amount = 32,\n\n /**\n * See [pending_transfer_already_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_posted)\n */\n pending_transfer_already_posted = 33,\n\n /**\n * See [pending_transfer_already_voided](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_voided)\n */\n pending_transfer_already_voided = 34,\n\n /**\n * See [pending_transfer_expired](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_expired)\n */\n pending_transfer_expired = 35,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_flags)\n */\n exists_with_different_flags = 36,\n\n /**\n * See [exists_with_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_debit_account_id)\n */\n exists_with_different_debit_account_id = 37,\n\n /**\n * See [exists_with_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_credit_account_id)\n */\n exists_with_different_credit_account_id = 38,\n\n /**\n * See [exists_with_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_amount)\n */\n exists_with_different_amount = 39,\n\n /**\n * See [exists_with_different_pending_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_pending_id)\n */\n exists_with_different_pending_id = 40,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 41,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 42,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 43,\n\n /**\n * See [exists_with_different_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_timeout)\n */\n exists_with_different_timeout = 44,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_code)\n */\n exists_with_different_code = 45,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists)\n */\n exists = 46,\n\n /**\n * See [overflows_debits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_pending)\n */\n overflows_debits_pending = 47,\n\n /**\n * See [overflows_credits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_pending)\n */\n overflows_credits_pending = 48,\n\n /**\n * See [overflows_debits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_posted)\n */\n overflows_debits_posted = 49,\n\n /**\n * See [overflows_credits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_posted)\n */\n overflows_credits_posted = 50,\n\n /**\n * See [overflows_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits)\n */\n overflows_debits = 51,\n\n /**\n * See [overflows_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits)\n */\n overflows_credits = 52,\n\n /**\n * See [overflows_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_timeout)\n */\n overflows_timeout = 53,\n\n /**\n * See [exceeds_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_credits)\n */\n exceeds_credits = 54,\n\n /**\n * See [exceeds_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_debits)\n */\n exceeds_debits = 55,\n}\n\nexport type CreateAccountsError = {\n index: number\n result: CreateAccountError\n}\n\nexport type CreateTransfersError = {\n index: number\n result: CreateTransferError\n}\n\n\n/**\n* See [AccountFilter](https://docs.tigerbeetle.com/reference/account_filter#)\n*/\nexport type AccountFilter = {\n\n /**\n * See [account_id](https://docs.tigerbeetle.com/reference/account_filter#account_id)\n */\n account_id: bigint\n\n /**\n * See [timestamp_min](https://docs.tigerbeetle.com/reference/account_filter#timestamp_min)\n */\n timestamp_min: bigint\n\n /**\n * See [timestamp_max](https://docs.tigerbeetle.com/reference/account_filter#timestamp_max)\n */\n timestamp_max: bigint\n\n /**\n * See [limit](https://docs.tigerbeetle.com/reference/account_filter#limit)\n */\n limit: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/account_filter#flags)\n */\n flags: number\n}\n\n\n/**\n* See [AccountBalance](https://docs.tigerbeetle.com/reference/account_balances#)\n*/\nexport type AccountBalance = {\n\n /**\n * See [debits_pending](https://docs.tigerbeetle.com/reference/account_balances#debits_pending)\n */\n debits_pending: bigint\n\n /**\n * See [debits_posted](https://docs.tigerbeetle.com/reference/account_balances#debits_posted)\n */\n debits_posted: bigint\n\n /**\n * See [credits_pending](https://docs.tigerbeetle.com/reference/account_balances#credits_pending)\n */\n credits_pending: bigint\n\n /**\n * See [credits_posted](https://docs.tigerbeetle.com/reference/account_balances#credits_posted)\n */\n credits_posted: bigint\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/account_balances#timestamp)\n */\n timestamp: bigint\n}\n\nexport enum Operation {\n create_accounts = 128,\n create_transfers = 129,\n lookup_accounts = 130,\n lookup_transfers = 131,\n get_account_transfers = 132,\n get_account_history = 133,\n}\n\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './bindings';
|
|
2
|
-
import { Account, Transfer, CreateAccountsError, CreateTransfersError,
|
|
2
|
+
import { Account, Transfer, CreateAccountsError, CreateTransfersError, AccountFilter, AccountBalance } from './bindings';
|
|
3
3
|
export declare type Context = object;
|
|
4
4
|
export declare type AccountID = bigint;
|
|
5
5
|
export declare type TransferID = bigint;
|
|
6
|
-
export declare type Event = Account | Transfer | AccountID | TransferID |
|
|
7
|
-
export declare type Result = CreateAccountsError | CreateTransfersError | Account | Transfer;
|
|
6
|
+
export declare type Event = Account | Transfer | AccountID | TransferID | AccountFilter;
|
|
7
|
+
export declare type Result = CreateAccountsError | CreateTransfersError | Account | Transfer | AccountBalance;
|
|
8
8
|
export declare type ResultCallback = (error: Error | null, results: Result[] | null) => void;
|
|
9
9
|
export interface ClientInitArgs {
|
|
10
10
|
cluster_id: bigint;
|
|
@@ -16,7 +16,9 @@ export interface Client {
|
|
|
16
16
|
createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>;
|
|
17
17
|
lookupAccounts: (batch: AccountID[]) => Promise<Account[]>;
|
|
18
18
|
lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>;
|
|
19
|
-
getAccountTransfers: (filter:
|
|
19
|
+
getAccountTransfers: (filter: AccountFilter) => Promise<Transfer[]>;
|
|
20
|
+
getAccountHistory: (filter: AccountFilter) => Promise<AccountBalance[]>;
|
|
20
21
|
destroy: () => void;
|
|
21
22
|
}
|
|
22
23
|
export declare function createClient(args: ClientInitArgs): Client;
|
|
24
|
+
export declare function id(): bigint;
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.createClient = void 0;
|
|
13
|
+
exports.id = exports.createClient = void 0;
|
|
14
14
|
__exportStar(require("./bindings"), exports);
|
|
15
15
|
const bindings_1 = require("./bindings");
|
|
16
|
+
const node_crypto_1 = require("node:crypto");
|
|
16
17
|
const binding = (() => {
|
|
17
18
|
const { arch, platform } = process;
|
|
18
19
|
const archMap = {
|
|
@@ -79,8 +80,37 @@ function createClient(args) {
|
|
|
79
80
|
lookupAccounts(batch) { return request(bindings_1.Operation.lookup_accounts, batch); },
|
|
80
81
|
lookupTransfers(batch) { return request(bindings_1.Operation.lookup_transfers, batch); },
|
|
81
82
|
getAccountTransfers(filter) { return request(bindings_1.Operation.get_account_transfers, [filter]); },
|
|
83
|
+
getAccountHistory(filter) { return request(bindings_1.Operation.get_account_history, [filter]); },
|
|
82
84
|
destroy() { binding.deinit(context); },
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
exports.createClient = createClient;
|
|
88
|
+
let idLastTimestamp = 0;
|
|
89
|
+
let idLastBuffer = new DataView(new ArrayBuffer(16));
|
|
90
|
+
function id() {
|
|
91
|
+
let timestamp = Date.now();
|
|
92
|
+
if (timestamp <= idLastTimestamp) {
|
|
93
|
+
timestamp = idLastTimestamp;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
idLastTimestamp = timestamp;
|
|
97
|
+
(0, node_crypto_1.randomFillSync)(idLastBuffer);
|
|
98
|
+
}
|
|
99
|
+
const littleEndian = true;
|
|
100
|
+
const randomLo32 = idLastBuffer.getUint32(0, littleEndian) + 1;
|
|
101
|
+
const randomHi32 = idLastBuffer.getUint32(4, littleEndian) + (randomLo32 > 0xFFFFFFFF ? 1 : 0);
|
|
102
|
+
const randomHi16 = idLastBuffer.getUint16(8, littleEndian) + (randomHi32 > 0xFFFFFFFF ? 1 : 0);
|
|
103
|
+
if (randomHi16 > 0xFFFF) {
|
|
104
|
+
throw new Error('random bits overflow on monotonic increment');
|
|
105
|
+
}
|
|
106
|
+
idLastBuffer.setUint32(0, randomLo32 & 0xFFFFFFFF, littleEndian);
|
|
107
|
+
idLastBuffer.setUint32(4, randomHi32 & 0xFFFFFFFF, littleEndian);
|
|
108
|
+
idLastBuffer.setUint16(8, randomHi16, littleEndian);
|
|
109
|
+
idLastBuffer.setUint16(10, timestamp & 0xFFFF, littleEndian);
|
|
110
|
+
idLastBuffer.setUint32(12, (timestamp >>> 16) & 0xFFFFFFFF, littleEndian);
|
|
111
|
+
const lo = idLastBuffer.getBigUint64(0, littleEndian);
|
|
112
|
+
const hi = idLastBuffer.getBigUint64(8, littleEndian);
|
|
113
|
+
return (hi << 64n) | lo;
|
|
114
|
+
}
|
|
115
|
+
exports.id = id;
|
|
86
116
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,yCAOmB;AAEnB,MAAM,OAAO,GAAY,CAAC,GAAG,EAAE;IAC7B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAElC,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,QAAQ;KAChB,CAAA;IAED,MAAM,WAAW,GAAG;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAG,SAAS;KACpB,CAAA;IAED,IAAI,CAAE,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;KAC7C;IAED,IAAI,CAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,IAAI,KAAK,GAAG,EAAE,CAAA;IAcd,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,MAA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,CAAA;qBACd;yBAAM,IAAI,MAAM,EAAE;wBACjB,OAAO,CAAC,MAAa,CAAC,CAAA;qBACvB;yBAAM;wBACL,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;qBACxE;gBACH,CAAC,CAAC,CAAA;aACH;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAA;aACZ;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO;QACL,cAAc,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC1E,eAAe,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC5E,cAAc,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC1E,eAAe,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC5E,mBAAmB,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC;QACzF,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA,CAAC,CAAC;KACtC,CAAA;AACH,CAAC;AAlCD,oCAkCC","sourcesContent":["export * from './bindings'\nimport {\n Account,\n Transfer,\n CreateAccountsError,\n CreateTransfersError,\n Operation,\n GetAccountTransfers,\n} from './bindings'\n\nconst binding: Binding = (() => {\n const { arch, platform } = process\n\n const archMap = {\n \"arm64\": \"aarch64\",\n \"x64\": \"x86_64\"\n }\n\n const platformMap = {\n \"linux\": \"linux\",\n \"darwin\": \"macos\",\n \"win32\" : \"windows\",\n }\n\n if (! (arch in archMap)) {\n throw new Error(`Unsupported arch: ${arch}`)\n }\n\n if (! (platform in platformMap)) {\n throw new Error(`Unsupported platform: ${platform}`)\n }\n\n let extra = ''\n\n /**\n * We need to detect during runtime which libc we're running on to load the correct NAPI.\n * binary.\n *\n * Rationale: The /proc/self/map_files/ subdirectory contains entries corresponding to\n * memory-mapped files loaded by Node.\n * https://man7.org/linux/man-pages/man5/proc.5.html: We detect a musl-based distro by\n * checking if any library contains the name \"musl\".\n *\n * Prior art: https://github.com/xerial/sqlite-jdbc/issues/623\n */\n\n const fs = require('fs')\n const path = require('path')\n\n if (platform === 'linux') {\n extra = '-gnu'\n\n for (const file of fs.readdirSync(\"/proc/self/map_files/\")) {\n const realPath = fs.readlinkSync(path.join(\"/proc/self/map_files/\", file))\n if (realPath.includes('musl')) {\n extra = '-musl'\n break\n }\n }\n }\n\n const filename = `./bin/${archMap[arch]}-${platformMap[platform]}${extra}/client.node`\n return require(filename)\n})()\n\nexport type Context = object // tb_client\nexport type AccountID = bigint // u128\nexport type TransferID = bigint // u128\nexport type Event = Account | Transfer | AccountID | TransferID | GetAccountTransfers\nexport type Result = CreateAccountsError | CreateTransfersError | Account | Transfer\nexport type ResultCallback = (error: Error | null, results: Result[] | null) => void\n\ninterface BindingInitArgs {\n cluster_id: bigint, // u128\n concurrency: number, // u32\n replica_addresses: Buffer,\n}\n\ninterface Binding {\n init: (args: BindingInitArgs) => Context\n submit: (context: Context, operation: Operation, batch: Event[], callback: ResultCallback) => void\n deinit: (context: Context) => void,\n}\n\nexport interface ClientInitArgs {\n cluster_id: bigint, // u128\n concurrency_max?: number, // u32\n replica_addresses: Array<string | number>,\n}\n\nexport interface Client {\n createAccounts: (batch: Account[]) => Promise<CreateAccountsError[]>\n createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>\n lookupAccounts: (batch: AccountID[]) => Promise<Account[]>\n lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>\n getAccountTransfers: (filter: GetAccountTransfers) => Promise<Transfer[]>\n destroy: () => void\n}\n\nexport function createClient (args: ClientInitArgs): Client {\n const concurrency_max_default = 256 // arbitrary\n const context = binding.init({\n cluster_id: args.cluster_id,\n concurrency: args.concurrency_max || concurrency_max_default,\n replica_addresses: Buffer.from(args.replica_addresses.join(',')),\n })\n\n const request = <T extends Result>(operation: Operation, batch: Event[]): Promise<T[]> => {\n return new Promise((resolve, reject) => {\n try {\n binding.submit(context, operation, batch, (error, result) => {\n if (error) {\n reject(error)\n } else if (result) {\n resolve(result as T[])\n } else {\n throw new Error(\"UB: Binding invoked callback without error or result\")\n }\n })\n } catch (err) {\n reject(err)\n }\n })\n }\n\n return {\n createAccounts(batch) { return request(Operation.create_accounts, batch) },\n createTransfers(batch) { return request(Operation.create_transfers, batch) },\n lookupAccounts(batch) { return request(Operation.lookup_accounts, batch) },\n lookupTransfers(batch) { return request(Operation.lookup_transfers, batch) },\n getAccountTransfers(filter) { return request(Operation.get_account_transfers, [filter]) },\n destroy() { binding.deinit(context) },\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,yCAQmB;AACnB,6CAA4C;AAE5C,MAAM,OAAO,GAAY,CAAC,GAAG,EAAE;IAC7B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAElC,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,QAAQ;KAChB,CAAA;IAED,MAAM,WAAW,GAAG;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAG,SAAS;KACpB,CAAA;IAED,IAAI,CAAE,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;KAC7C;IAED,IAAI,CAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,EAAE;QAC/B,MAAM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YAAY,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC,GAAG,UAAU,EAAE,YAAY,CAAC,CAAA;IAGzE,MAAM,EAAE,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;IACrD,MAAM,EAAE,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;IACrD,OAAO,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC;AA9BD,gBA8BC","sourcesContent":["export * from './bindings'\nimport {\n Account,\n Transfer,\n CreateAccountsError,\n CreateTransfersError,\n Operation,\n AccountFilter,\n AccountBalance,\n} from './bindings'\nimport { randomFillSync } from 'node:crypto'\n\nconst binding: Binding = (() => {\n const { arch, platform } = process\n\n const archMap = {\n \"arm64\": \"aarch64\",\n \"x64\": \"x86_64\"\n }\n\n const platformMap = {\n \"linux\": \"linux\",\n \"darwin\": \"macos\",\n \"win32\" : \"windows\",\n }\n\n if (! (arch in archMap)) {\n throw new Error(`Unsupported arch: ${arch}`)\n }\n\n if (! (platform in platformMap)) {\n throw new Error(`Unsupported platform: ${platform}`)\n }\n\n let extra = ''\n\n /**\n * We need to detect during runtime which libc we're running on to load the correct NAPI.\n * binary.\n *\n * Rationale: The /proc/self/map_files/ subdirectory contains entries corresponding to\n * memory-mapped files loaded by Node.\n * https://man7.org/linux/man-pages/man5/proc.5.html: We detect a musl-based distro by\n * checking if any library contains the name \"musl\".\n *\n * Prior art: https://github.com/xerial/sqlite-jdbc/issues/623\n */\n\n const fs = require('fs')\n const path = require('path')\n\n if (platform === 'linux') {\n extra = '-gnu'\n\n for (const file of fs.readdirSync(\"/proc/self/map_files/\")) {\n const realPath = fs.readlinkSync(path.join(\"/proc/self/map_files/\", file))\n if (realPath.includes('musl')) {\n extra = '-musl'\n break\n }\n }\n }\n\n const filename = `./bin/${archMap[arch]}-${platformMap[platform]}${extra}/client.node`\n return require(filename)\n})()\n\nexport type Context = object // tb_client\nexport type AccountID = bigint // u128\nexport type TransferID = bigint // u128\nexport type Event = Account | Transfer | AccountID | TransferID | AccountFilter\nexport type Result = CreateAccountsError | CreateTransfersError | Account | Transfer | AccountBalance\nexport type ResultCallback = (error: Error | null, results: Result[] | null) => void\n\ninterface BindingInitArgs {\n cluster_id: bigint, // u128\n concurrency: number, // u32\n replica_addresses: Buffer,\n}\n\ninterface Binding {\n init: (args: BindingInitArgs) => Context\n submit: (context: Context, operation: Operation, batch: Event[], callback: ResultCallback) => void\n deinit: (context: Context) => void,\n}\n\nexport interface ClientInitArgs {\n cluster_id: bigint, // u128\n concurrency_max?: number, // u32\n replica_addresses: Array<string | number>,\n}\n\nexport interface Client {\n createAccounts: (batch: Account[]) => Promise<CreateAccountsError[]>\n createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>\n lookupAccounts: (batch: AccountID[]) => Promise<Account[]>\n lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>\n getAccountTransfers: (filter: AccountFilter) => Promise<Transfer[]>\n getAccountHistory: (filter: AccountFilter) => Promise<AccountBalance[]>\n destroy: () => void\n}\n\nexport function createClient (args: ClientInitArgs): Client {\n const concurrency_max_default = 256 // arbitrary\n const context = binding.init({\n cluster_id: args.cluster_id,\n concurrency: args.concurrency_max || concurrency_max_default,\n replica_addresses: Buffer.from(args.replica_addresses.join(',')),\n })\n\n const request = <T extends Result>(operation: Operation, batch: Event[]): Promise<T[]> => {\n return new Promise((resolve, reject) => {\n try {\n binding.submit(context, operation, batch, (error, result) => {\n if (error) {\n reject(error)\n } else if (result) {\n resolve(result as T[])\n } else {\n throw new Error(\"UB: Binding invoked callback without error or result\")\n }\n })\n } catch (err) {\n reject(err)\n }\n })\n }\n\n return {\n createAccounts(batch) { return request(Operation.create_accounts, batch) },\n createTransfers(batch) { return request(Operation.create_transfers, batch) },\n lookupAccounts(batch) { return request(Operation.lookup_accounts, batch) },\n lookupTransfers(batch) { return request(Operation.lookup_transfers, batch) },\n getAccountTransfers(filter) { return request(Operation.get_account_transfers, [filter]) },\n getAccountHistory(filter) { return request(Operation.get_account_history, [filter]) },\n destroy() { binding.deinit(context) },\n }\n}\n\nlet idLastTimestamp = 0;\nlet idLastBuffer = new DataView(new ArrayBuffer(16));\n\n/**\n * Generates a Universally Unique and Sortable Identifier as a u128 bigint.\n *\n * @remarks\n * Based on {@link https://github.com/ulid/spec}, IDs returned are guaranteed to be monotonically\n * increasing.\n */\nexport function id(): bigint {\n // Ensure timestamp monotonically increases and generate a new random on each new timestamp.\n let timestamp = Date.now()\n if (timestamp <= idLastTimestamp) {\n timestamp = idLastTimestamp\n } else {\n idLastTimestamp = timestamp\n randomFillSync(idLastBuffer)\n }\n\n // Increment the u80 in idLastBuffer using carry arithmetic on u32s (as JS doesn't have fast u64).\n const littleEndian = true\n const randomLo32 = idLastBuffer.getUint32(0, littleEndian) + 1\n const randomHi32 = idLastBuffer.getUint32(4, littleEndian) + (randomLo32 > 0xFFFFFFFF ? 1 : 0)\n const randomHi16 = idLastBuffer.getUint16(8, littleEndian) + (randomHi32 > 0xFFFFFFFF ? 1 : 0)\n if (randomHi16 > 0xFFFF) {\n throw new Error('random bits overflow on monotonic increment')\n }\n\n // Store the incremented random monotonic and the timestamp into the buffer.\n idLastBuffer.setUint32(0, randomLo32 & 0xFFFFFFFF, littleEndian)\n idLastBuffer.setUint32(4, randomHi32 & 0xFFFFFFFF, littleEndian)\n idLastBuffer.setUint16(8, randomHi16, littleEndian) // No need to mask since checked above.\n idLastBuffer.setUint16(10, timestamp & 0xFFFF, littleEndian) // timestamp lo.\n idLastBuffer.setUint32(12, (timestamp >>> 16) & 0xFFFFFFFF, littleEndian) // timestamp hi.\n\n // Then return the buffer's contents as a little-endian u128 bigint.\n const lo = idLastBuffer.getBigUint64(0, littleEndian)\n const hi = idLastBuffer.getBigUint64(8, littleEndian)\n return (hi << 64n) | lo\n}\n"]}
|