Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tigerbeetle-node

Package Overview
Dependencies
Maintainers
1
Versions
321
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tigerbeetle-node - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

src/tigerbeetle/scripts/confirm_image.sh

142

dist/index.d.ts

@@ -27,22 +27,19 @@ /// <reference types="node" />

linked_event_failed = 1,
reserved_flag = 2,
reserved_field = 3,
id_must_not_be_zero = 4,
id_must_not_be_int_max = 5,
ledger_must_not_be_zero = 6,
code_must_not_be_zero = 7,
mutually_exclusive_flags = 8,
overflows_debits = 9,
overflows_credits = 10,
exceeds_credits = 11,
exceeds_debits = 12,
exists_with_different_flags = 13,
exists_with_different_user_data = 14,
exists_with_different_ledger = 15,
exists_with_different_code = 16,
exists_with_different_debits_pending = 17,
exists_with_different_debits_posted = 18,
exists_with_different_credits_pending = 19,
exists_with_different_credits_posted = 20,
exists = 21
linked_event_chain_open = 2,
reserved_flag = 3,
reserved_field = 4,
id_must_not_be_zero = 5,
id_must_not_be_int_max = 6,
ledger_must_not_be_zero = 7,
code_must_not_be_zero = 8,
debits_pending_must_be_zero = 9,
debits_posted_must_be_zero = 10,
credits_pending_must_be_zero = 11,
credits_posted_must_be_zero = 12,
mutually_exclusive_flags = 13,
exists_with_different_flags = 14,
exists_with_different_user_data = 15,
exists_with_different_ledger = 16,
exists_with_different_code = 17,
exists = 18
}

@@ -75,54 +72,55 @@ export declare type CreateAccountsError = {

linked_event_failed = 1,
reserved_flag = 2,
reserved_field = 3,
id_must_not_be_zero = 4,
id_must_not_be_int_max = 5,
debit_account_id_must_not_be_zero = 6,
debit_account_id_must_not_be_int_max = 7,
credit_account_id_must_not_be_zero = 8,
credit_account_id_must_not_be_int_max = 9,
accounts_must_be_different = 10,
pending_id_must_be_zero = 11,
pending_transfer_must_timeout = 12,
ledger_must_not_be_zero = 13,
code_must_not_be_zero = 14,
amount_must_not_be_zero = 15,
debit_account_not_found = 16,
credit_account_not_found = 17,
accounts_must_have_the_same_ledger = 18,
transfer_must_have_the_same_ledger_as_accounts = 19,
exists_with_different_flags = 20,
exists_with_different_debit_account_id = 21,
exists_with_different_credit_account_id = 22,
exists_with_different_user_data = 23,
exists_with_different_pending_id = 24,
exists_with_different_timeout = 25,
exists_with_different_code = 26,
exists_with_different_amount = 27,
exists = 28,
overflows_debits_pending = 29,
overflows_credits_pending = 30,
overflows_debits_posted = 31,
overflows_credits_posted = 32,
overflows_debits = 33,
overflows_credits = 34,
exceeds_credits = 35,
exceeds_debits = 36,
cannot_post_and_void_pending_transfer = 37,
pending_transfer_cannot_post_or_void_another = 38,
timeout_reserved_for_pending_transfer = 39,
pending_id_must_not_be_zero = 40,
pending_id_must_not_be_int_max = 41,
pending_id_must_be_different = 42,
pending_transfer_not_found = 43,
pending_transfer_not_pending = 44,
pending_transfer_has_different_debit_account_id = 45,
pending_transfer_has_different_credit_account_id = 46,
pending_transfer_has_different_ledger = 47,
pending_transfer_has_different_code = 48,
exceeds_pending_transfer_amount = 49,
pending_transfer_has_different_amount = 50,
pending_transfer_already_posted = 51,
pending_transfer_already_voided = 52,
pending_transfer_expired = 53
linked_event_chain_open = 2,
reserved_flag = 3,
reserved_field = 4,
id_must_not_be_zero = 5,
id_must_not_be_int_max = 6,
debit_account_id_must_not_be_zero = 7,
debit_account_id_must_not_be_int_max = 8,
credit_account_id_must_not_be_zero = 9,
credit_account_id_must_not_be_int_max = 10,
accounts_must_be_different = 11,
pending_id_must_be_zero = 12,
pending_transfer_must_timeout = 13,
ledger_must_not_be_zero = 14,
code_must_not_be_zero = 15,
amount_must_not_be_zero = 16,
debit_account_not_found = 17,
credit_account_not_found = 18,
accounts_must_have_the_same_ledger = 19,
transfer_must_have_the_same_ledger_as_accounts = 20,
exists_with_different_flags = 21,
exists_with_different_debit_account_id = 22,
exists_with_different_credit_account_id = 23,
exists_with_different_user_data = 24,
exists_with_different_pending_id = 25,
exists_with_different_timeout = 26,
exists_with_different_code = 27,
exists_with_different_amount = 28,
exists = 29,
overflows_debits_pending = 30,
overflows_credits_pending = 31,
overflows_debits_posted = 32,
overflows_credits_posted = 33,
overflows_debits = 34,
overflows_credits = 35,
exceeds_credits = 36,
exceeds_debits = 37,
cannot_post_and_void_pending_transfer = 38,
pending_transfer_cannot_post_or_void_another = 39,
timeout_reserved_for_pending_transfer = 40,
pending_id_must_not_be_zero = 41,
pending_id_must_not_be_int_max = 42,
pending_id_must_be_different = 43,
pending_transfer_not_found = 44,
pending_transfer_not_pending = 45,
pending_transfer_has_different_debit_account_id = 46,
pending_transfer_has_different_credit_account_id = 47,
pending_transfer_has_different_ledger = 48,
pending_transfer_has_different_code = 49,
exceeds_pending_transfer_amount = 50,
pending_transfer_has_different_amount = 51,
pending_transfer_already_posted = 52,
pending_transfer_already_voided = 53,
pending_transfer_expired = 54
}

