@meshtrade/api-node 1.30.0
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 +93 -0
- package/dist/buf/validate/validate_pb.d.ts +4597 -0
- package/dist/buf/validate/validate_pb.js +354 -0
- package/dist/google/type/date_pb.d.ts +52 -0
- package/dist/google/type/date_pb.js +26 -0
- package/dist/meshtrade/common/config.d.ts +50 -0
- package/dist/meshtrade/common/config.js +34 -0
- package/dist/meshtrade/common/connectInterceptors.d.ts +137 -0
- package/dist/meshtrade/common/connectInterceptors.js +233 -0
- package/dist/meshtrade/common/validation.d.ts +62 -0
- package/dist/meshtrade/common/validation.js +77 -0
- package/dist/meshtrade/compliance/client/v1/client_pb.d.ts +138 -0
- package/dist/meshtrade/compliance/client/v1/client_pb.js +23 -0
- package/dist/meshtrade/compliance/client/v1/company_pb.d.ts +313 -0
- package/dist/meshtrade/compliance/client/v1/company_pb.js +100 -0
- package/dist/meshtrade/compliance/client/v1/company_representative_pb.d.ts +81 -0
- package/dist/meshtrade/compliance/client/v1/company_representative_pb.js +22 -0
- package/dist/meshtrade/compliance/client/v1/company_representative_role_pb.d.ts +88 -0
- package/dist/meshtrade/compliance/client/v1/company_representative_role_pb.js +95 -0
- package/dist/meshtrade/compliance/client/v1/fund_pb.d.ts +65 -0
- package/dist/meshtrade/compliance/client/v1/fund_pb.js +18 -0
- package/dist/meshtrade/compliance/client/v1/identification_document_type_pb.d.ts +55 -0
- package/dist/meshtrade/compliance/client/v1/identification_document_type_pb.js +62 -0
- package/dist/meshtrade/compliance/client/v1/index.d.ts +16 -0
- package/dist/meshtrade/compliance/client/v1/index.js +59 -0
- package/dist/meshtrade/compliance/client/v1/industry_classification_pb.d.ts +86 -0
- package/dist/meshtrade/compliance/client/v1/industry_classification_pb.js +16 -0
- package/dist/meshtrade/compliance/client/v1/natural_person_connection_type_pb.d.ts +133 -0
- package/dist/meshtrade/compliance/client/v1/natural_person_connection_type_pb.js +140 -0
- package/dist/meshtrade/compliance/client/v1/natural_person_pb.d.ts +143 -0
- package/dist/meshtrade/compliance/client/v1/natural_person_pb.js +24 -0
- package/dist/meshtrade/compliance/client/v1/pep_status_pb.d.ts +46 -0
- package/dist/meshtrade/compliance/client/v1/pep_status_pb.js +53 -0
- package/dist/meshtrade/compliance/client/v1/service_node_meshts.d.ts +78 -0
- package/dist/meshtrade/compliance/client/v1/service_node_meshts.js +141 -0
- package/dist/meshtrade/compliance/client/v1/service_pb.d.ts +123 -0
- package/dist/meshtrade/compliance/client/v1/service_pb.js +45 -0
- package/dist/meshtrade/compliance/client/v1/source_of_income_and_wealth_pb.d.ts +180 -0
- package/dist/meshtrade/compliance/client/v1/source_of_income_and_wealth_pb.js +187 -0
- package/dist/meshtrade/compliance/client/v1/tax_residency_pb.d.ts +40 -0
- package/dist/meshtrade/compliance/client/v1/tax_residency_pb.js +17 -0
- package/dist/meshtrade/compliance/client/v1/trust_pb.d.ts +65 -0
- package/dist/meshtrade/compliance/client/v1/trust_pb.js +18 -0
- package/dist/meshtrade/compliance/client/v1/verification_status_pb.d.ts +57 -0
- package/dist/meshtrade/compliance/client/v1/verification_status_pb.js +64 -0
- package/dist/meshtrade/iam/api_user/v1/api_credentials_pb.d.ts +43 -0
- package/dist/meshtrade/iam/api_user/v1/api_credentials_pb.js +17 -0
- package/dist/meshtrade/iam/api_user/v1/api_user_pb.d.ts +152 -0
- package/dist/meshtrade/iam/api_user/v1/api_user_pb.js +95 -0
- package/dist/meshtrade/iam/api_user/v1/index.d.ts +4 -0
- package/dist/meshtrade/iam/api_user/v1/index.js +45 -0
- package/dist/meshtrade/iam/api_user/v1/service_node_meshts.d.ts +114 -0
- package/dist/meshtrade/iam/api_user/v1/service_node_meshts.js +201 -0
- package/dist/meshtrade/iam/api_user/v1/service_pb.d.ts +343 -0
- package/dist/meshtrade/iam/api_user/v1/service_pb.js +86 -0
- package/dist/meshtrade/iam/group/v1/group_pb.d.ts +58 -0
- package/dist/meshtrade/iam/group/v1/group_pb.js +17 -0
- package/dist/meshtrade/iam/group/v1/index.d.ts +3 -0
- package/dist/meshtrade/iam/group/v1/index.js +44 -0
- package/dist/meshtrade/iam/group/v1/service_node_meshts.d.ts +90 -0
- package/dist/meshtrade/iam/group/v1/service_node_meshts.js +161 -0
- package/dist/meshtrade/iam/group/v1/service_pb.d.ts +306 -0
- package/dist/meshtrade/iam/group/v1/service_pb.js +75 -0
- package/dist/meshtrade/iam/role/v1/index.d.ts +2 -0
- package/dist/meshtrade/iam/role/v1/index.js +43 -0
- package/dist/meshtrade/iam/role/v1/role.d.ts +71 -0
- package/dist/meshtrade/iam/role/v1/role.js +192 -0
- package/dist/meshtrade/iam/role/v1/role_pb.d.ts +164 -0
- package/dist/meshtrade/iam/role/v1/role_pb.js +171 -0
- package/dist/meshtrade/iam/user/v1/index.d.ts +3 -0
- package/dist/meshtrade/iam/user/v1/index.js +44 -0
- package/dist/meshtrade/iam/user/v1/service_node_meshts.d.ts +108 -0
- package/dist/meshtrade/iam/user/v1/service_node_meshts.js +191 -0
- package/dist/meshtrade/iam/user/v1/service_pb.d.ts +379 -0
- package/dist/meshtrade/iam/user/v1/service_pb.js +90 -0
- package/dist/meshtrade/iam/user/v1/user_pb.d.ts +58 -0
- package/dist/meshtrade/iam/user/v1/user_pb.js +17 -0
- package/dist/meshtrade/ledger/transaction/v1/index.d.ts +5 -0
- package/dist/meshtrade/ledger/transaction/v1/index.js +46 -0
- package/dist/meshtrade/ledger/transaction/v1/service_node_meshts.d.ts +80 -0
- package/dist/meshtrade/ledger/transaction/v1/service_node_meshts.js +140 -0
- package/dist/meshtrade/ledger/transaction/v1/service_pb.d.ts +102 -0
- package/dist/meshtrade/ledger/transaction/v1/service_pb.js +41 -0
- package/dist/meshtrade/ledger/transaction/v1/transaction_action_pb.d.ts +46 -0
- package/dist/meshtrade/ledger/transaction/v1/transaction_action_pb.js +53 -0
- package/dist/meshtrade/ledger/transaction/v1/transaction_state.d.ts +14 -0
- package/dist/meshtrade/ledger/transaction/v1/transaction_state.js +64 -0
- package/dist/meshtrade/ledger/transaction/v1/transaction_state_pb.d.ts +50 -0
- package/dist/meshtrade/ledger/transaction/v1/transaction_state_pb.js +57 -0
- package/dist/meshtrade/market_data/price/v1/index.d.ts +3 -0
- package/dist/meshtrade/market_data/price/v1/index.js +44 -0
- package/dist/meshtrade/market_data/price/v1/price_pb.d.ts +50 -0
- package/dist/meshtrade/market_data/price/v1/price_pb.js +19 -0
- package/dist/meshtrade/market_data/price/v1/service_node_meshts.d.ts +66 -0
- package/dist/meshtrade/market_data/price/v1/service_node_meshts.js +121 -0
- package/dist/meshtrade/market_data/price/v1/service_pb.d.ts +48 -0
- package/dist/meshtrade/market_data/price/v1/service_pb.js +27 -0
- package/dist/meshtrade/option/method_options/v1/index.d.ts +1 -0
- package/dist/meshtrade/option/method_options/v1/index.js +42 -0
- package/dist/meshtrade/option/method_options/v1/method_options_pb.d.ts +132 -0
- package/dist/meshtrade/option/method_options/v1/method_options_pb.js +108 -0
- package/dist/meshtrade/reporting/account_report/v1/account_report_pb.d.ts +136 -0
- package/dist/meshtrade/reporting/account_report/v1/account_report_pb.js +28 -0
- package/dist/meshtrade/reporting/account_report/v1/disclaimer_pb.d.ts +39 -0
- package/dist/meshtrade/reporting/account_report/v1/disclaimer_pb.js +16 -0
- package/dist/meshtrade/reporting/account_report/v1/fee_entry_pb.d.ts +66 -0
- package/dist/meshtrade/reporting/account_report/v1/fee_entry_pb.js +18 -0
- package/dist/meshtrade/reporting/account_report/v1/income_entry_pb.d.ts +139 -0
- package/dist/meshtrade/reporting/account_report/v1/income_entry_pb.js +80 -0
- package/dist/meshtrade/reporting/account_report/v1/index.d.ts +7 -0
- package/dist/meshtrade/reporting/account_report/v1/index.js +48 -0
- package/dist/meshtrade/reporting/account_report/v1/service_node_meshts.d.ts +72 -0
- package/dist/meshtrade/reporting/account_report/v1/service_node_meshts.js +131 -0
- package/dist/meshtrade/reporting/account_report/v1/service_pb.d.ts +162 -0
- package/dist/meshtrade/reporting/account_report/v1/service_pb.js +46 -0
- package/dist/meshtrade/reporting/account_report/v1/trading_statement_entry_pb.d.ts +80 -0
- package/dist/meshtrade/reporting/account_report/v1/trading_statement_entry_pb.js +18 -0
- package/dist/meshtrade/studio/instrument/v1/index.d.ts +3 -0
- package/dist/meshtrade/studio/instrument/v1/index.js +44 -0
- package/dist/meshtrade/studio/instrument/v1/instrument_pb.d.ts +53 -0
- package/dist/meshtrade/studio/instrument/v1/instrument_pb.js +18 -0
- package/dist/meshtrade/studio/instrument/v1/instrument_type_pb.d.ts +214 -0
- package/dist/meshtrade/studio/instrument/v1/instrument_type_pb.js +221 -0
- package/dist/meshtrade/studio/instrument/v1/unit_pb.d.ts +148 -0
- package/dist/meshtrade/studio/instrument/v1/unit_pb.js +155 -0
- package/dist/meshtrade/trading/limit_order/v1/index.d.ts +3 -0
- package/dist/meshtrade/trading/limit_order/v1/index.js +44 -0
- package/dist/meshtrade/trading/limit_order/v1/limit_order_pb.d.ts +211 -0
- package/dist/meshtrade/trading/limit_order/v1/limit_order_pb.js +111 -0
- package/dist/meshtrade/trading/limit_order/v1/service_node_meshts.d.ts +111 -0
- package/dist/meshtrade/trading/limit_order/v1/service_node_meshts.js +190 -0
- package/dist/meshtrade/trading/limit_order/v1/service_pb.d.ts +357 -0
- package/dist/meshtrade/trading/limit_order/v1/service_pb.js +73 -0
- package/dist/meshtrade/trading/market_order/v1/index.d.ts +3 -0
- package/dist/meshtrade/trading/market_order/v1/index.js +44 -0
- package/dist/meshtrade/trading/market_order/v1/market_order_pb.d.ts +20 -0
- package/dist/meshtrade/trading/market_order/v1/market_order_pb.js +16 -0
- package/dist/meshtrade/trading/market_order/v1/service_node_meshts.d.ts +66 -0
- package/dist/meshtrade/trading/market_order/v1/service_node_meshts.js +121 -0
- package/dist/meshtrade/trading/market_order/v1/service_pb.d.ts +34 -0
- package/dist/meshtrade/trading/market_order/v1/service_pb.js +22 -0
- package/dist/meshtrade/type/v1/address_pb.d.ts +82 -0
- package/dist/meshtrade/type/v1/address_pb.js +16 -0
- package/dist/meshtrade/type/v1/amount.d.ts +13 -0
- package/dist/meshtrade/type/v1/amount.js +68 -0
- package/dist/meshtrade/type/v1/amountWrapper.d.ts +74 -0
- package/dist/meshtrade/type/v1/amountWrapper.js +98 -0
- package/dist/meshtrade/type/v1/amount_pb.d.ts +44 -0
- package/dist/meshtrade/type/v1/amount_pb.js +18 -0
- package/dist/meshtrade/type/v1/contact_details_pb.d.ts +98 -0
- package/dist/meshtrade/type/v1/contact_details_pb.js +16 -0
- package/dist/meshtrade/type/v1/date.d.ts +49 -0
- package/dist/meshtrade/type/v1/date.js +136 -0
- package/dist/meshtrade/type/v1/date_pb.d.ts +50 -0
- package/dist/meshtrade/type/v1/date_pb.js +16 -0
- package/dist/meshtrade/type/v1/decimalConversions.d.ts +24 -0
- package/dist/meshtrade/type/v1/decimalConversions.js +39 -0
- package/dist/meshtrade/type/v1/decimal_pb.d.ts +24 -0
- package/dist/meshtrade/type/v1/decimal_pb.js +16 -0
- package/dist/meshtrade/type/v1/index.d.ts +15 -0
- package/dist/meshtrade/type/v1/index.js +56 -0
- package/dist/meshtrade/type/v1/ledger.d.ts +27 -0
- package/dist/meshtrade/type/v1/ledger.js +115 -0
- package/dist/meshtrade/type/v1/ledger_pb.d.ts +83 -0
- package/dist/meshtrade/type/v1/ledger_pb.js +90 -0
- package/dist/meshtrade/type/v1/sorting_pb.d.ts +35 -0
- package/dist/meshtrade/type/v1/sorting_pb.js +42 -0
- package/dist/meshtrade/type/v1/time_of_day.d.ts +74 -0
- package/dist/meshtrade/type/v1/time_of_day.js +199 -0
- package/dist/meshtrade/type/v1/time_of_day_pb.d.ts +67 -0
- package/dist/meshtrade/type/v1/time_of_day_pb.js +16 -0
- package/dist/meshtrade/type/v1/token.d.ts +4 -0
- package/dist/meshtrade/type/v1/token.js +23 -0
- package/dist/meshtrade/type/v1/tokenWrapper.d.ts +49 -0
- package/dist/meshtrade/type/v1/tokenWrapper.js +92 -0
- package/dist/meshtrade/type/v1/token_pb.d.ts +56 -0
- package/dist/meshtrade/type/v1/token_pb.js +17 -0
- package/dist/meshtrade/wallet/account/v1/account_pb.d.ts +264 -0
- package/dist/meshtrade/wallet/account/v1/account_pb.js +74 -0
- package/dist/meshtrade/wallet/account/v1/index.d.ts +3 -0
- package/dist/meshtrade/wallet/account/v1/index.js +44 -0
- package/dist/meshtrade/wallet/account/v1/service_node_meshts.d.ts +114 -0
- package/dist/meshtrade/wallet/account/v1/service_node_meshts.js +201 -0
- package/dist/meshtrade/wallet/account/v1/service_pb.d.ts +559 -0
- package/dist/meshtrade/wallet/account/v1/service_pb.js +112 -0
- package/package.json +171 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allLedgers = void 0;
|
|
4
|
+
exports.ledgerToString = ledgerToString;
|
|
5
|
+
exports.stringToLedger = stringToLedger;
|
|
6
|
+
exports.getLedgerNoDecimalPlaces = getLedgerNoDecimalPlaces;
|
|
7
|
+
exports.ledgerToBEString = ledgerToBEString;
|
|
8
|
+
const ledger_pb_1 = require("./ledger_pb");
|
|
9
|
+
// Get all Ledgers as enum values
|
|
10
|
+
exports.allLedgers = Object.values(ledger_pb_1.Ledger).filter((value) => typeof value === "number");
|
|
11
|
+
// Define explicit mappings between Ledger enums and custom string representations
|
|
12
|
+
const ledgerToStringMapping = {
|
|
13
|
+
[ledger_pb_1.Ledger.UNSPECIFIED]: "-",
|
|
14
|
+
[ledger_pb_1.Ledger.STELLAR]: "Stellar",
|
|
15
|
+
[ledger_pb_1.Ledger.BITCOIN]: "Bitcoin",
|
|
16
|
+
[ledger_pb_1.Ledger.LITECOIN]: "Litecoin",
|
|
17
|
+
[ledger_pb_1.Ledger.ETHEREUM]: "Ethereum",
|
|
18
|
+
[ledger_pb_1.Ledger.XRP]: "Ripple",
|
|
19
|
+
[ledger_pb_1.Ledger.SA_STOCK_BROKERS]: "SA Stock Brokers",
|
|
20
|
+
[ledger_pb_1.Ledger.NULL]: "NULL",
|
|
21
|
+
};
|
|
22
|
+
// Reverse mapping from string to Ledger enum
|
|
23
|
+
const stringToLedgerMapping = {};
|
|
24
|
+
for (const [key, value] of Object.entries(ledgerToStringMapping)) {
|
|
25
|
+
stringToLedgerMapping[value] = Number(key);
|
|
26
|
+
}
|
|
27
|
+
class UnsupportedLedgerError extends Error {
|
|
28
|
+
constructor(Ledger) {
|
|
29
|
+
const message = `Unsupported Ledger: ${Ledger}`;
|
|
30
|
+
super(message);
|
|
31
|
+
this.Ledger = Ledger;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts a Ledger enum instance to a custom string representation.
|
|
36
|
+
* @param {Ledger} Ledger - The Ledger to convert.
|
|
37
|
+
* @returns {string} The custom string representation of the Ledger.
|
|
38
|
+
*/
|
|
39
|
+
function ledgerToString(Ledger) {
|
|
40
|
+
if (Ledger in ledgerToStringMapping) {
|
|
41
|
+
return ledgerToStringMapping[Ledger];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new UnsupportedLedgerError(Ledger);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class UnsupportedLedgerStringError extends Error {
|
|
48
|
+
constructor(LedgerStr) {
|
|
49
|
+
const message = `Unsupported Ledger string: ${LedgerStr}`;
|
|
50
|
+
super(message);
|
|
51
|
+
this.LedgerStr = LedgerStr;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Converts a custom string representation to a Ledger enum instance.
|
|
56
|
+
* @param {string} LedgerStr - The custom string representation of the Ledger.
|
|
57
|
+
* @returns {Ledger} The corresponding Ledger enum instance.
|
|
58
|
+
*/
|
|
59
|
+
function stringToLedger(LedgerStr) {
|
|
60
|
+
if (LedgerStr in stringToLedgerMapping) {
|
|
61
|
+
return stringToLedgerMapping[LedgerStr];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new UnsupportedLedgerStringError(LedgerStr);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Define a mapping from Ledger to the number of decimal places
|
|
68
|
+
const ledgerDecimalPlaces = {
|
|
69
|
+
[ledger_pb_1.Ledger.UNSPECIFIED]: 2,
|
|
70
|
+
[ledger_pb_1.Ledger.STELLAR]: 7,
|
|
71
|
+
[ledger_pb_1.Ledger.BITCOIN]: 8,
|
|
72
|
+
[ledger_pb_1.Ledger.LITECOIN]: 7,
|
|
73
|
+
[ledger_pb_1.Ledger.ETHEREUM]: 7,
|
|
74
|
+
[ledger_pb_1.Ledger.XRP]: 7,
|
|
75
|
+
[ledger_pb_1.Ledger.SA_STOCK_BROKERS]: 2,
|
|
76
|
+
[ledger_pb_1.Ledger.NULL]: 2,
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new Amount object using a BigNumber and a Token.
|
|
80
|
+
*
|
|
81
|
+
* @param {Ledger} ledger - The ledger for which to get decimal places.
|
|
82
|
+
* @returns {number} Returns the number of decimal places supported on ledger.
|
|
83
|
+
*/
|
|
84
|
+
function getLedgerNoDecimalPlaces(ledger) {
|
|
85
|
+
if (ledger in ledgerDecimalPlaces) {
|
|
86
|
+
return ledgerDecimalPlaces[ledger];
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new UnsupportedLedgerError(ledger);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Define explicit mappings between Ledger enums backend string representations
|
|
93
|
+
const ledgerToBEStringMapping = {
|
|
94
|
+
[ledger_pb_1.Ledger.UNSPECIFIED]: "LEDGER_UNSPECIFIED",
|
|
95
|
+
[ledger_pb_1.Ledger.STELLAR]: "LEDGER_STELLAR",
|
|
96
|
+
[ledger_pb_1.Ledger.BITCOIN]: "LEDGER_BITCOIN",
|
|
97
|
+
[ledger_pb_1.Ledger.LITECOIN]: "LEDGER_LITECOIN",
|
|
98
|
+
[ledger_pb_1.Ledger.ETHEREUM]: "LEDGER_ETHEREUM",
|
|
99
|
+
[ledger_pb_1.Ledger.XRP]: "LEDGER_XRP",
|
|
100
|
+
[ledger_pb_1.Ledger.SA_STOCK_BROKERS]: "LEDGER_SA_STOCK_BROKERS",
|
|
101
|
+
[ledger_pb_1.Ledger.NULL]: "LEDGER_NULL",
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Converts a Ledger enum instance to a BE string representation.
|
|
105
|
+
* @param {Ledger} Ledger - The Ledger to convert.
|
|
106
|
+
* @returns {string} The custom string representation of the Ledger.
|
|
107
|
+
*/
|
|
108
|
+
function ledgerToBEString(Ledger) {
|
|
109
|
+
if (Ledger in ledgerToBEStringMapping) {
|
|
110
|
+
return ledgerToBEStringMapping[Ledger];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw new UnsupportedLedgerError(Ledger);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { GenEnum, GenFile } from "@bufbuild/protobuf/codegenv2";
|
|
2
|
+
/**
|
|
3
|
+
* Describes the file meshtrade/type/v1/ledger.proto.
|
|
4
|
+
*/
|
|
5
|
+
export declare const file_meshtrade_type_v1_ledger: GenFile;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* Ledger represents the various distributed and centralized systems that Mesh
|
|
9
|
+
* interacts with where value is accounted for. The term "Ledger" is used
|
|
10
|
+
* inclusively to cover both blockchain and other value-tracking systems.
|
|
11
|
+
* Note that numbering is not sequential for legacy reasons.
|
|
12
|
+
*
|
|
13
|
+
* @generated from enum meshtrade.type.v1.Ledger
|
|
14
|
+
*/
|
|
15
|
+
export declare enum Ledger {
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* Indicates an unknown or unspecified ledger. This default value helps
|
|
19
|
+
* prevent accidental assignment and should not be used in practice.
|
|
20
|
+
*
|
|
21
|
+
* @generated from enum value: LEDGER_UNSPECIFIED = 0;
|
|
22
|
+
*/
|
|
23
|
+
UNSPECIFIED = 0,
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* The Stellar public ledger network.
|
|
27
|
+
* See: https://stellar.org
|
|
28
|
+
*
|
|
29
|
+
* @generated from enum value: LEDGER_STELLAR = 3;
|
|
30
|
+
*/
|
|
31
|
+
STELLAR = 3,
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* The Bitcoin public ledger network.
|
|
35
|
+
* See: https://bitcoin.org
|
|
36
|
+
*
|
|
37
|
+
* @generated from enum value: LEDGER_BITCOIN = 5;
|
|
38
|
+
*/
|
|
39
|
+
BITCOIN = 5,
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* The Litecoin public ledger network.
|
|
43
|
+
* See: https://litecoin.org
|
|
44
|
+
*
|
|
45
|
+
* @generated from enum value: LEDGER_LITECOIN = 7;
|
|
46
|
+
*/
|
|
47
|
+
LITECOIN = 7,
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* The Ethereum public ledger network.
|
|
51
|
+
* See: https://ethereum.org
|
|
52
|
+
*
|
|
53
|
+
* @generated from enum value: LEDGER_ETHEREUM = 9;
|
|
54
|
+
*/
|
|
55
|
+
ETHEREUM = 9,
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* The XRP Ledger (formerly Ripple).
|
|
59
|
+
* See: https://xrpl.org
|
|
60
|
+
*
|
|
61
|
+
* @generated from enum value: LEDGER_XRP = 11;
|
|
62
|
+
*/
|
|
63
|
+
XRP = 11,
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* The proprietary ledger for the SA Stockbrokers platform.
|
|
67
|
+
*
|
|
68
|
+
* @generated from enum value: LEDGER_SA_STOCK_BROKERS = 15;
|
|
69
|
+
*/
|
|
70
|
+
SA_STOCK_BROKERS = 15,
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* A null ledger, used as a placeholder for assets that do not have
|
|
74
|
+
* an external or on-chain accounting ledger.
|
|
75
|
+
*
|
|
76
|
+
* @generated from enum value: LEDGER_NULL = 16;
|
|
77
|
+
*/
|
|
78
|
+
NULL = 16
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Describes the enum meshtrade.type.v1.Ledger.
|
|
82
|
+
*/
|
|
83
|
+
export declare const LedgerSchema: GenEnum<Ledger>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @generated by protoc-gen-es v2.10.1 with parameter "target=ts"
|
|
3
|
+
// @generated from file meshtrade/type/v1/ledger.proto (package meshtrade.type.v1, syntax proto3)
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LedgerSchema = exports.Ledger = exports.file_meshtrade_type_v1_ledger = void 0;
|
|
7
|
+
const codegenv2_1 = require("@bufbuild/protobuf/codegenv2");
|
|
8
|
+
/**
|
|
9
|
+
* Describes the file meshtrade/type/v1/ledger.proto.
|
|
10
|
+
*/
|
|
11
|
+
exports.file_meshtrade_type_v1_ledger = (0, codegenv2_1.fileDesc)("Ch5tZXNodHJhZGUvdHlwZS92MS9sZWRnZXIucHJvdG8SEW1lc2h0cmFkZS50eXBlLnYxKrABCgZMZWRnZXISFgoSTEVER0VSX1VOU1BFQ0lGSUVEEAASEgoOTEVER0VSX1NURUxMQVIQAxISCg5MRURHRVJfQklUQ09JThAFEhMKD0xFREdFUl9MSVRFQ09JThAHEhMKD0xFREdFUl9FVEhFUkVVTRAJEg4KCkxFREdFUl9YUlAQCxIbChdMRURHRVJfU0FfU1RPQ0tfQlJPS0VSUxAPEg8KC0xFREdFUl9OVUxMEBBCRwoYY28ubWVzaHRyYWRlLmFwaS50eXBlLnYxWitnaXRodWIuY29tL21lc2h0cmFkZS9hcGkvZ28vdHlwZS92MTt0eXBlX3YxYgZwcm90bzM");
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* Ledger represents the various distributed and centralized systems that Mesh
|
|
15
|
+
* interacts with where value is accounted for. The term "Ledger" is used
|
|
16
|
+
* inclusively to cover both blockchain and other value-tracking systems.
|
|
17
|
+
* Note that numbering is not sequential for legacy reasons.
|
|
18
|
+
*
|
|
19
|
+
* @generated from enum meshtrade.type.v1.Ledger
|
|
20
|
+
*/
|
|
21
|
+
var Ledger;
|
|
22
|
+
(function (Ledger) {
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* Indicates an unknown or unspecified ledger. This default value helps
|
|
26
|
+
* prevent accidental assignment and should not be used in practice.
|
|
27
|
+
*
|
|
28
|
+
* @generated from enum value: LEDGER_UNSPECIFIED = 0;
|
|
29
|
+
*/
|
|
30
|
+
Ledger[Ledger["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* The Stellar public ledger network.
|
|
34
|
+
* See: https://stellar.org
|
|
35
|
+
*
|
|
36
|
+
* @generated from enum value: LEDGER_STELLAR = 3;
|
|
37
|
+
*/
|
|
38
|
+
Ledger[Ledger["STELLAR"] = 3] = "STELLAR";
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* The Bitcoin public ledger network.
|
|
42
|
+
* See: https://bitcoin.org
|
|
43
|
+
*
|
|
44
|
+
* @generated from enum value: LEDGER_BITCOIN = 5;
|
|
45
|
+
*/
|
|
46
|
+
Ledger[Ledger["BITCOIN"] = 5] = "BITCOIN";
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* The Litecoin public ledger network.
|
|
50
|
+
* See: https://litecoin.org
|
|
51
|
+
*
|
|
52
|
+
* @generated from enum value: LEDGER_LITECOIN = 7;
|
|
53
|
+
*/
|
|
54
|
+
Ledger[Ledger["LITECOIN"] = 7] = "LITECOIN";
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* The Ethereum public ledger network.
|
|
58
|
+
* See: https://ethereum.org
|
|
59
|
+
*
|
|
60
|
+
* @generated from enum value: LEDGER_ETHEREUM = 9;
|
|
61
|
+
*/
|
|
62
|
+
Ledger[Ledger["ETHEREUM"] = 9] = "ETHEREUM";
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* The XRP Ledger (formerly Ripple).
|
|
66
|
+
* See: https://xrpl.org
|
|
67
|
+
*
|
|
68
|
+
* @generated from enum value: LEDGER_XRP = 11;
|
|
69
|
+
*/
|
|
70
|
+
Ledger[Ledger["XRP"] = 11] = "XRP";
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* The proprietary ledger for the SA Stockbrokers platform.
|
|
74
|
+
*
|
|
75
|
+
* @generated from enum value: LEDGER_SA_STOCK_BROKERS = 15;
|
|
76
|
+
*/
|
|
77
|
+
Ledger[Ledger["SA_STOCK_BROKERS"] = 15] = "SA_STOCK_BROKERS";
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* A null ledger, used as a placeholder for assets that do not have
|
|
81
|
+
* an external or on-chain accounting ledger.
|
|
82
|
+
*
|
|
83
|
+
* @generated from enum value: LEDGER_NULL = 16;
|
|
84
|
+
*/
|
|
85
|
+
Ledger[Ledger["NULL"] = 16] = "NULL";
|
|
86
|
+
})(Ledger || (exports.Ledger = Ledger = {}));
|
|
87
|
+
/**
|
|
88
|
+
* Describes the enum meshtrade.type.v1.Ledger.
|
|
89
|
+
*/
|
|
90
|
+
exports.LedgerSchema = (0, codegenv2_1.enumDesc)(exports.file_meshtrade_type_v1_ledger, 0);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { GenEnum, GenFile } from "@bufbuild/protobuf/codegenv2";
|
|
2
|
+
/**
|
|
3
|
+
* Describes the file meshtrade/type/v1/sorting.proto.
|
|
4
|
+
*/
|
|
5
|
+
export declare const file_meshtrade_type_v1_sorting: GenFile;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* SortingOrder is possible search sorting orders.
|
|
9
|
+
*
|
|
10
|
+
* @generated from enum meshtrade.type.v1.SortingOrder
|
|
11
|
+
*/
|
|
12
|
+
export declare enum SortingOrder {
|
|
13
|
+
/**
|
|
14
|
+
* 0 not used to prevent unexpected default value behaviour
|
|
15
|
+
*
|
|
16
|
+
* @generated from enum value: SORTING_ORDER_UNSPECIFIED = 0;
|
|
17
|
+
*/
|
|
18
|
+
UNSPECIFIED = 0,
|
|
19
|
+
/**
|
|
20
|
+
* Ascending sorting order
|
|
21
|
+
*
|
|
22
|
+
* @generated from enum value: SORTING_ORDER_ASC = 1;
|
|
23
|
+
*/
|
|
24
|
+
ASC = 1,
|
|
25
|
+
/**
|
|
26
|
+
* Descending sorting order
|
|
27
|
+
*
|
|
28
|
+
* @generated from enum value: SORTING_ORDER_DESC = 2;
|
|
29
|
+
*/
|
|
30
|
+
DESC = 2
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Describes the enum meshtrade.type.v1.SortingOrder.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SortingOrderSchema: GenEnum<SortingOrder>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @generated by protoc-gen-es v2.10.1 with parameter "target=ts"
|
|
3
|
+
// @generated from file meshtrade/type/v1/sorting.proto (package meshtrade.type.v1, syntax proto3)
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SortingOrderSchema = exports.SortingOrder = exports.file_meshtrade_type_v1_sorting = void 0;
|
|
7
|
+
const codegenv2_1 = require("@bufbuild/protobuf/codegenv2");
|
|
8
|
+
/**
|
|
9
|
+
* Describes the file meshtrade/type/v1/sorting.proto.
|
|
10
|
+
*/
|
|
11
|
+
exports.file_meshtrade_type_v1_sorting = (0, codegenv2_1.fileDesc)("Ch9tZXNodHJhZGUvdHlwZS92MS9zb3J0aW5nLnByb3RvEhFtZXNodHJhZGUudHlwZS52MSpcCgxTb3J0aW5nT3JkZXISHQoZU09SVElOR19PUkRFUl9VTlNQRUNJRklFRBAAEhUKEVNPUlRJTkdfT1JERVJfQVNDEAESFgoSU09SVElOR19PUkRFUl9ERVNDEAJCRwoYY28ubWVzaHRyYWRlLmFwaS50eXBlLnYxWitnaXRodWIuY29tL21lc2h0cmFkZS9hcGkvZ28vdHlwZS92MTt0eXBlX3YxYgZwcm90bzM");
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* SortingOrder is possible search sorting orders.
|
|
15
|
+
*
|
|
16
|
+
* @generated from enum meshtrade.type.v1.SortingOrder
|
|
17
|
+
*/
|
|
18
|
+
var SortingOrder;
|
|
19
|
+
(function (SortingOrder) {
|
|
20
|
+
/**
|
|
21
|
+
* 0 not used to prevent unexpected default value behaviour
|
|
22
|
+
*
|
|
23
|
+
* @generated from enum value: SORTING_ORDER_UNSPECIFIED = 0;
|
|
24
|
+
*/
|
|
25
|
+
SortingOrder[SortingOrder["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
26
|
+
/**
|
|
27
|
+
* Ascending sorting order
|
|
28
|
+
*
|
|
29
|
+
* @generated from enum value: SORTING_ORDER_ASC = 1;
|
|
30
|
+
*/
|
|
31
|
+
SortingOrder[SortingOrder["ASC"] = 1] = "ASC";
|
|
32
|
+
/**
|
|
33
|
+
* Descending sorting order
|
|
34
|
+
*
|
|
35
|
+
* @generated from enum value: SORTING_ORDER_DESC = 2;
|
|
36
|
+
*/
|
|
37
|
+
SortingOrder[SortingOrder["DESC"] = 2] = "DESC";
|
|
38
|
+
})(SortingOrder || (exports.SortingOrder = SortingOrder = {}));
|
|
39
|
+
/**
|
|
40
|
+
* Describes the enum meshtrade.type.v1.SortingOrder.
|
|
41
|
+
*/
|
|
42
|
+
exports.SortingOrderSchema = (0, codegenv2_1.enumDesc)(exports.file_meshtrade_type_v1_sorting, 0);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { TimeOfDay } from "./time_of_day_pb";
|
|
2
|
+
import { Date as ProtoDate } from "./date_pb";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new TimeOfDay protobuf message from hours, minutes, seconds, and nanos values.
|
|
5
|
+
* Validates the input values according to the TimeOfDay message constraints.
|
|
6
|
+
*
|
|
7
|
+
* @param hours - Hours value (0-23, default 0)
|
|
8
|
+
* @param minutes - Minutes value (0-59, default 0)
|
|
9
|
+
* @param seconds - Seconds value (0-59, default 0)
|
|
10
|
+
* @param nanos - Nanoseconds value (0-999999999, default 0)
|
|
11
|
+
* @returns A TimeOfDay protobuf message
|
|
12
|
+
* @throws Error if the time values are invalid
|
|
13
|
+
*/
|
|
14
|
+
export declare function newTimeOfDay(hours?: number, minutes?: number, seconds?: number, nanos?: number): TimeOfDay;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a TimeOfDay protobuf message from a JavaScript Date object.
|
|
17
|
+
* Only extracts the time components, ignoring the date.
|
|
18
|
+
*
|
|
19
|
+
* @param jsDate - A JavaScript Date object
|
|
20
|
+
* @returns A TimeOfDay protobuf message
|
|
21
|
+
*/
|
|
22
|
+
export declare function newTimeOfDayFromJsDate(jsDate: Date): TimeOfDay;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a TimeOfDay protobuf message from milliseconds since midnight.
|
|
25
|
+
*
|
|
26
|
+
* @param millisSinceMidnight - Milliseconds elapsed since midnight
|
|
27
|
+
* @returns A TimeOfDay protobuf message
|
|
28
|
+
* @throws Error if the value is negative or >= 24 hours
|
|
29
|
+
*/
|
|
30
|
+
export declare function newTimeOfDayFromMillis(millisSinceMidnight: number): TimeOfDay;
|
|
31
|
+
/**
|
|
32
|
+
* Converts a TimeOfDay protobuf message to milliseconds since midnight.
|
|
33
|
+
*
|
|
34
|
+
* @param protoTime - A TimeOfDay protobuf message
|
|
35
|
+
* @returns Milliseconds elapsed since midnight
|
|
36
|
+
*/
|
|
37
|
+
export declare function timeOfDayToMillis(protoTime: TimeOfDay): number;
|
|
38
|
+
/**
|
|
39
|
+
* Combines a TimeOfDay with a Date to create a JavaScript Date object.
|
|
40
|
+
*
|
|
41
|
+
* @param protoTime - A TimeOfDay protobuf message
|
|
42
|
+
* @param protoDate - A Date protobuf message
|
|
43
|
+
* @returns A JavaScript Date object
|
|
44
|
+
* @throws Error if either object is invalid or if date is incomplete
|
|
45
|
+
*/
|
|
46
|
+
export declare function timeOfDayToJsDateWithDate(protoTime: TimeOfDay, protoDate: ProtoDate): Date;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if a TimeOfDay has valid values according to the protobuf constraints.
|
|
49
|
+
*
|
|
50
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
51
|
+
* @returns True if the time is valid, false otherwise
|
|
52
|
+
*/
|
|
53
|
+
export declare function isValid(protoTime?: TimeOfDay): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Returns true if the time represents midnight (00:00:00.000000000).
|
|
56
|
+
*
|
|
57
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
58
|
+
* @returns True if the time is midnight, false otherwise
|
|
59
|
+
*/
|
|
60
|
+
export declare function isMidnight(protoTime?: TimeOfDay): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a string representation of the time in HH:MM:SS.nnnnnnnnn format.
|
|
63
|
+
*
|
|
64
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
65
|
+
* @returns String representation of the time
|
|
66
|
+
*/
|
|
67
|
+
export declare function timeOfDayToString(protoTime?: TimeOfDay): string;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the total number of seconds since midnight as a number.
|
|
70
|
+
*
|
|
71
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
72
|
+
* @returns Total seconds since midnight
|
|
73
|
+
*/
|
|
74
|
+
export declare function totalSeconds(protoTime?: TimeOfDay): number;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newTimeOfDay = newTimeOfDay;
|
|
4
|
+
exports.newTimeOfDayFromJsDate = newTimeOfDayFromJsDate;
|
|
5
|
+
exports.newTimeOfDayFromMillis = newTimeOfDayFromMillis;
|
|
6
|
+
exports.timeOfDayToMillis = timeOfDayToMillis;
|
|
7
|
+
exports.timeOfDayToJsDateWithDate = timeOfDayToJsDateWithDate;
|
|
8
|
+
exports.isValid = isValid;
|
|
9
|
+
exports.isMidnight = isMidnight;
|
|
10
|
+
exports.timeOfDayToString = timeOfDayToString;
|
|
11
|
+
exports.totalSeconds = totalSeconds;
|
|
12
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
13
|
+
const time_of_day_pb_1 = require("./time_of_day_pb");
|
|
14
|
+
const date_1 = require("./date");
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new TimeOfDay protobuf message from hours, minutes, seconds, and nanos values.
|
|
17
|
+
* Validates the input values according to the TimeOfDay message constraints.
|
|
18
|
+
*
|
|
19
|
+
* @param hours - Hours value (0-23, default 0)
|
|
20
|
+
* @param minutes - Minutes value (0-59, default 0)
|
|
21
|
+
* @param seconds - Seconds value (0-59, default 0)
|
|
22
|
+
* @param nanos - Nanoseconds value (0-999999999, default 0)
|
|
23
|
+
* @returns A TimeOfDay protobuf message
|
|
24
|
+
* @throws Error if the time values are invalid
|
|
25
|
+
*/
|
|
26
|
+
function newTimeOfDay(hours = 0, minutes = 0, seconds = 0, nanos = 0) {
|
|
27
|
+
validateTimeOfDay(hours, minutes, seconds, nanos);
|
|
28
|
+
return (0, protobuf_1.create)(time_of_day_pb_1.TimeOfDaySchema, { hours, minutes, seconds, nanos });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a TimeOfDay protobuf message from a JavaScript Date object.
|
|
32
|
+
* Only extracts the time components, ignoring the date.
|
|
33
|
+
*
|
|
34
|
+
* @param jsDate - A JavaScript Date object
|
|
35
|
+
* @returns A TimeOfDay protobuf message
|
|
36
|
+
*/
|
|
37
|
+
function newTimeOfDayFromJsDate(jsDate) {
|
|
38
|
+
return (0, protobuf_1.create)(time_of_day_pb_1.TimeOfDaySchema, {
|
|
39
|
+
hours: jsDate.getHours(),
|
|
40
|
+
minutes: jsDate.getMinutes(),
|
|
41
|
+
seconds: jsDate.getSeconds(),
|
|
42
|
+
nanos: jsDate.getMilliseconds() * 1000000, // Convert milliseconds to nanoseconds
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a TimeOfDay protobuf message from milliseconds since midnight.
|
|
47
|
+
*
|
|
48
|
+
* @param millisSinceMidnight - Milliseconds elapsed since midnight
|
|
49
|
+
* @returns A TimeOfDay protobuf message
|
|
50
|
+
* @throws Error if the value is negative or >= 24 hours
|
|
51
|
+
*/
|
|
52
|
+
function newTimeOfDayFromMillis(millisSinceMidnight) {
|
|
53
|
+
if (millisSinceMidnight < 0) {
|
|
54
|
+
throw new Error(`Milliseconds cannot be negative: ${millisSinceMidnight}`);
|
|
55
|
+
}
|
|
56
|
+
if (millisSinceMidnight >= 24 * 60 * 60 * 1000) {
|
|
57
|
+
throw new Error(`Milliseconds cannot be 24 hours or more: ${millisSinceMidnight}`);
|
|
58
|
+
}
|
|
59
|
+
const totalSeconds = Math.floor(millisSinceMidnight / 1000);
|
|
60
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
61
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
62
|
+
const seconds = totalSeconds % 60;
|
|
63
|
+
const nanos = (millisSinceMidnight % 1000) * 1000000; // Convert remaining milliseconds to nanoseconds
|
|
64
|
+
return (0, protobuf_1.create)(time_of_day_pb_1.TimeOfDaySchema, { hours, minutes, seconds, nanos });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Converts a TimeOfDay protobuf message to milliseconds since midnight.
|
|
68
|
+
*
|
|
69
|
+
* @param protoTime - A TimeOfDay protobuf message
|
|
70
|
+
* @returns Milliseconds elapsed since midnight
|
|
71
|
+
*/
|
|
72
|
+
function timeOfDayToMillis(protoTime) {
|
|
73
|
+
if (!protoTime) {
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
return (protoTime.hours * 3600000 +
|
|
77
|
+
protoTime.minutes * 60000 +
|
|
78
|
+
protoTime.seconds * 1000 +
|
|
79
|
+
Math.floor(protoTime.nanos / 1000000)); // Convert nanoseconds to milliseconds
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Combines a TimeOfDay with a Date to create a JavaScript Date object.
|
|
83
|
+
*
|
|
84
|
+
* @param protoTime - A TimeOfDay protobuf message
|
|
85
|
+
* @param protoDate - A Date protobuf message
|
|
86
|
+
* @returns A JavaScript Date object
|
|
87
|
+
* @throws Error if either object is invalid or if date is incomplete
|
|
88
|
+
*/
|
|
89
|
+
function timeOfDayToJsDateWithDate(protoTime, protoDate) {
|
|
90
|
+
if (!protoTime) {
|
|
91
|
+
throw new Error("TimeOfDay object is null or undefined");
|
|
92
|
+
}
|
|
93
|
+
if (!protoDate) {
|
|
94
|
+
throw new Error("Date object is null or undefined");
|
|
95
|
+
}
|
|
96
|
+
if (!(0, date_1.isComplete)(protoDate)) {
|
|
97
|
+
throw new Error("Date must be complete");
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
return new Date(protoDate.year, protoDate.month - 1, // JS months are 0-indexed
|
|
101
|
+
protoDate.day, protoTime.hours, protoTime.minutes, protoTime.seconds, Math.floor(protoTime.nanos / 1000000) // Convert nanoseconds to milliseconds
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
throw new Error(`Invalid datetime values: ${e}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Checks if a TimeOfDay has valid values according to the protobuf constraints.
|
|
110
|
+
*
|
|
111
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
112
|
+
* @returns True if the time is valid, false otherwise
|
|
113
|
+
*/
|
|
114
|
+
function isValid(protoTime) {
|
|
115
|
+
if (!protoTime) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
validateTimeOfDay(protoTime.hours, protoTime.minutes, protoTime.seconds, protoTime.nanos);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns true if the time represents midnight (00:00:00.000000000).
|
|
128
|
+
*
|
|
129
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
130
|
+
* @returns True if the time is midnight, false otherwise
|
|
131
|
+
*/
|
|
132
|
+
function isMidnight(protoTime) {
|
|
133
|
+
if (!protoTime) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return (protoTime.hours === 0 &&
|
|
137
|
+
protoTime.minutes === 0 &&
|
|
138
|
+
protoTime.seconds === 0 &&
|
|
139
|
+
protoTime.nanos === 0);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns a string representation of the time in HH:MM:SS.nnnnnnnnn format.
|
|
143
|
+
*
|
|
144
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
145
|
+
* @returns String representation of the time
|
|
146
|
+
*/
|
|
147
|
+
function timeOfDayToString(protoTime) {
|
|
148
|
+
if (!protoTime) {
|
|
149
|
+
return "<undefined>";
|
|
150
|
+
}
|
|
151
|
+
if (protoTime.nanos === 0) {
|
|
152
|
+
return `${protoTime.hours.toString().padStart(2, "0")}:${protoTime.minutes.toString().padStart(2, "0")}:${protoTime.seconds.toString().padStart(2, "0")}`;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return `${protoTime.hours.toString().padStart(2, "0")}:${protoTime.minutes.toString().padStart(2, "0")}:${protoTime.seconds.toString().padStart(2, "0")}.${protoTime.nanos.toString().padStart(9, "0")}`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns the total number of seconds since midnight as a number.
|
|
160
|
+
*
|
|
161
|
+
* @param protoTime - A TimeOfDay protobuf message or undefined
|
|
162
|
+
* @returns Total seconds since midnight
|
|
163
|
+
*/
|
|
164
|
+
function totalSeconds(protoTime) {
|
|
165
|
+
if (!protoTime) {
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
return (protoTime.hours * 3600 +
|
|
169
|
+
protoTime.minutes * 60 +
|
|
170
|
+
protoTime.seconds +
|
|
171
|
+
protoTime.nanos / 1e9);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Validates the hours, minutes, seconds, and nanos values according to TimeOfDay constraints.
|
|
175
|
+
*
|
|
176
|
+
* @param hours - Hours value
|
|
177
|
+
* @param minutes - Minutes value
|
|
178
|
+
* @param seconds - Seconds value
|
|
179
|
+
* @param nanos - Nanoseconds value
|
|
180
|
+
* @throws Error if the time values are invalid
|
|
181
|
+
*/
|
|
182
|
+
function validateTimeOfDay(hours, minutes, seconds, nanos) {
|
|
183
|
+
// Hours validation
|
|
184
|
+
if (hours < 0 || hours > 23) {
|
|
185
|
+
throw new Error(`Hours must be between 0 and 23, got ${hours}`);
|
|
186
|
+
}
|
|
187
|
+
// Minutes validation
|
|
188
|
+
if (minutes < 0 || minutes > 59) {
|
|
189
|
+
throw new Error(`Minutes must be between 0 and 59, got ${minutes}`);
|
|
190
|
+
}
|
|
191
|
+
// Seconds validation
|
|
192
|
+
if (seconds < 0 || seconds > 59) {
|
|
193
|
+
throw new Error(`Seconds must be between 0 and 59, got ${seconds}`);
|
|
194
|
+
}
|
|
195
|
+
// Nanos validation
|
|
196
|
+
if (nanos < 0 || nanos > 999999999) {
|
|
197
|
+
throw new Error(`Nanos must be between 0 and 999,999,999, got ${nanos}`);
|
|
198
|
+
}
|
|
199
|
+
}
|