@odatano/core 2.0.0-rc.3 → 2.0.0-rc.30
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/@cds-models/CardanoAgentService/index.d.ts +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +294 -7
- package/@cds-models/CardanoODataService/index.js +33 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +52 -19
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +18 -0
- package/@cds-models/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +677 -13
- package/db/types.cds +27 -0
- package/package.json +182 -173
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +11 -10
- package/src/index.js +28 -14
- package/src/plugin.js +39 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +49 -160
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +356 -217
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +548 -197
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +78 -205
- package/srv/blockchain/cardano-client.js +186 -242
- package/srv/blockchain/cardano-indexer.d.ts +302 -242
- package/srv/blockchain/cardano-indexer.js +1191 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +43 -81
- package/srv/blockchain/cardano-tx-builder.js +177 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +108 -160
- package/srv/blockchain/transaction-building/buildooor-tx.js +620 -285
- package/srv/blockchain/transaction-building/caller-datums.d.ts +17 -0
- package/srv/blockchain/transaction-building/caller-datums.js +50 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +48 -24
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +56 -1
- package/srv/cardano-service.js +52 -113
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +439 -364
- package/srv/cardano-tx-service.js +305 -209
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/parse.js +13 -1
- package/srv/server.d.ts +28 -86
- package/srv/server.js +127 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +25 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +26 -92
- package/srv/utils/tx-build-helper.js +68 -123
- package/srv/utils/tx-request-parsers.d.ts +107 -21
- package/srv/utils/tx-request-parsers.js +433 -34
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +238 -169
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
package/srv/utils/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AllBackendsInitFailedError = exports.BackendInitError = exports.ConfigError = exports.HsmError = exports.AllBackendsFailedError = exports.RateLimitError = exports.ProviderUnavailableError = exports.MixedAssetsError = exports.InsufficientFundsError = exports.TransactionAlreadySubmittedError = exports.ScriptValidationError = exports.TransactionValidationError = exports.NotFoundError = exports.BackendError = void 0;
|
|
3
|
+
exports.AllBackendsInitFailedError = exports.BackendInitError = exports.ChainSyncFrameError = exports.ChainSyncStalledError = exports.ChainSyncClosedError = exports.ConfigError = exports.HsmError = exports.AllBackendsFailedError = exports.RateLimitError = exports.ProviderUnavailableError = exports.MixedAssetsError = exports.InsufficientFundsError = exports.TransactionAlreadySubmittedError = exports.ChainPointMismatchError = exports.ScriptValidationError = exports.TransactionValidationError = exports.NotFoundError = exports.BackendError = void 0;
|
|
4
4
|
exports.isNotFoundOnAllBackends = isNotFoundOnAllBackends;
|
|
5
5
|
exports.isPostgrestServerErrorCode = isPostgrestServerErrorCode;
|
|
6
6
|
exports.getErrorStatus = getErrorStatus;
|
|
@@ -10,27 +10,14 @@ exports.rejectInvalid = rejectInvalid;
|
|
|
10
10
|
exports.rejectMissing = rejectMissing;
|
|
11
11
|
exports.throwIfValidationErrors = throwIfValidationErrors;
|
|
12
12
|
const error_codes_1 = require("./error-codes");
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
* Defines typed errors for backend communication issues
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* BackendError Base class for all backend-related errors
|
|
19
|
-
*/
|
|
13
|
+
/** Typed errors for backend communication and request validation. */
|
|
14
|
+
/** Base class for all backend-related errors. */
|
|
20
15
|
class BackendError extends Error {
|
|
21
16
|
statusCode;
|
|
22
17
|
code;
|
|
23
18
|
backendName;
|
|
24
19
|
originalError;
|
|
25
20
|
target;
|
|
26
|
-
/** Constructor
|
|
27
|
-
* @param message error message string
|
|
28
|
-
* @param statusCode error status code
|
|
29
|
-
* @param code error code
|
|
30
|
-
* @param backendName name of the backend where the error originated
|
|
31
|
-
* @param originalError original error object
|
|
32
|
-
* @param target target resource (if applicable)
|
|
33
|
-
*/
|
|
34
21
|
constructor(message, statusCode = 500, code = error_codes_1.ERROR_CODES.INTERNAL_ERROR, backendName, originalError, target) {
|
|
35
22
|
super(message);
|
|
36
23
|
this.statusCode = statusCode;
|
|
@@ -43,67 +30,40 @@ class BackendError extends Error {
|
|
|
43
30
|
}
|
|
44
31
|
}
|
|
45
32
|
exports.BackendError = BackendError;
|
|
46
|
-
/**
|
|
47
|
-
* NotFoundError - Resource not found in backend (404)
|
|
48
|
-
* This is NOT a provider error - it's a valid response indicating the resource doesn't exist
|
|
49
|
-
* Examples: transaction hash not found, address has no UTxOs
|
|
50
|
-
*/
|
|
33
|
+
/** Resource not found (404); a valid response, not a provider fault. */
|
|
51
34
|
class NotFoundError extends BackendError {
|
|
52
|
-
/** Constructor
|
|
53
|
-
* @param resource name of the resource that was not found
|
|
54
|
-
* @param backendName name of the backend where the error originated
|
|
55
|
-
* @param originalError original error object
|
|
56
|
-
*/
|
|
57
35
|
constructor(resource, backendName, originalError) {
|
|
58
36
|
super(`${resource} not found`, 404, error_codes_1.ERROR_CODES.NOT_FOUND, backendName, originalError);
|
|
59
37
|
}
|
|
60
38
|
}
|
|
61
39
|
exports.NotFoundError = NotFoundError;
|
|
62
|
-
/**
|
|
63
|
-
* TransactionValidationError - Transaction failed validation (400)
|
|
64
|
-
* Indicates that the transaction failed validation checks
|
|
65
|
-
* Examples: wrong signature, tampered CBOR, invalid witnesses
|
|
66
|
-
*/
|
|
40
|
+
/** Transaction failed validation (400): wrong signature, tampered CBOR, invalid witnesses. `code` may be `TX_PARSE_FAILED`. */
|
|
67
41
|
class TransactionValidationError extends BackendError {
|
|
68
|
-
/** Constructor
|
|
69
|
-
* @param message detailed validation failure message
|
|
70
|
-
* @param originalError original error object
|
|
71
|
-
* @param code optional override (e.g. `TX_PARSE_FAILED` for CBOR decode failures);
|
|
72
|
-
* defaults to `TX_VALIDATION_FAILED`.
|
|
73
|
-
*/
|
|
74
42
|
constructor(message, originalError, code = error_codes_1.ERROR_CODES.TX_VALIDATION_FAILED) {
|
|
75
43
|
super(message, 400, code, undefined, originalError);
|
|
76
44
|
}
|
|
77
45
|
}
|
|
78
46
|
exports.TransactionValidationError = TransactionValidationError;
|
|
79
|
-
/**
|
|
80
|
-
* ScriptValidationError - Plutus script validation failed on the ledger (400)
|
|
81
|
-
* Distinguishes a clean ledger rejection (PlutusFailure, CekError, overspent
|
|
82
|
-
* budget, script hash mismatch) from provider outages (503). The transaction
|
|
83
|
-
* was well-formed enough to reach phase-2 validation — retrying against a
|
|
84
|
-
* different provider will not help; the tx shape itself is the problem.
|
|
85
|
-
*/
|
|
47
|
+
/** Ledger phase-2 script rejection (400): PlutusFailure, CekError, budget, hash mismatch. Not retryable on another provider. */
|
|
86
48
|
class ScriptValidationError extends BackendError {
|
|
87
|
-
/** Constructor
|
|
88
|
-
* @param message detailed script failure message (typically from ledger)
|
|
89
|
-
* @param originalError original error object
|
|
90
|
-
*/
|
|
91
49
|
constructor(message, originalError) {
|
|
92
50
|
super(message, 400, error_codes_1.ERROR_CODES.SCRIPT_VALIDATION_FAILURE, undefined, originalError);
|
|
93
51
|
}
|
|
94
52
|
}
|
|
95
53
|
exports.ScriptValidationError = ScriptValidationError;
|
|
96
54
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* Examples: same txHash already in mempool or on chain
|
|
55
|
+
* A crawler cursor block this instance does not follow (409). A 4xx keeps its message in production,
|
|
56
|
+
* so a remote crawler receives the `CHAIN_POINT_MISMATCH:` marker it recovers on.
|
|
100
57
|
*/
|
|
58
|
+
class ChainPointMismatchError extends BackendError {
|
|
59
|
+
constructor(message, backendName) {
|
|
60
|
+
super(message, 409, error_codes_1.ERROR_CODES.CHAIN_POINT_MISMATCH, backendName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ChainPointMismatchError = ChainPointMismatchError;
|
|
64
|
+
/** Transaction already in mempool or on chain (409). */
|
|
101
65
|
class TransactionAlreadySubmittedError extends BackendError {
|
|
102
66
|
txHash;
|
|
103
|
-
/** Constructor
|
|
104
|
-
* @param txHash the transaction hash that was already submitted
|
|
105
|
-
* @param originalError original error object
|
|
106
|
-
*/
|
|
107
67
|
constructor(txHash, originalError) {
|
|
108
68
|
super(`Transaction ${txHash} already exists in mempool or on chain`, 409, error_codes_1.ERROR_CODES.TX_ALREADY_SUBMITTED, undefined, originalError);
|
|
109
69
|
this.txHash = txHash;
|
|
@@ -111,23 +71,13 @@ class TransactionAlreadySubmittedError extends BackendError {
|
|
|
111
71
|
}
|
|
112
72
|
exports.TransactionAlreadySubmittedError = TransactionAlreadySubmittedError;
|
|
113
73
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* Examples: trying to send more ADA than available, not enough native tokens
|
|
74
|
+
* Not enough of an asset for the transaction (400). `required`/`available` are 0n when unknown;
|
|
75
|
+
* `detail` then replaces the amounts in the message.
|
|
117
76
|
*/
|
|
118
77
|
class InsufficientFundsError extends BackendError {
|
|
119
78
|
assetUnit;
|
|
120
79
|
required;
|
|
121
80
|
available;
|
|
122
|
-
/** Constructor
|
|
123
|
-
* @param assetUnit the asset unit that is insufficient (e.g., "lovelace" or "policyId.assetName")
|
|
124
|
-
* @param required the required amount (0n when unknown)
|
|
125
|
-
* @param available the available amount (0n when unknown)
|
|
126
|
-
* @param originalError original error object
|
|
127
|
-
* @param detail human-readable cause shown INSTEAD of the amounts — use when
|
|
128
|
-
* the amounts are unknown; "required 0, available 0" reads as
|
|
129
|
-
* nonsense from the consumer's perspective
|
|
130
|
-
*/
|
|
131
81
|
constructor(assetUnit, required, available, originalError, detail) {
|
|
132
82
|
super(detail
|
|
133
83
|
? `Insufficient ${assetUnit}: ${detail}`
|
|
@@ -138,18 +88,10 @@ class InsufficientFundsError extends BackendError {
|
|
|
138
88
|
}
|
|
139
89
|
}
|
|
140
90
|
exports.InsufficientFundsError = InsufficientFundsError;
|
|
141
|
-
/**
|
|
142
|
-
* MixedAssetsError - UTxO contains mixed assets when pure ADA is required (400)
|
|
143
|
-
* Indicates that a UTxO contains native assets in addition to ADA, but the operation requires ADA-only UTxOs
|
|
144
|
-
*/
|
|
91
|
+
/** UTxO carries native assets where ADA-only is required (400). `utxoRef` is `txHash#outputIndex`. */
|
|
145
92
|
class MixedAssetsError extends BackendError {
|
|
146
93
|
utxoRef;
|
|
147
94
|
assets;
|
|
148
|
-
/** Constructor
|
|
149
|
-
* @param utxoRef UTxO reference (txHash#outputIndex)
|
|
150
|
-
* @param assets list of non-ADA assets found in the UTxO
|
|
151
|
-
* @param originalError original error object
|
|
152
|
-
*/
|
|
153
95
|
constructor(utxoRef, assets, originalError) {
|
|
154
96
|
super(`UTxO ${utxoRef} contains non-ADA assets: ${assets.join(', ')}`, 400, error_codes_1.ERROR_CODES.INVALID_INPUT, undefined, originalError, utxoRef);
|
|
155
97
|
this.utxoRef = utxoRef;
|
|
@@ -157,18 +99,8 @@ class MixedAssetsError extends BackendError {
|
|
|
157
99
|
}
|
|
158
100
|
}
|
|
159
101
|
exports.MixedAssetsError = MixedAssetsError;
|
|
160
|
-
/**
|
|
161
|
-
* ProviderUnavailableError - Provider unavailable or timeout (503)
|
|
162
|
-
* Indicates a temporary issue - retrying may help
|
|
163
|
-
* Examples: network timeout, 5xx errors, service down
|
|
164
|
-
*/
|
|
102
|
+
/** Provider unavailable or timed out (503); retryable. `timeoutMs` is appended to the message. */
|
|
165
103
|
class ProviderUnavailableError extends BackendError {
|
|
166
|
-
/** Constructor
|
|
167
|
-
* @param message error message string
|
|
168
|
-
* @param backendName name of the backend where the error originated
|
|
169
|
-
* @param timeoutMs optional timeout duration in milliseconds
|
|
170
|
-
* @param originalError original error object
|
|
171
|
-
*/
|
|
172
104
|
constructor(message, backendName, timeoutMs, originalError) {
|
|
173
105
|
const msg = timeoutMs
|
|
174
106
|
? `${message} (timeout after ${timeoutMs}ms)`
|
|
@@ -177,18 +109,8 @@ class ProviderUnavailableError extends BackendError {
|
|
|
177
109
|
}
|
|
178
110
|
}
|
|
179
111
|
exports.ProviderUnavailableError = ProviderUnavailableError;
|
|
180
|
-
/**
|
|
181
|
-
* RateLimitError - Provider rate limit exceeded (429)
|
|
182
|
-
* Indicates too many requests - client should back off and retry later
|
|
183
|
-
* Examples: Blockfrost 10 req/sec limit, Koios tier limits
|
|
184
|
-
*/
|
|
112
|
+
/** Provider rate limit exceeded (429). `retryAfter` is in seconds. */
|
|
185
113
|
class RateLimitError extends BackendError {
|
|
186
|
-
/** Constructor
|
|
187
|
-
* @param message error message string
|
|
188
|
-
* @param backendName name of the backend where the error originated
|
|
189
|
-
* @param retryAfter optional retry-after duration in seconds
|
|
190
|
-
* @param originalError original error object
|
|
191
|
-
*/
|
|
192
114
|
constructor(message, backendName, retryAfter, originalError) {
|
|
193
115
|
const msg = retryAfter
|
|
194
116
|
? `${message} (retry after ${retryAfter}s)`
|
|
@@ -197,36 +119,23 @@ class RateLimitError extends BackendError {
|
|
|
197
119
|
}
|
|
198
120
|
}
|
|
199
121
|
exports.RateLimitError = RateLimitError;
|
|
200
|
-
/**
|
|
201
|
-
* AllBackendsFailedError - All backends failed
|
|
202
|
-
* Aggregates multiple backend errors and returns the most relevant status
|
|
203
|
-
*/
|
|
122
|
+
/** Every backend failed; carries the last error's status, or 503 when all were skipped. */
|
|
204
123
|
class AllBackendsFailedError extends BackendError {
|
|
205
124
|
errors;
|
|
206
|
-
/**
|
|
207
|
-
|
|
208
|
-
* @param originalError original error object
|
|
209
|
-
*/
|
|
210
|
-
constructor(errors, originalError) {
|
|
125
|
+
/** @param skipped why backends were not called at all, e.g. `koios: circuit open` */
|
|
126
|
+
constructor(errors, originalError, skipped = []) {
|
|
211
127
|
const lastError = errors[errors.length - 1];
|
|
128
|
+
const noneCalled = skipped.length ? `no backend available (${skipped.join('; ')})` : 'unknown error';
|
|
212
129
|
super(
|
|
213
|
-
// Empty errors
|
|
214
|
-
|
|
215
|
-
// available) rather than 502 (which implies an upstream backend returned a bad
|
|
216
|
-
// response). A real backend failure carries its own statusCode via lastError.
|
|
217
|
-
`All backends failed: ${lastError?.message ?? 'unknown error'}`, lastError?.statusCode ?? 503, lastError?.code ?? error_codes_1.ERROR_CODES.PROVIDER_UNAVAILABLE, undefined, originalError);
|
|
130
|
+
// Empty errors: every backend was skipped (method unsupported), nothing failed upstream, so 503
|
|
131
|
+
`All backends failed: ${lastError?.message ?? noneCalled}`, lastError?.statusCode ?? 503, lastError?.code ?? error_codes_1.ERROR_CODES.PROVIDER_UNAVAILABLE, undefined, originalError);
|
|
218
132
|
this.errors = errors;
|
|
219
133
|
}
|
|
220
134
|
}
|
|
221
135
|
exports.AllBackendsFailedError = AllBackendsFailedError;
|
|
222
136
|
/**
|
|
223
|
-
* True when the
|
|
224
|
-
*
|
|
225
|
-
* collected per-backend errors are all 404s. CardanoClient's failover wraps
|
|
226
|
-
* per-backend errors (including 404s) into AllBackendsFailedError, so callers
|
|
227
|
-
* that need "definitively not found" (e.g. the wallet-worker's dropped-tx
|
|
228
|
-
* detection) must use this instead of `instanceof NotFoundError`. A mixed
|
|
229
|
-
* result (one backend 404, another 500) is NOT proof of absence.
|
|
137
|
+
* True when the resource is absent on every consulted backend: a NotFoundError, or an
|
|
138
|
+
* AllBackendsFailedError whose per-backend errors are all 404. A mixed result is not proof of absence.
|
|
230
139
|
*/
|
|
231
140
|
function isNotFoundOnAllBackends(err) {
|
|
232
141
|
if (err instanceof NotFoundError)
|
|
@@ -236,64 +145,42 @@ function isNotFoundOnAllBackends(err) {
|
|
|
236
145
|
&& err.errors.every((e) => e instanceof NotFoundError || e.statusCode === 404);
|
|
237
146
|
}
|
|
238
147
|
/**
|
|
239
|
-
* PostgreSQL error-code classes that
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* half-migrated SQL function on one load-balanced instance, or '57014'
|
|
243
|
-
* (statement timeout) under load. Client-input errors (class 22, invalid text
|
|
244
|
-
* representation etc.) are deliberately NOT listed — those remain 4xx.
|
|
245
|
-
* Classes: 08 connection, 42 syntax/undefined object, 53 insufficient
|
|
246
|
-
* resources, 57 operator intervention (incl. query_canceled), 58 system
|
|
247
|
-
* error, XX internal error.
|
|
148
|
+
* PostgreSQL error-code classes that mean a provider-side fault, which PostgREST (Koios) returns as HTTP 400:
|
|
149
|
+
* 08 connection, 42 undefined object, 53 resources, 57 operator intervention, 58 system, XX internal.
|
|
150
|
+
* Client-input classes (22 etc.) stay 4xx.
|
|
248
151
|
*/
|
|
249
152
|
const PG_SERVER_ERROR_CODE_CLASSES = ['08', '42', '53', '57', '58', 'XX'];
|
|
250
153
|
/** True when a PostgREST error body's `code` denotes a provider-side SQL fault. */
|
|
251
154
|
function isPostgrestServerErrorCode(code) {
|
|
252
155
|
return typeof code === 'string' && PG_SERVER_ERROR_CODE_CLASSES.some(c => code.startsWith(c));
|
|
253
156
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Utility functions to extract status and message from HttpErrorLike
|
|
256
|
-
* @param err error object
|
|
257
|
-
* @returns {number} status code
|
|
258
|
-
*/
|
|
157
|
+
/** HTTP status of an HttpErrorLike, default 500. */
|
|
259
158
|
function getErrorStatus(err) {
|
|
260
159
|
const e = (err ?? {});
|
|
261
160
|
return e.status ?? e.response?.status ?? 500;
|
|
262
161
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Utility functions to extract status and message from HttpErrorLike
|
|
265
|
-
* @param err error object
|
|
266
|
-
* @returns {string} error message
|
|
267
|
-
*/
|
|
162
|
+
/** Message of an HttpErrorLike: `response.data.error` (Koios), else `message`. */
|
|
268
163
|
function getErrorMessage(err) {
|
|
269
164
|
const e = (err ?? {});
|
|
270
|
-
// Check Axios response.data.error (Koios format)
|
|
271
165
|
if (e.response?.data?.error)
|
|
272
166
|
return e.response.data.error;
|
|
273
|
-
// Check direct message property
|
|
274
167
|
if (e.message)
|
|
275
168
|
return e.message;
|
|
276
169
|
return 'Unknown error';
|
|
277
170
|
}
|
|
171
|
+
/** Ogmios JSON-RPC code of a failed script evaluation. */
|
|
172
|
+
const OGMIOS_SCRIPT_EXECUTION_FAILURE = 3010;
|
|
173
|
+
/** Characters of Ogmios error data kept in a message. */
|
|
174
|
+
const OGMIOS_DETAIL_MAX = 2000;
|
|
278
175
|
/**
|
|
279
|
-
* Normalizes any backend error into a typed BackendError
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* 1. TX Submission — Already submitted/duplicate → 409
|
|
283
|
-
* 2. TX Submission — Plutus script validation failure → 400 (ScriptValidationError)
|
|
284
|
-
* 3. TX Submission — Validation/Signature errors → 400
|
|
285
|
-
* 4. Message indicates "not found" → 404 (even if provider returns 5xx)
|
|
286
|
-
* 5. Rate limiting (status 429 or message patterns) → 429
|
|
287
|
-
* 6. Explicit 404 status → 404
|
|
288
|
-
* 7. 5xx errors → 503 (Provider unavailable, retry-able)
|
|
289
|
-
* 8. Other 4xx → 503
|
|
290
|
-
* 9. Unknown/network errors → 503 (default fallback)
|
|
176
|
+
* Normalizes any backend error into a typed BackendError. An Ogmios script failure is recognised
|
|
177
|
+
* by its JSON-RPC code. Message hints are then checked in priority
|
|
178
|
+
* order (already submitted, script failure, validation, not found, rate limit) before the HTTP status.
|
|
291
179
|
*/
|
|
292
180
|
function normalizeBackendError(err, backendName) {
|
|
293
|
-
// Already normalized
|
|
294
181
|
if (err instanceof BackendError)
|
|
295
182
|
return err;
|
|
296
|
-
//
|
|
183
|
+
// TypeError from calling a method on an uninitialized (null) backend client
|
|
297
184
|
if (err instanceof TypeError &&
|
|
298
185
|
(err.message.includes('Cannot read properties of null') ||
|
|
299
186
|
err.message.includes('Cannot read properties of undefined') ||
|
|
@@ -301,10 +188,16 @@ function normalizeBackendError(err, backendName) {
|
|
|
301
188
|
err.message.includes('undefined is not an object'))) {
|
|
302
189
|
return new BackendInitError(backendName || 'unknown', new Error('Backend client not initialized - call init() first'));
|
|
303
190
|
}
|
|
191
|
+
// Ogmios evaluateTransaction 3010: a script failed. Its data names each failing validator.
|
|
192
|
+
const rpc = err;
|
|
193
|
+
if (rpc?.code === OGMIOS_SCRIPT_EXECUTION_FAILURE) {
|
|
194
|
+
const detail = rpc.data === undefined ? '' : ` ${JSON.stringify(rpc.data).slice(0, OGMIOS_DETAIL_MAX)}`;
|
|
195
|
+
return new ScriptValidationError(`Script validation failed (${rpc.code}): ${String(rpc.message ?? '')}${detail}`, err);
|
|
196
|
+
}
|
|
304
197
|
const message = getErrorMessage(err);
|
|
305
198
|
const status = getErrorStatus(err);
|
|
306
199
|
const messageLower = message.toLowerCase();
|
|
307
|
-
//
|
|
200
|
+
// Already submitted / duplicate: 409
|
|
308
201
|
const alreadySubmittedHints = [
|
|
309
202
|
'already exists',
|
|
310
203
|
'already submitted',
|
|
@@ -314,13 +207,10 @@ function normalizeBackendError(err, backendName) {
|
|
|
314
207
|
'in mempool',
|
|
315
208
|
];
|
|
316
209
|
if (alreadySubmittedHints.some(h => messageLower.includes(h))) {
|
|
317
|
-
// Try to extract txHash from message
|
|
318
210
|
const txHashMatch = message.match(/([a-f0-9]{64})/i);
|
|
319
211
|
return new TransactionAlreadySubmittedError(txHashMatch?.[1] || 'unknown', err);
|
|
320
212
|
}
|
|
321
|
-
//
|
|
322
|
-
// Must precede the generic validation block: these are ledger phase-2 rejections
|
|
323
|
-
// (tx was well-formed), not provider outages and not generic witness/CBOR issues.
|
|
213
|
+
// Ledger phase-2 script rejection: 400, before the generic validation hints
|
|
324
214
|
const scriptValidationHints = [
|
|
325
215
|
'plutusfailure',
|
|
326
216
|
'plutus failure',
|
|
@@ -337,9 +227,7 @@ function normalizeBackendError(err, backendName) {
|
|
|
337
227
|
if (scriptValidationHints.some(h => messageLower.includes(h))) {
|
|
338
228
|
return new ScriptValidationError(`Script validation failed: ${message}`, err);
|
|
339
229
|
}
|
|
340
|
-
//
|
|
341
|
-
// validation hints — 'malformed' there used to shadow 'malformed address',
|
|
342
|
-
// turning a Blockfrost 400 on a read into a TransactionValidationError.
|
|
230
|
+
// Address-shaped lookup errors: 404, before 'malformed' in the validation hints can catch them
|
|
343
231
|
const addressNotFoundHints = [
|
|
344
232
|
'invalid address',
|
|
345
233
|
'malformed address',
|
|
@@ -347,7 +235,7 @@ function normalizeBackendError(err, backendName) {
|
|
|
347
235
|
if (addressNotFoundHints.some(h => messageLower.includes(h))) {
|
|
348
236
|
return new NotFoundError('Resource', backendName, err);
|
|
349
237
|
}
|
|
350
|
-
//
|
|
238
|
+
// Validation / signature errors: 400
|
|
351
239
|
const validationErrorHints = [
|
|
352
240
|
'signature',
|
|
353
241
|
'witness',
|
|
@@ -360,22 +248,14 @@ function normalizeBackendError(err, backendName) {
|
|
|
360
248
|
if (validationErrorHints.some(h => messageLower.includes(h))) {
|
|
361
249
|
return new TransactionValidationError(`Transaction validation failed: ${message}`, err);
|
|
362
250
|
}
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
// SQL function on one LB instance) or { code: '57014' } (statement timeout).
|
|
366
|
-
// These are provider faults, not request validation — classify as retry-able
|
|
367
|
-
// 503 so multi-backend failover and the circuit breaker treat them like any
|
|
368
|
-
// other provider outage. Checked before Priority 4: the PostgREST message
|
|
369
|
-
// ("column … does not exist") would otherwise be misread as a resource 404.
|
|
251
|
+
// PostgREST server-side SQL faults arrive as HTTP 400 with a PG code: retryable 503 for failover.
|
|
252
|
+
// Before the not-found hints, whose 'does not exist' would match "column ... does not exist".
|
|
370
253
|
const pgErrorBody = err?.response?.data;
|
|
371
254
|
if ((status === 400 || status === 422) && isPostgrestServerErrorCode(pgErrorBody?.code)) {
|
|
372
255
|
return new ProviderUnavailableError(`Provider database error (${pgErrorBody?.code}): ${pgErrorBody?.message ?? message}`, backendName, undefined, err);
|
|
373
256
|
}
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
// resources. Deliberately NOT here: 'not available' / bare 'no data' — those
|
|
377
|
-
// also appear in provider OUTAGE messages, and classifying an outage as 404
|
|
378
|
-
// would make it circuit-breaker-exempt (4xx) on top of hiding the 503.
|
|
257
|
+
// Not-found messages: 404 regardless of status. 'not available' / bare 'no data' are excluded,
|
|
258
|
+
// they also appear in outage messages and a 404 would be circuit-breaker-exempt.
|
|
379
259
|
const notFoundHints = [
|
|
380
260
|
'not found',
|
|
381
261
|
'has not been found',
|
|
@@ -388,26 +268,24 @@ function normalizeBackendError(err, backendName) {
|
|
|
388
268
|
if (notFoundHints.some(h => messageLower.includes(h))) {
|
|
389
269
|
return new NotFoundError('Resource', backendName, err);
|
|
390
270
|
}
|
|
391
|
-
//
|
|
271
|
+
// Rate limiting: status 429 or message patterns
|
|
392
272
|
if (status === 429 ||
|
|
393
273
|
messageLower.includes('rate limit') ||
|
|
394
274
|
messageLower.includes('too many requests') ||
|
|
395
275
|
messageLower.includes('quota exceeded')) {
|
|
396
|
-
// Try to extract retry-after header
|
|
397
276
|
const headers = err.response?.headers;
|
|
398
277
|
const retryAfter = headers?.["retry-after"] ||
|
|
399
278
|
headers?.["x-ratelimit-reset"];
|
|
400
279
|
return new RateLimitError(message || 'Rate limit exceeded', backendName, retryAfter ? parseInt(retryAfter, 10) : undefined, err);
|
|
401
280
|
}
|
|
402
|
-
// Priority 6: Explicit 404 status
|
|
403
281
|
if (status === 404) {
|
|
404
282
|
return new NotFoundError('Resource', backendName, err);
|
|
405
283
|
}
|
|
406
|
-
//
|
|
284
|
+
// 5xx: provider unavailable (retryable)
|
|
407
285
|
if (status >= 500) {
|
|
408
286
|
return new ProviderUnavailableError(message || 'Provider returned server error', backendName, undefined, err);
|
|
409
287
|
}
|
|
410
|
-
//
|
|
288
|
+
// Other 4xx by status code
|
|
411
289
|
if (status === 400 || status === 422) {
|
|
412
290
|
return new TransactionValidationError(message || `Provider returned ${status}: invalid request`, err);
|
|
413
291
|
}
|
|
@@ -417,13 +295,10 @@ function normalizeBackendError(err, backendName) {
|
|
|
417
295
|
if (status >= 400) {
|
|
418
296
|
return new ProviderUnavailableError(message || 'Provider request failed', backendName, undefined, err);
|
|
419
297
|
}
|
|
420
|
-
//
|
|
298
|
+
// Unknown / network errors: unavailable
|
|
421
299
|
return new ProviderUnavailableError(message || 'Unknown backend error', backendName, undefined, err);
|
|
422
300
|
}
|
|
423
|
-
/**
|
|
424
|
-
* HsmError - Error related to HSM operations (signing, session, key access)
|
|
425
|
-
* Indicates that the Hardware Security Module is unavailable or signing failed
|
|
426
|
-
*/
|
|
301
|
+
/** HSM operation failed (session, key access, signing). */
|
|
427
302
|
class HsmError extends BackendError {
|
|
428
303
|
constructor(message, statusCode = 503, code = error_codes_1.ERROR_CODES.HSM_UNAVAILABLE, originalError) {
|
|
429
304
|
super(message, statusCode, code, 'hsm', originalError);
|
|
@@ -431,10 +306,7 @@ class HsmError extends BackendError {
|
|
|
431
306
|
}
|
|
432
307
|
}
|
|
433
308
|
exports.HsmError = HsmError;
|
|
434
|
-
/**
|
|
435
|
-
* ConfigError - Error in configuration settings
|
|
436
|
-
* Captures configuration-related issues
|
|
437
|
-
*/
|
|
309
|
+
/** Configuration error. */
|
|
438
310
|
class ConfigError extends Error {
|
|
439
311
|
constructor(message) {
|
|
440
312
|
super(message);
|
|
@@ -443,20 +315,43 @@ class ConfigError extends Error {
|
|
|
443
315
|
}
|
|
444
316
|
exports.ConfigError = ConfigError;
|
|
445
317
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
318
|
+
* Ogmios chain-sync frame that could not be parsed. Names the block (when readable from the raw
|
|
319
|
+
* text) so the crawler can fetch that one block through the paginating backend instead.
|
|
448
320
|
*/
|
|
321
|
+
/** The Ogmios chain-sync socket closed without being asked to (server-side failure or restart). */
|
|
322
|
+
class ChainSyncClosedError extends ProviderUnavailableError {
|
|
323
|
+
}
|
|
324
|
+
exports.ChainSyncClosedError = ChainSyncClosedError;
|
|
325
|
+
/** Chain-sync closed before delivering block `height`; the crawler fetches it over pagination. */
|
|
326
|
+
class ChainSyncStalledError extends BackendError {
|
|
327
|
+
height;
|
|
328
|
+
constructor(height, reason) {
|
|
329
|
+
super(`Ogmios chain-sync closed before delivering block ${height}: ${reason}`, 503, error_codes_1.ERROR_CODES.PROVIDER_UNAVAILABLE, 'ogmios');
|
|
330
|
+
this.height = height;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
exports.ChainSyncStalledError = ChainSyncStalledError;
|
|
334
|
+
class ChainSyncFrameError extends BackendError {
|
|
335
|
+
height;
|
|
336
|
+
id;
|
|
337
|
+
constructor(height, id, reason) {
|
|
338
|
+
super(`Ogmios chain-sync frame for block ${height ?? '?'} ${id ?? ''} could not be parsed: ${reason}`, 503, error_codes_1.ERROR_CODES.PROVIDER_UNAVAILABLE, 'ogmios');
|
|
339
|
+
this.height = height;
|
|
340
|
+
this.id = id;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
exports.ChainSyncFrameError = ChainSyncFrameError;
|
|
344
|
+
/** A backend failed to initialize. */
|
|
449
345
|
class BackendInitError extends BackendError {
|
|
450
346
|
constructor(backendName, originalError) {
|
|
451
|
-
super(
|
|
347
|
+
super(originalError != null
|
|
348
|
+
? `Failed to initialize backend: ${backendName} (${getErrorMessage(originalError)})`
|
|
349
|
+
: `Failed to initialize backend: ${backendName}`, 500, error_codes_1.ERROR_CODES.INTERNAL_ERROR, backendName, originalError);
|
|
452
350
|
this.name = 'BackendInitError';
|
|
453
351
|
}
|
|
454
352
|
}
|
|
455
353
|
exports.BackendInitError = BackendInitError;
|
|
456
|
-
/**
|
|
457
|
-
* AllBackendsInitFailedError - All backends failed to initialize
|
|
458
|
-
* Aggregates multiple backend initialization errors
|
|
459
|
-
*/
|
|
354
|
+
/** Every backend failed to initialize. */
|
|
460
355
|
class AllBackendsInitFailedError extends Error {
|
|
461
356
|
errors;
|
|
462
357
|
constructor(errors) {
|
|
@@ -469,34 +364,15 @@ class AllBackendsInitFailedError extends Error {
|
|
|
469
364
|
}
|
|
470
365
|
}
|
|
471
366
|
exports.AllBackendsInitFailedError = AllBackendsInitFailedError;
|
|
472
|
-
/**
|
|
473
|
-
* Function to reject requests with standardized error messages
|
|
474
|
-
* @param req - The incoming request
|
|
475
|
-
* @param ctx - Context string for the error
|
|
476
|
-
* @param message - Detailed error message
|
|
477
|
-
* @param target - Optional target resource
|
|
478
|
-
* @throws {BackendError} BackendError with 400 status code
|
|
479
|
-
*/
|
|
367
|
+
/** Throws a 400 INVALID_INPUT BackendError `<ctx>: <message>`. */
|
|
480
368
|
function rejectInvalid(req, ctx, message, target) {
|
|
481
369
|
throw new BackendError(`${ctx}: ${message}`, 400, error_codes_1.ERROR_CODES.INVALID_INPUT, undefined, undefined, target);
|
|
482
370
|
}
|
|
483
|
-
/**
|
|
484
|
-
* Function to reject requests for missing required fields
|
|
485
|
-
* @param req - The incoming request
|
|
486
|
-
* @param ctx - Context string for the error
|
|
487
|
-
* @param field - Name of the missing field
|
|
488
|
-
* @throws {BackendError} BackendError with 400 status code
|
|
489
|
-
*/
|
|
371
|
+
/** Throws a 400 INVALID_INPUT BackendError for a missing required field. */
|
|
490
372
|
function rejectMissing(req, ctx, field) {
|
|
491
373
|
throw new BackendError(`${ctx}: ${field} is required`, 400, error_codes_1.ERROR_CODES.INVALID_INPUT, undefined, undefined, field);
|
|
492
374
|
}
|
|
493
|
-
/**
|
|
494
|
-
* Throw BackendError for the first validation error in the list
|
|
495
|
-
* @param req - The incoming request
|
|
496
|
-
* @param ctx - Context string for the error
|
|
497
|
-
* @param errors - Array of validation errors from validateTransactionInputs
|
|
498
|
-
* @throws {BackendError} if errors array is not empty
|
|
499
|
-
*/
|
|
375
|
+
/** Throws a BackendError for the first validation error, if any. */
|
|
500
376
|
function throwIfValidationErrors(req, ctx, errors) {
|
|
501
377
|
if (errors.length === 0)
|
|
502
378
|
return;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unauthenticated liveness body for CardanoIndexerService.getLiveness(): process facts only,
|
|
3
|
+
* never touches app context, backends or DB, so it answers while those initialize or fail.
|
|
4
|
+
*/
|
|
5
|
+
export interface Liveness {
|
|
6
|
+
status: 'alive';
|
|
7
|
+
timestamp: string;
|
|
8
|
+
/** Seconds since the process started. */
|
|
9
|
+
uptime: number;
|
|
10
|
+
/** @odatano/core version; '' when package.json is not where the in-place build puts it. */
|
|
11
|
+
version: string;
|
|
12
|
+
/** Configured network (cds.requires.odatano-core.network, NETWORK, default preview). */
|
|
13
|
+
network: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildLiveness(now?: Date): Liveness;
|
|
16
|
+
//# sourceMappingURL=liveness.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unauthenticated liveness body for CardanoIndexerService.getLiveness(): process facts only,
|
|
4
|
+
* never touches app context, backends or DB, so it answers while those initialize or fail.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.buildLiveness = buildLiveness;
|
|
11
|
+
const cds_1 = __importDefault(require("@sap/cds"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const processStartedAt = Date.now();
|
|
14
|
+
let cachedVersion = null;
|
|
15
|
+
function packageVersion() {
|
|
16
|
+
if (cachedVersion !== null)
|
|
17
|
+
return cachedVersion;
|
|
18
|
+
try {
|
|
19
|
+
// srv/utils → package root; the in-place build keeps this path in plugin mode too.
|
|
20
|
+
const pkg = require(path_1.default.resolve(__dirname, '..', '..', 'package.json'));
|
|
21
|
+
cachedVersion = String(pkg.version ?? '');
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
cachedVersion = '';
|
|
25
|
+
}
|
|
26
|
+
return cachedVersion;
|
|
27
|
+
}
|
|
28
|
+
function buildLiveness(now = new Date()) {
|
|
29
|
+
const requires = (cds_1.default.env?.requires ?? {});
|
|
30
|
+
const core = (requires['odatano-core'] ?? {});
|
|
31
|
+
const network = String(core.network || process.env.NETWORK || 'preview');
|
|
32
|
+
return {
|
|
33
|
+
status: 'alive',
|
|
34
|
+
timestamp: now.toISOString(),
|
|
35
|
+
uptime: Math.max(0, Math.floor((now.getTime() - processStartedAt) / 1000)),
|
|
36
|
+
version: packageVersion(),
|
|
37
|
+
network,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=liveness.js.map
|