@@ -129,0 +127,0 @@ export declare type CreateTransfersError = {

@@ -14,22 +14,19 @@ "use strict";

CreateAccountError[CreateAccountError["linked_event_failed"] = 1] = "linked_event_failed";
CreateAccountError[CreateAccountError["reserved_flag"] = 2] = "reserved_flag";
CreateAccountError[CreateAccountError["reserved_field"] = 3] = "reserved_field";
CreateAccountError[CreateAccountError["id_must_not_be_zero"] = 4] = "id_must_not_be_zero";
CreateAccountError[CreateAccountError["id_must_not_be_int_max"] = 5] = "id_must_not_be_int_max";
CreateAccountError[CreateAccountError["ledger_must_not_be_zero"] = 6] = "ledger_must_not_be_zero";
CreateAccountError[CreateAccountError["code_must_not_be_zero"] = 7] = "code_must_not_be_zero";
CreateAccountError[CreateAccountError["mutually_exclusive_flags"] = 8] = "mutually_exclusive_flags";
CreateAccountError[CreateAccountError["overflows_debits"] = 9] = "overflows_debits";
CreateAccountError[CreateAccountError["overflows_credits"] = 10] = "overflows_credits";
CreateAccountError[CreateAccountError["exceeds_credits"] = 11] = "exceeds_credits";
CreateAccountError[CreateAccountError["exceeds_debits"] = 12] = "exceeds_debits";
CreateAccountError[CreateAccountError["exists_with_different_flags"] = 13] = "exists_with_different_flags";
CreateAccountError[CreateAccountError["exists_with_different_user_data"] = 14] = "exists_with_different_user_data";
CreateAccountError[CreateAccountError["exists_with_different_ledger"] = 15] = "exists_with_different_ledger";
CreateAccountError[CreateAccountError["exists_with_different_code"] = 16] = "exists_with_different_code";
CreateAccountError[CreateAccountError["exists_with_different_debits_pending"] = 17] = "exists_with_different_debits_pending";
CreateAccountError[CreateAccountError["exists_with_different_debits_posted"] = 18] = "exists_with_different_debits_posted";
CreateAccountError[CreateAccountError["exists_with_different_credits_pending"] = 19] = "exists_with_different_credits_pending";
CreateAccountError[CreateAccountError["exists_with_different_credits_posted"] = 20] = "exists_with_different_credits_posted";
CreateAccountError[CreateAccountError["exists"] = 21] = "exists";
CreateAccountError[CreateAccountError["linked_event_chain_open"] = 2] = "linked_event_chain_open";
CreateAccountError[CreateAccountError["reserved_flag"] = 3] = "reserved_flag";
CreateAccountError[CreateAccountError["reserved_field"] = 4] = "reserved_field";
CreateAccountError[CreateAccountError["id_must_not_be_zero"] = 5] = "id_must_not_be_zero";
CreateAccountError[CreateAccountError["id_must_not_be_int_max"] = 6] = "id_must_not_be_int_max";
CreateAccountError[CreateAccountError["ledger_must_not_be_zero"] = 7] = "ledger_must_not_be_zero";
CreateAccountError[CreateAccountError["code_must_not_be_zero"] = 8] = "code_must_not_be_zero";
CreateAccountError[CreateAccountError["debits_pending_must_be_zero"] = 9] = "debits_pending_must_be_zero";
CreateAccountError[CreateAccountError["debits_posted_must_be_zero"] = 10] = "debits_posted_must_be_zero";
CreateAccountError[CreateAccountError["credits_pending_must_be_zero"] = 11] = "credits_pending_must_be_zero";
CreateAccountError[CreateAccountError["credits_posted_must_be_zero"] = 12] = "credits_posted_must_be_zero";
CreateAccountError[CreateAccountError["mutually_exclusive_flags"] = 13] = "mutually_exclusive_flags";
CreateAccountError[CreateAccountError["exists_with_different_flags"] = 14] = "exists_with_different_flags";
CreateAccountError[CreateAccountError["exists_with_different_user_data"] = 15] = "exists_with_different_user_data";
CreateAccountError[CreateAccountError["exists_with_different_ledger"] = 16] = "exists_with_different_ledger";
CreateAccountError[CreateAccountError["exists_with_different_code"] = 17] = "exists_with_different_code";
CreateAccountError[CreateAccountError["exists"] = 18] = "exists";
})(CreateAccountError = exports.CreateAccountError || (exports.CreateAccountError = {}));

@@ -46,54 +43,55 @@ var TransferFlags;

CreateTransferError[CreateTransferError["linked_event_failed"] = 1] = "linked_event_failed";
CreateTransferError[CreateTransferError["reserved_flag"] = 2] = "reserved_flag";
CreateTransferError[CreateTransferError["reserved_field"] = 3] = "reserved_field";
CreateTransferError[CreateTransferError["id_must_not_be_zero"] = 4] = "id_must_not_be_zero";
CreateTransferError[CreateTransferError["id_must_not_be_int_max"] = 5] = "id_must_not_be_int_max";
CreateTransferError[CreateTransferError["debit_account_id_must_not_be_zero"] = 6] = "debit_account_id_must_not_be_zero";
CreateTransferError[CreateTransferError["debit_account_id_must_not_be_int_max"] = 7] = "debit_account_id_must_not_be_int_max";
CreateTransferError[CreateTransferError["credit_account_id_must_not_be_zero"] = 8] = "credit_account_id_must_not_be_zero";
CreateTransferError[CreateTransferError["credit_account_id_must_not_be_int_max"] = 9] = "credit_account_id_must_not_be_int_max";
CreateTransferError[CreateTransferError["accounts_must_be_different"] = 10] = "accounts_must_be_different";
CreateTransferError[CreateTransferError["pending_id_must_be_zero"] = 11] = "pending_id_must_be_zero";
CreateTransferError[CreateTransferError["pending_transfer_must_timeout"] = 12] = "pending_transfer_must_timeout";
CreateTransferError[CreateTransferError["ledger_must_not_be_zero"] = 13] = "ledger_must_not_be_zero";
CreateTransferError[CreateTransferError["code_must_not_be_zero"] = 14] = "code_must_not_be_zero";
CreateTransferError[CreateTransferError["amount_must_not_be_zero"] = 15] = "amount_must_not_be_zero";
CreateTransferError[CreateTransferError["debit_account_not_found"] = 16] = "debit_account_not_found";
CreateTransferError[CreateTransferError["credit_account_not_found"] = 17] = "credit_account_not_found";
CreateTransferError[CreateTransferError["accounts_must_have_the_same_ledger"] = 18] = "accounts_must_have_the_same_ledger";
CreateTransferError[CreateTransferError["transfer_must_have_the_same_ledger_as_accounts"] = 19] = "transfer_must_have_the_same_ledger_as_accounts";
CreateTransferError[CreateTransferError["exists_with_different_flags"] = 20] = "exists_with_different_flags";
CreateTransferError[CreateTransferError["exists_with_different_debit_account_id"] = 21] = "exists_with_different_debit_account_id";
CreateTransferError[CreateTransferError["exists_with_different_credit_account_id"] = 22] = "exists_with_different_credit_account_id";
CreateTransferError[CreateTransferError["exists_with_different_user_data"] = 23] = "exists_with_different_user_data";
CreateTransferError[CreateTransferError["exists_with_different_pending_id"] = 24] = "exists_with_different_pending_id";
CreateTransferError[CreateTransferError["exists_with_different_timeout"] = 25] = "exists_with_different_timeout";
CreateTransferError[CreateTransferError["exists_with_different_code"] = 26] = "exists_with_different_code";
CreateTransferError[CreateTransferError["exists_with_different_amount"] = 27] = "exists_with_different_amount";
CreateTransferError[CreateTransferError["exists"] = 28] = "exists";
CreateTransferError[CreateTransferError["overflows_debits_pending"] = 29] = "overflows_debits_pending";
CreateTransferError[CreateTransferError["overflows_credits_pending"] = 30] = "overflows_credits_pending";
CreateTransferError[CreateTransferError["overflows_debits_posted"] = 31] = "overflows_debits_posted";
CreateTransferError[CreateTransferError["overflows_credits_posted"] = 32] = "overflows_credits_posted";
CreateTransferError[CreateTransferError["overflows_debits"] = 33] = "overflows_debits";
CreateTransferError[CreateTransferError["overflows_credits"] = 34] = "overflows_credits";
CreateTransferError[CreateTransferError["exceeds_credits"] = 35] = "exceeds_credits";
CreateTransferError[CreateTransferError["exceeds_debits"] = 36] = "exceeds_debits";
CreateTransferError[CreateTransferError["cannot_post_and_void_pending_transfer"] = 37] = "cannot_post_and_void_pending_transfer";
CreateTransferError[CreateTransferError["pending_transfer_cannot_post_or_void_another"] = 38] = "pending_transfer_cannot_post_or_void_another";
CreateTransferError[CreateTransferError["timeout_reserved_for_pending_transfer"] = 39] = "timeout_reserved_for_pending_transfer";
CreateTransferError[CreateTransferError["pending_id_must_not_be_zero"] = 40] = "pending_id_must_not_be_zero";
CreateTransferError[CreateTransferError["pending_id_must_not_be_int_max"] = 41] = "pending_id_must_not_be_int_max";
CreateTransferError[CreateTransferError["pending_id_must_be_different"] = 42] = "pending_id_must_be_different";
CreateTransferError[CreateTransferError["pending_transfer_not_found"] = 43] = "pending_transfer_not_found";
CreateTransferError[CreateTransferError["pending_transfer_not_pending"] = 44] = "pending_transfer_not_pending";
CreateTransferError[CreateTransferError["pending_transfer_has_different_debit_account_id"] = 45] = "pending_transfer_has_different_debit_account_id";
CreateTransferError[CreateTransferError["pending_transfer_has_different_credit_account_id"] = 46] = "pending_transfer_has_different_credit_account_id";
CreateTransferError[CreateTransferError["pending_transfer_has_different_ledger"] = 47] = "pending_transfer_has_different_ledger";
CreateTransferError[CreateTransferError["pending_transfer_has_different_code"] = 48] = "pending_transfer_has_different_code";
CreateTransferError[CreateTransferError["exceeds_pending_transfer_amount"] = 49] = "exceeds_pending_transfer_amount";
CreateTransferError[CreateTransferError["pending_transfer_has_different_amount"] = 50] = "pending_transfer_has_different_amount";
CreateTransferError[CreateTransferError["pending_transfer_already_posted"] = 51] = "pending_transfer_already_posted";
CreateTransferError[CreateTransferError["pending_transfer_already_voided"] = 52] = "pending_transfer_already_voided";
CreateTransferError[CreateTransferError["pending_transfer_expired"] = 53] = "pending_transfer_expired";
CreateTransferError[CreateTransferError["linked_event_chain_open"] = 2] = "linked_event_chain_open";
CreateTransferError[CreateTransferError["reserved_flag"] = 3] = "reserved_flag";
CreateTransferError[CreateTransferError["reserved_field"] = 4] = "reserved_field";
CreateTransferError[CreateTransferError["id_must_not_be_zero"] = 5] = "id_must_not_be_zero";
CreateTransferError[CreateTransferError["id_must_not_be_int_max"] = 6] = "id_must_not_be_int_max";
CreateTransferError[CreateTransferError["debit_account_id_must_not_be_zero"] = 7] = "debit_account_id_must_not_be_zero";
CreateTransferError[CreateTransferError["debit_account_id_must_not_be_int_max"] = 8] = "debit_account_id_must_not_be_int_max";
CreateTransferError[CreateTransferError["credit_account_id_must_not_be_zero"] = 9] = "credit_account_id_must_not_be_zero";
CreateTransferError[CreateTransferError["credit_account_id_must_not_be_int_max"] = 10] = "credit_account_id_must_not_be_int_max";
CreateTransferError[CreateTransferError["accounts_must_be_different"] = 11] = "accounts_must_be_different";
CreateTransferError[CreateTransferError["pending_id_must_be_zero"] = 12] = "pending_id_must_be_zero";
CreateTransferError[CreateTransferError["pending_transfer_must_timeout"] = 13] = "pending_transfer_must_timeout";
CreateTransferError[CreateTransferError["ledger_must_not_be_zero"] = 14] = "ledger_must_not_be_zero";
CreateTransferError[CreateTransferError["code_must_not_be_zero"] = 15] = "code_must_not_be_zero";
CreateTransferError[CreateTransferError["amount_must_not_be_zero"] = 16] = "amount_must_not_be_zero";
CreateTransferError[CreateTransferError["debit_account_not_found"] = 17] = "debit_account_not_found";
CreateTransferError[CreateTransferError["credit_account_not_found"] = 18] = "credit_account_not_found";
CreateTransferError[CreateTransferError["accounts_must_have_the_same_ledger"] = 19] = "accounts_must_have_the_same_ledger";
CreateTransferError[CreateTransferError["transfer_must_have_the_same_ledger_as_accounts"] = 20] = "transfer_must_have_the_same_ledger_as_accounts";
CreateTransferError[CreateTransferError["exists_with_different_flags"] = 21] = "exists_with_different_flags";
CreateTransferError[CreateTransferError["exists_with_different_debit_account_id"] = 22] = "exists_with_different_debit_account_id";
CreateTransferError[CreateTransferError["exists_with_different_credit_account_id"] = 23] = "exists_with_different_credit_account_id";
CreateTransferError[CreateTransferError["exists_with_different_user_data"] = 24] = "exists_with_different_user_data";
CreateTransferError[CreateTransferError["exists_with_different_pending_id"] = 25] = "exists_with_different_pending_id";
CreateTransferError[CreateTransferError["exists_with_different_timeout"] = 26] = "exists_with_different_timeout";
CreateTransferError[CreateTransferError["exists_with_different_code"] = 27] = "exists_with_different_code";
CreateTransferError[CreateTransferError["exists_with_different_amount"] = 28] = "exists_with_different_amount";
CreateTransferError[CreateTransferError["exists"] = 29] = "exists";
CreateTransferError[CreateTransferError["overflows_debits_pending"] = 30] = "overflows_debits_pending";
CreateTransferError[CreateTransferError["overflows_credits_pending"] = 31] = "overflows_credits_pending";
CreateTransferError[CreateTransferError["overflows_debits_posted"] = 32] = "overflows_debits_posted";
CreateTransferError[CreateTransferError["overflows_credits_posted"] = 33] = "overflows_credits_posted";
CreateTransferError[CreateTransferError["overflows_debits"] = 34] = "overflows_debits";
CreateTransferError[CreateTransferError["overflows_credits"] = 35] = "overflows_credits";
CreateTransferError[CreateTransferError["exceeds_credits"] = 36] = "exceeds_credits";
CreateTransferError[CreateTransferError["exceeds_debits"] = 37] = "exceeds_debits";
CreateTransferError[CreateTransferError["cannot_post_and_void_pending_transfer"] = 38] = "cannot_post_and_void_pending_transfer";
CreateTransferError[CreateTransferError["pending_transfer_cannot_post_or_void_another"] = 39] = "pending_transfer_cannot_post_or_void_another";
CreateTransferError[CreateTransferError["timeout_reserved_for_pending_transfer"] = 40] = "timeout_reserved_for_pending_transfer";
CreateTransferError[CreateTransferError["pending_id_must_not_be_zero"] = 41] = "pending_id_must_not_be_zero";
CreateTransferError[CreateTransferError["pending_id_must_not_be_int_max"] = 42] = "pending_id_must_not_be_int_max";
CreateTransferError[CreateTransferError["pending_id_must_be_different"] = 43] = "pending_id_must_be_different";
CreateTransferError[CreateTransferError["pending_transfer_not_found"] = 44] = "pending_transfer_not_found";
CreateTransferError[CreateTransferError["pending_transfer_not_pending"] = 45] = "pending_transfer_not_pending";
CreateTransferError[CreateTransferError["pending_transfer_has_different_debit_account_id"] = 46] = "pending_transfer_has_different_debit_account_id";
CreateTransferError[CreateTransferError["pending_transfer_has_different_credit_account_id"] = 47] = "pending_transfer_has_different_credit_account_id";
CreateTransferError[CreateTransferError["pending_transfer_has_different_ledger"] = 48] = "pending_transfer_has_different_ledger";
CreateTransferError[CreateTransferError["pending_transfer_has_different_code"] = 49] = "pending_transfer_has_different_code";
CreateTransferError[CreateTransferError["exceeds_pending_transfer_amount"] = 50] = "exceeds_pending_transfer_amount";
CreateTransferError[CreateTransferError["pending_transfer_has_different_amount"] = 51] = "pending_transfer_has_different_amount";
CreateTransferError[CreateTransferError["pending_transfer_already_posted"] = 52] = "pending_transfer_already_posted";
CreateTransferError[CreateTransferError["pending_transfer_already_voided"] = 53] = "pending_transfer_already_voided";
CreateTransferError[CreateTransferError["pending_transfer_expired"] = 54] = "pending_transfer_expired";
})(CreateTransferError = exports.CreateTransferError || (exports.CreateTransferError = {}));

@@ -100,0 +98,0 @@ var Operation;

{
"name": "tigerbeetle-node",
"version": "0.10.0",
"version": "0.11.0",
"description": "TigerBeetle Node.js client",

@@ -9,3 +9,3 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/coilhq/tigerbeetle-node.git"
"url": "git+https://github.com/tigerbeetledb/tigerbeetle-node.git"
},

@@ -38,4 +38,4 @@ "preferUnplugged": true,

"postinstall": "npm run install_zig && npm run download_node_headers && npm run build_lib",
"install_zig": "./src/tigerbeetle/scripts/install_zig.sh",
"download_node_headers": "./scripts/download_node_headers.sh",
"install_zig": "sh ./src/tigerbeetle/scripts/install_zig.sh",
"download_node_headers": "sh ./scripts/download_node_headers.sh",
"build": "npm run build_tsc && npm run build_lib",

@@ -47,3 +47,3 @@ "build_tsc": "./node_modules/typescript/bin/tsc",

},
"author": "Coil Technologies, Inc",
"author": "TigerBeetle, Inc",
"license": "Apache-2.0",

@@ -54,3 +54,3 @@ "contributors": [

"Jason Bruwer <jason.bruwer@coil.com>",
"Joran Dirk Greef <joran@coil.com>"
"Joran Dirk Greef <joran@tigerbeetle.com>"
],

@@ -57,0 +57,0 @@ "devDependencies": {

# tigerbeetle-node
[TigerBeetle](https://github.com/coilhq/tigerbeetle) client for Node.js.
[TigerBeetle](https://github.com/tigerbeetledb/tigerbeetle) client for Node.js.

@@ -12,2 +12,12 @@ ## Installation

If you run into issues, check out the distribution-specific install
steps that are run in CI to test support:
* [Alpine](./scripts/test_install_on_alpine.sh)
* [Amazon Linux](./scripts/test_install_on_amazonlinux.sh)
* [Debian](./scripts/test_install_on_debian.sh)
* [Fedora](./scripts/test_install_on_fedora.sh)
* [Ubuntu](./scripts/test_install_on_ubuntu.sh)
* [RHEL](./scripts/test_install_on_rhelubi.sh)
### Prerequisites

@@ -28,3 +38,9 @@

```js
import { createClient } from 'tigerbeetle-node'
const {
createClient,
CreateAccountError,
CreateTransferError,
AccountFlags,
TransferFlags,
} = require('tigerbeetle-node');

@@ -34,132 +50,268 @@ const client = createClient({

replica_addresses: ['3001', '3002', '3003']
})
});
```
One of the ways TigerBeetle achieves its performance is through batching.
This is reflected in the below function interfaces where each one takes in an array of events.
One of the ways TigerBeetle achieves its performance is through
batching. This is reflected in the below function interfaces where
each one takes in an array of items.
### Account Creation
### Sidenote: `BigInt`
TigerBeetle uses 64-bit integers for many fields while JavaScript's
builtin `Number` maximum value is 2^53-1. The `n` suffix in JavaScript
means the value is a BigInt. This is useful for literal numbers. If
you already have a `Number` variable though, you can call the `BigInt`
constructor to get a `BigInt` from it. For example, `1n` is the same
as `BigInt(1)`.
## Creating Accounts: `client.createAccounts`
See details for account fields in the [Accounts
reference](https://docs.tigerbeetle.com/reference/accounts).
```js
const account = {
id: 137n, // u128
user_data: 0n, // u128, opaque third-party identifier to link this account to an external entity:
reserved: Buffer.alloc(48, 0), // [48]u8
ledger: 1, // u32, ledger value
code: 718, // u16, a chart of accounts code describing the type of account (e.g. clearing, settlement)
flags: 0, // u16
debits_pending: 0n, // u64
debits_posted: 0n, // u64
credits_pending: 0n, // u64
credits_posted: 0n, // u64
timestamp: 0n, // u64, Reserved: This will be set by the server.
id: 137n, // u128
user_data: 0n, // u128, opaque third-party identifier to link this account to an external entity:
reserved: Buffer.alloc(48, 0), // [48]u8
ledger: 1, // u32, ledger value
code: 718, // u16, a chart of accounts code describing the type of account (e.g. clearing, settlement)
flags: 0, // u16
debits_pending: 0n, // u64
debits_posted: 0n, // u64
credits_pending: 0n, // u64
credits_posted: 0n, // u64
timestamp: 0n, // u64, Reserved: This will be set by the server.
};
const errors = await client.createAccounts([account]);
if (errors.length) {
// Grab a human-readable message from the response
console.log(CreateAccountError[errors[0].code]);
}
```
const errors = await client.createAccounts([account])
### Account Flags
The account `flags` value is a bitfield. See details for these flags in
the [Accounts
reference](https://docs.tigerbeetle.com/reference/accounts#flags).
To toggle behavior for an account, combine enum values stored in the
`AccountFlags` object (in TypeScript it is an actual enum) with
bitwise-or:
* `AccountFlags.linked`
* `AccountFlags.debits_must_not_exceed_credits`
* `AccountFlags.credits_must_not_exceed_credits`
For example, to link `account0` and `account1`, where `account0`
additionally has the `debits_must_not_exceed_credits` constraint:
```js
const account0 = { ... account values ... };
const account1 = { ... account values ... };
account0.flags = AccountFlags.linked | AccountFlags.debits_must_not_exceed_credits;
// Create the account
const errors = client.createAccounts([account0, account1]);
```
Successfully executed events return an empty array whilst unsuccessful ones return an array with errors for **only the ones that failed**. An error will point to the index in the submitted array of the failed event.
### Response and Errors
The response is an empty array if all accounts were created
successfully. If the response is non-empty, each object in the
response array contains error information for an account that
failed. The error object contains an error code and the index of the
account in the request batch.
```js
const errors = await client.createAccounts([account1, account2, account3])
const errors = await client.createAccounts([account1, account2, account3]);
// errors = [{ index: 1, code: 1 }]
const error = errors[0]
// errors = [{ index: 1, code: 1 }];
for (const error of errors) {
switch (error.code) {
case CreateAccountError.exists: {
console.error(`Batch event at ${error.index} already exists.`)
}
case CreateAccountError.exists:
console.error(`Batch account at ${error.index} already exists.`);
break;
default:
console.error(`Batch account at ${error.index} failed to create: ${CreateAccountError[error.code]}.`);
}
}
```
The example above shows that the event in index 1 failed with error 1. This means that `account1` and `account3` were created successfully but not `account2`.
The `flags` on an account provide a way for you to enforce policies by toggling the bits below.
| bit 0 | bit 1 | bit 2 |
|----------|----------------------------------|-----------------------------------------|
| `linked` | `debits_must_not_exceed_credits` | `credits_must_not_exceed_debits` |
The example above shows that the account in index 1 failed with
error 1. This error here means that `account1` and `account3` were
created successfully. But `account2` was not created.
The creation of an account can be linked to the successful creation of another by setting the `linked` flag (see [linked events](#linked-events)). By setting `debits_must_not_exceed_credits`, then any transfer such that `debits_posted + debits_pending + amount > credits_posted` will fail. Similarly for `credits_must_not_exceed_debits`.
```js
enum CreateAccountFlags {
linked = (1 << 0),
debits_must_not_exceed_credits = (1 << 1),
credits_must_not_exceed_debits = (1 << 2)
}
To handle errors you can either 1) exactly match error codes returned
from `client.createAccounts` with enum values in the
`CreateAccountError` object, or you can 2) look up the error code in
the `CreateAccountError` object for a human-readable string.
let flags = 0
flags |= CreateAccountFlags.debits_must_not_exceed_credits
```
## Account Lookup: `client.lookupAccounts`
### Account Lookup
Account lookup is batched, like account creation. Pass in all `id`s to
fetch, and matched accounts are returned.
The `id` of the account is used for lookups. Only matched accounts are returned.
If no account matches an `id`, no object is returned for that
account. So the order of accounts in the response is not necessarily
the same as the order of `id`s in the request. You can refer to the
`id` field in the response to distinguish accounts.
```js
// account 137n exists, 138n does not
const accounts = await client.lookupAccounts([137n, 138n])
/**
* const accounts = [{
* id: 137n,
* user_data: 0n,
* reserved: Buffer,
* ledger: 1,
* code: 718,
* flags: 0,
* debits_pending: 0n,
* debits_posted: 0n,
* credits_pending: 0n,
* credits_posted: 0n,
* timestamp: 1623062009212508993n,
* }]
*/
// account 137n exists, 138n does not
const accounts = await client.lookupAccounts([137n, 138n]);
/* console.log(accounts);
* [{
* id: 137n,
* user_data: 0n,
* reserved: Buffer,
* ledger: 1,
* code: 718,
* flags: 0,
* debits_pending: 0n,
* debits_posted: 0n,
* credits_pending: 0n,
* credits_posted: 0n,
* timestamp: 1623062009212508993n,
* }]
*/
```
### Creating a Transfer
## Creating Transfers: `client.createTransfers`
This creates a journal entry between two accounts.
See details for transfer fields in the [Transfers
reference](https://docs.tigerbeetle.com/reference/transfers).
```js
const transfer = {
id: 1n, // u128
// Double-entry accounting:
debit_account_id: 1n, // u128
credit_account_id: 2n, // u128
// Opaque third-party identifier to link this transfer to an external entity:
user_data: 0n, // u128
reserved: 0n, // u128
// Timeout applicable for a pending/2-phase transfer:
timeout: 0n, // u64, in nano-seconds.
// Collection of accounts usually grouped by the currency:
// You can't transfer money between accounts with different ledgers:
ledger: 720, // u32, ledger for transfer (e.g. currency).
// Chart of accounts code describing the reason for the transfer:
code: 1, // u16, (e.g. deposit, settlement)
flags: 0, // u16
amount: 10n, // u64
timestamp: 0n, //u64, Reserved: This will be set by the server.
id: 1n, // u128
pending_id: 0n, // u128
// Double-entry accounting:
debit_account_id: 1n, // u128
credit_account_id: 2n, // u128
// Opaque third-party identifier to link this transfer to an external entity:
user_data: 0n, // u128
reserved: 0n, // u128
// Timeout applicable for a pending/2-phase transfer:
timeout: 0n, // u64, in nano-seconds.
// Collection of accounts usually grouped by the currency:
// You can't transfer money between accounts with different ledgers:
ledger: 1, // u32, ledger for transfer (e.g. currency).
// Chart of accounts code describing the reason for the transfer:
code: 720, // u16, (e.g. deposit, settlement)
flags: 0, // u16
amount: 10n, // u64
timestamp: 0n, //u64, Reserved: This will be set by the server.
};
const errors = await client.createTransfers([transfer]);
for (const error of errors) {
switch (error.code) {
default:
console.error(`Batch transfer at ${error.index} failed to create: ${CreateAccountError[error.code]}.`);
}
}
const errors = await client.createTransfers([transfer])
```
Two-phase transfers are supported natively by toggling the appropriate flag. TigerBeetle will then adjust the `credits_pending` and `debits_pending` fields of the appropriate accounts. A corresponding commit transfer then needs to be sent to accept or reject the transfer.
Transfers within a batch may also be linked (see [linked events](#linked-events)).
### Response and Errors
The response is an empty array if all transfers were created
successfully. If the response is non-empty, each object in the
response array contains error information for an transfer that
failed. The error object contains an error code and the index of the
transfer in the request batch.
```js
enum TransferFlags {
linked = (1 << 0),
pending = (1 << 1),
post_pending_transfer = (1 << 2),
void_pending_transfer = (1 << 3)
const errors = await client.createTransfers([transfer1, transfer2, transfer3]);
// errors = [{ index: 1, code: 1 }];
for (const error of errors) {
switch (error.code) {
case CreateTransferError.exists:
console.error(`Batch transfer at ${error.index} already exists.`);
break;
default:
console.error(`Batch transfer at ${error.index} failed to create: ${CreateTransferError[error.code]}.`);
}
// Two-phase transfer (pending):
let flags = 0n
flags |= TransferFlags.pending
}
```
// Linked two-phase transfer (pending):
let flags = 0n
flags |= TransferFlags.linked
flags |= TransferFlags.pending
The example above shows that the transfer in index 1 failed with
error 1. This error here means that `transfer1` and `transfer3` were
created successfully. But `transfer2` was not created.
To handle errors you can either 1) exactly match error codes returned
from `client.createTransfers` with enum values in the
`CreateTransferError` object, or you can 2) look up the error code in
the `CreateTransferError` object for a human-readable string.
### Batching
TigerBeetle performance is maximized when you batch inserts. The
client does not do this automatically for you. So, for example, you
can insert 1 million transfers one at a time like so:
```js
for (let i = 0; i < 1_000_000; i++) {
const errors = client.createTransfers(transfers[i]);
// error handling omitted
}
```
### Post a Pending Transfer (2-Phase)
But the insert rate will be a fraction of potential. Instead, always
batch what you can. The maximum batch size is set in the TigerBeetle
server. The default is 8191.
With `flags = post_pending_transfer`, TigerBeetle will accept the transfer. TigerBeetle will atomically rollback the changes to `debits_pending` and `credits_pending` of the appropriate accounts and apply them to the `debits_posted` and `credits_posted` balances.
```js
const BATCH_SIZE = 8191;
for (let i = 0; i < 1_000_000; i += BATCH_SIZE) {
const errors = client.createTransfers(transfers.slice(i, Math.min(transfers.length, BATCH_SIZE)));
// error handling omitted
}
```
### Transfer Flags
The transfer `flags` value is a bitfield. See details for these flags in
the [Transfers
reference](https://docs.tigerbeetle.com/reference/transfers#flags).
To toggle behavior for a transfer, combine enum values stored in the
`TransferFlags` object (in TypeScript it is an actual enum) with
bitwise-or:
* `TransferFlags.linked`
* `TransferFlags.pending`
* `TransferFlags.post_pending_transfer`
* `TransferFlags.void_pending_transfer`
For example, to link `transfer0` and `transfer1`:
```js
const transfer0 = { ... transfer values ... };
const transfer1 = { ... transfer values ... };
transfer0.flags = TransferFlags.linked;
// Create the transfer
const errors = client.createTransfers([transfer0, transfer1]);
```
#### Two-Phase Transfers
Two-phase transfers are supported natively by toggling the appropriate
flag. TigerBeetle will then adjust the `credits_pending` and
`debits_pending` fields of the appropriate accounts. A corresponding
post pending transfer then needs to be sent to post or void the
transfer.
##### Post a Pending Transfer
With `transfer.flags == TransferFlags.post_pending_transfer`,
TigerBeetle will post the transfer. TigerBeetle will atomically roll
back the changes to `debits_pending` and `credits_pending` of the
appropriate accounts and apply them to the `debits_posted` and
`credits_posted` balances.
```js
const post = {

@@ -174,7 +326,56 @@ id: 2n, // u128, must correspond to the transfer id

### Linked Events
## Transfer Lookup: `client.lookupTransfers`
When the `linked` flag is specified for the `createAccount`, `createTransfer`, `commitTransfer` event, it links an event with the next event in the batch, to create a chain of events, of arbitrary length, which all succeed or fail together. The tail of a chain is denoted by the first event without this flag. The last event in a batch may therefore never have the `linked` flag set as this would leave a chain open-ended. Multiple chains or individual events may coexist within a batch to succeed or fail independently. Events within a chain are executed within order, or are rolled back on error, so that the effect of each event in the chain is visible to the next, and so that the chain is either visible or invisible as a unit to subsequent events after the chain. The event that was the first to break the chain will have a unique error result. Other events in the chain will have their error result set to `linked_event_failed`.
NOTE: While transfer lookup exists, it is not a flexible query API. We
are developing query APIs and there will be new methods for querying
transfers in the future.
Transfer lookup is batched, like transfer creation. Pass in all `id`s to
fetch, and matched transfers are returned.
If no transfer matches an `id`, no object is returned for that
transfer. So the order of transfers in the response is not necessarily
the same as the order of `id`s in the request. You can refer to the
`id` field in the response to distinguish transfers.
```js
// transfer 1n exists, 2n does not
const transfers = await client.lookupTransfers([1n, 2n]);
/* console.log(transfers);
* [{
* id: 1n,
* pending_id: 0n,
* debit_account_id: 1n,
* credit_account_id: 2n,
* user_data: 0n,
* reserved: 0n,
* timeout: 0n,
* ledger: 1,
* code: 720,
* flags: 0,
* amount: 10n,
* timestamp: 1623062009212508993n,
* }]
*/
```
## Linked Events
When the `linked` flag is specified for the `createAccount` or
`createTransfer` event, it links an event with the next event in the
batch, to create a chain of events, of arbitrary length, which all
succeed or fail together. The tail of a chain is denoted by the first
event without this flag. The last event in a batch may therefore never
have the `linked` flag set as this would leave a chain
open-ended. Multiple chains or individual events may coexist within a
batch to succeed or fail independently.
Events within a chain are executed within order, or are rolled back on
error, so that the effect of each event in the chain is visible to the
next, and so that the chain is either visible or invisible as a unit
to subsequent events after the chain. The event that was the first to
break the chain will have a unique error result. Other events in the
chain will have their error result set to `linked_event_failed`.
```js
let batch = []

@@ -225,3 +426,3 @@ let linkedFlag = 0

```shell
git clone --recurse-submodules https://github.com/coilhq/tigerbeetle-node.git
git clone --recurse-submodules https://github.com/tigerbeetledb/tigerbeetle-node.git
cd tigerbeetle-node/

@@ -228,0 +429,0 @@ npm install --include dev # This will automatically install and build everything you need.

@@ -46,2 +46,3 @@ const binding: Binding = require('./client.node')

linked_event_failed = 1,
linked_event_chain_open,

@@ -55,11 +56,9 @@ reserved_flag,

code_must_not_be_zero,
debits_pending_must_be_zero,
debits_posted_must_be_zero,
credits_pending_must_be_zero,
credits_posted_must_be_zero,
mutually_exclusive_flags,
overflows_debits,
overflows_credits,
exceeds_credits,
exceeds_debits,
exists_with_different_flags,

@@ -69,6 +68,2 @@ exists_with_different_user_data,

exists_with_different_code,
exists_with_different_debits_pending,
exists_with_different_debits_posted,
exists_with_different_credits_pending,
exists_with_different_credits_posted,
exists,

@@ -107,2 +102,3 @@ }

linked_event_failed = 1,
linked_event_chain_open,

@@ -109,0 +105,0 @@ reserved_flag,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc