@odatano/core 2.0.0-rc.5 → 2.0.0-rc.51
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 +99 -51
- package/@cds-models/CardanoAgentService/index.js +15 -0
- package/@cds-models/CardanoBackendService/index.d.ts +358 -0
- package/@cds-models/CardanoBackendService/index.js +41 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +594 -11
- package/@cds-models/CardanoIndexerService/index.js +74 -0
- package/@cds-models/CardanoODataService/index.d.ts +417 -57
- package/@cds-models/CardanoODataService/index.js +42 -0
- package/@cds-models/CardanoSignService/index.d.ts +45 -19
- package/@cds-models/CardanoSignService/index.js +4 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +70 -44
- package/@cds-models/CardanoTransactionService/index.js +5 -0
- package/@cds-models/CardanoWorkerService/index.d.ts +35 -22
- package/@cds-models/CardanoWorkerService/index.js +2 -0
- package/@cds-models/index.d.ts +114 -4
- package/@cds-models/index.js +20 -4
- package/@cds-models/odatano/cardano/index.d.ts +451 -32
- package/@cds-models/odatano/cardano/index.js +48 -0
- package/README.md +103 -167
- package/db/schema.cds +2455 -1705
- package/db/types.cds +456 -295
- package/package.json +41 -53
- package/scripts/deploy-schema.mjs +113 -0
- package/scripts/migrate-schema.mjs +528 -0
- package/scripts/migrate-slot-leader.mjs +96 -0
- package/src/index.d.ts +20 -21
- package/src/index.js +45 -31
- package/src/plugin.js +17 -35
- package/srv/blockchain/asset-decimals.d.ts +7 -0
- package/srv/blockchain/asset-decimals.js +91 -0
- package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -137
- package/srv/blockchain/backends/blockfrost-backend.js +125 -215
- package/srv/blockchain/backends/call-signal.d.ts +7 -0
- package/srv/blockchain/backends/call-signal.js +22 -0
- package/srv/blockchain/backends/cardano-backend.d.ts +100 -189
- package/srv/blockchain/backends/cardano-backend.js +29 -5
- package/srv/blockchain/backends/koios-backend.d.ts +108 -170
- package/srv/blockchain/backends/koios-backend.js +488 -482
- package/srv/blockchain/backends/odatano-backend.d.ts +55 -0
- package/srv/blockchain/backends/odatano-backend.js +211 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +122 -190
- package/srv/blockchain/backends/ogmios-backend.js +683 -327
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
- package/srv/blockchain/cardano-client.d.ts +71 -241
- package/srv/blockchain/cardano-client.js +354 -322
- package/srv/blockchain/cardano-indexer.d.ts +295 -283
- package/srv/blockchain/cardano-indexer.js +1690 -502
- package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
- package/srv/blockchain/cardano-tx-builder.js +164 -140
- package/srv/blockchain/circuit-breaker.d.ts +2 -13
- package/srv/blockchain/circuit-breaker.js +11 -15
- package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
- package/srv/blockchain/crawler/account-snapshots.js +173 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +17 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
- package/srv/blockchain/crawler/asset-registry-backfill.d.ts +46 -0
- package/srv/blockchain/crawler/asset-registry-backfill.js +157 -0
- package/srv/blockchain/crawler/asset-slice-backfill.d.ts +35 -0
- package/srv/blockchain/crawler/asset-slice-backfill.js +149 -0
- package/srv/blockchain/crawler/certificate-backfill.d.ts +56 -0
- package/srv/blockchain/crawler/certificate-backfill.js +174 -0
- package/srv/blockchain/crawler/crawler.d.ts +125 -81
- package/srv/blockchain/crawler/crawler.js +738 -167
- package/srv/blockchain/crawler/credential-backfill.d.ts +30 -0
- package/srv/blockchain/crawler/credential-backfill.js +101 -0
- package/srv/blockchain/crawler/hooks.d.ts +2 -17
- package/srv/blockchain/crawler/index.d.ts +1 -8
- package/srv/blockchain/crawler/index.js +31 -17
- package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
- package/srv/blockchain/crawler/input-asset-copies.js +161 -0
- package/srv/blockchain/crawler/key-pages.d.ts +12 -0
- package/srv/blockchain/crawler/key-pages.js +48 -0
- package/srv/blockchain/crawler/metadata-position-backfill.d.ts +22 -0
- package/srv/blockchain/crawler/metadata-position-backfill.js +59 -0
- package/srv/blockchain/crawler/output-datum-backfill.d.ts +41 -0
- package/srv/blockchain/crawler/output-datum-backfill.js +100 -0
- package/srv/blockchain/crawler/sync-state.d.ts +31 -47
- package/srv/blockchain/crawler/sync-state.js +135 -128
- package/srv/blockchain/crawler/transaction-backfill.d.ts +46 -0
- package/srv/blockchain/crawler/transaction-backfill.js +271 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
- package/srv/blockchain/crawler/utxo-set-import.js +399 -0
- package/srv/blockchain/crawler/window-plan.d.ts +31 -0
- package/srv/blockchain/crawler/window-plan.js +59 -0
- package/srv/blockchain/ledger-state.d.ts +62 -0
- package/srv/blockchain/ledger-state.js +521 -0
- package/srv/blockchain/pending-spends.d.ts +16 -0
- package/srv/blockchain/pending-spends.js +81 -0
- package/srv/blockchain/pool-metadata.d.ts +15 -0
- package/srv/blockchain/pool-metadata.js +132 -0
- package/srv/blockchain/request-coalescer.d.ts +2 -16
- package/srv/blockchain/request-coalescer.js +2 -16
- package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
- package/srv/blockchain/signing/cose-verifier.js +146 -70
- package/srv/blockchain/signing/external-signer.d.ts +15 -115
- package/srv/blockchain/signing/external-signer.js +22 -131
- package/srv/blockchain/signing/failed-recheck.d.ts +17 -0
- package/srv/blockchain/signing/failed-recheck.js +135 -0
- package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
- package/srv/blockchain/signing/hsm-signer.js +28 -79
- package/srv/blockchain/signing/landing-proof.d.ts +60 -0
- package/srv/blockchain/signing/landing-proof.js +224 -0
- package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
- package/srv/blockchain/signing/signature-verifier.js +71 -87
- package/srv/blockchain/signing/submission-finalizer.d.ts +37 -45
- package/srv/blockchain/signing/submission-finalizer.js +280 -86
- package/srv/blockchain/stored-chain.d.ts +19 -0
- package/srv/blockchain/stored-chain.js +258 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
- package/srv/blockchain/transaction-building/buildooor-tx.js +663 -421
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
- package/srv/blockchain/transaction-presence.d.ts +12 -0
- package/srv/blockchain/transaction-presence.js +29 -0
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +44 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +8 -23
- package/srv/blockchain/wallet-worker/build-request.js +40 -353
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +27 -47
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +158 -61
- package/srv/blockchain/wallet-worker/index.d.ts +1 -1
- package/srv/blockchain/wallet-worker/index.js +3 -11
- package/srv/blockchain/wallet-worker/invalidation.d.ts +35 -0
- package/srv/blockchain/wallet-worker/invalidation.js +128 -0
- package/srv/blockchain/wallet-worker/job-store.d.ts +58 -150
- package/srv/blockchain/wallet-worker/job-store.js +200 -273
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
- package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
- package/srv/blockchain/wallet-worker/signers.js +4 -12
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +29 -82
- package/srv/blockchain/wallet-worker/wallet-worker.js +334 -198
- package/srv/cardano-agent-service.cds +122 -84
- package/srv/cardano-agent-service.js +12 -9
- package/srv/cardano-backend-service.cds +81 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +259 -0
- package/srv/cardano-indexer-service.cds +393 -18
- package/srv/cardano-indexer-service.d.ts +5 -1
- package/srv/cardano-indexer-service.js +477 -16
- package/srv/cardano-service.cds +426 -269
- package/srv/cardano-service.js +640 -217
- package/srv/cardano-sign-service.cds +211 -180
- package/srv/cardano-sign-service.js +210 -287
- package/srv/cardano-tx-service.cds +462 -370
- package/srv/cardano-tx-service.js +283 -800
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.cds +141 -125
- package/srv/cardano-worker-service.js +104 -61
- package/srv/cbor/cip68.d.ts +13 -0
- package/srv/cbor/cip68.js +56 -0
- package/srv/cbor/index.d.ts +3 -1
- package/srv/cbor/index.js +9 -1
- package/srv/cbor/parse.d.ts +30 -18
- package/srv/cbor/parse.js +44 -9
- package/srv/cbor/plutus-data-json.d.ts +20 -0
- package/srv/cbor/plutus-data-json.js +32 -0
- package/srv/config.d.ts +117 -0
- package/srv/config.js +419 -0
- package/srv/server.d.ts +15 -110
- package/srv/server.js +83 -405
- package/srv/utils/agent-access.d.ts +11 -0
- package/srv/utils/agent-access.js +86 -0
- package/srv/utils/agent-grants-config.d.ts +0 -46
- package/srv/utils/agent-grants-config.js +17 -85
- package/srv/utils/agent-grants.d.ts +106 -122
- package/srv/utils/agent-grants.js +538 -237
- package/srv/utils/agent-token-auth.d.ts +4 -99
- package/srv/utils/agent-token-auth.js +62 -186
- package/srv/utils/backend-request-handler.d.ts +3 -17
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/build-request.d.ts +52 -0
- package/srv/utils/build-request.js +487 -0
- package/srv/utils/collections.d.ts +4 -10
- package/srv/utils/collections.js +14 -10
- package/srv/utils/const.d.ts +32 -75
- package/srv/utils/const.js +40 -80
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +11 -25
- package/srv/utils/db-indexes.d.ts +31 -0
- package/srv/utils/db-indexes.js +185 -0
- package/srv/utils/db-kind.d.ts +23 -0
- package/srv/utils/db-kind.js +42 -0
- package/srv/utils/db-sanitize.d.ts +20 -0
- package/srv/utils/db-sanitize.js +80 -0
- package/srv/utils/deep-json.d.ts +6 -0
- package/srv/utils/deep-json.js +240 -0
- package/srv/utils/detached-run.d.ts +41 -0
- package/srv/utils/detached-run.js +101 -0
- package/srv/utils/epoch-slots.d.ts +14 -0
- package/srv/utils/epoch-slots.js +45 -0
- package/srv/utils/error-codes.d.ts +26 -75
- package/srv/utils/error-codes.js +27 -72
- package/srv/utils/errors.d.ts +55 -187
- package/srv/utils/errors.js +161 -235
- package/srv/utils/lease.d.ts +20 -0
- package/srv/utils/lease.js +62 -0
- package/srv/utils/liveness.d.ts +12 -0
- package/srv/utils/liveness.js +35 -0
- package/srv/utils/mappers.d.ts +111 -223
- package/srv/utils/mappers.js +432 -371
- package/srv/utils/navigation.d.ts +17 -0
- package/srv/utils/navigation.js +52 -0
- package/srv/utils/network-context.d.ts +0 -1
- package/srv/utils/network-context.js +9 -15
- package/srv/utils/paging.d.ts +31 -0
- package/srv/utils/paging.js +43 -0
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +58 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +54 -0
- package/srv/utils/plutus-placeholders.d.ts +16 -22
- package/srv/utils/plutus-placeholders.js +62 -33
- package/srv/utils/rate-limiter.d.ts +2 -21
- package/srv/utils/rate-limiter.js +5 -17
- package/srv/utils/readiness.d.ts +12 -0
- package/srv/utils/readiness.js +29 -0
- package/srv/utils/reference-script.d.ts +19 -0
- package/srv/utils/reference-script.js +84 -0
- package/srv/utils/resolution.d.ts +13 -0
- package/srv/utils/resolution.js +47 -0
- package/srv/utils/result-numbers.d.ts +15 -0
- package/srv/utils/result-numbers.js +61 -0
- package/srv/utils/row-values.d.ts +7 -0
- package/srv/utils/row-values.js +27 -0
- package/srv/utils/service-events.d.ts +0 -24
- package/srv/utils/service-events.js +3 -25
- package/srv/utils/signing-helper.d.ts +3 -20
- package/srv/utils/signing-helper.js +35 -64
- package/srv/utils/tx-build-helper.d.ts +25 -105
- package/srv/utils/tx-build-helper.js +108 -156
- package/srv/utils/tx-request-parsers.d.ts +82 -33
- package/srv/utils/tx-request-parsers.js +401 -49
- package/srv/utils/tx-utils.d.ts +3 -27
- package/srv/utils/tx-utils.js +32 -50
- package/srv/utils/types.d.ts +294 -232
- package/srv/utils/types.js +2 -22
- package/srv/utils/validators.d.ts +22 -92
- package/srv/utils/validators.js +60 -170
package/srv/utils/tx-utils.js
CHANGED
|
@@ -5,38 +5,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DETACHED_TX_TIMEOUT_MS = void 0;
|
|
7
7
|
exports.runWithoutAmbientTx = runWithoutAmbientTx;
|
|
8
|
+
exports.holdsConnection = holdsConnection;
|
|
9
|
+
exports.readOutside = readOutside;
|
|
8
10
|
exports.detachedTx = detachedTx;
|
|
9
11
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
10
12
|
const errors_1 = require("./errors");
|
|
13
|
+
const config_1 = require("../config");
|
|
11
14
|
const error_codes_1 = require("./error-codes");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* Context: @cap-js/sqlite runs on a SINGLE pooled connection. A request
|
|
16
|
-
* transaction begins lazily on its first CQL statement and holds that
|
|
17
|
-
* connection until the request commits. Any code that then needs a NEW ROOT
|
|
18
|
-
* transaction (detached committed bookkeeping) waits on the pool — forever,
|
|
19
|
-
* if the waiter is awaited by the very request holding the connection
|
|
20
|
-
* (docs/KNOWN_ISSUES.md issue 11).
|
|
21
|
-
*/
|
|
15
|
+
// @cap-js/sqlite has a single pooled connection held by the request transaction.
|
|
16
|
+
// A new root transaction awaited by that request would wait forever.
|
|
22
17
|
const logger = cds_1.default.log('tx-utils');
|
|
23
18
|
/** Default acquire budget for detached bookkeeping transactions. */
|
|
24
19
|
exports.DETACHED_TX_TIMEOUT_MS = 10_000;
|
|
25
|
-
/** Effective timeout: env override (ODATANO_DETACHED_TX_TIMEOUT_MS) > default. Read per call so tests can tune it. */
|
|
26
20
|
function effectiveTimeoutMs() {
|
|
27
|
-
|
|
28
|
-
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : exports.DETACHED_TX_TIMEOUT_MS;
|
|
21
|
+
return (0, config_1.detachedTxTimeoutMs)() ?? exports.DETACHED_TX_TIMEOUT_MS;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* fresh short-lived transaction instead of joining a long-lived ambient one.
|
|
33
|
-
* Under @cap-js/sqlite (pool.max=1) this is what keeps the single pooled
|
|
34
|
-
* connection free during long awaits (NIGHTGATE lesson 2; used by the
|
|
35
|
-
* wallet-worker job loops).
|
|
36
|
-
*/
|
|
23
|
+
// Clears cds.context so inner db.run calls use short transactions instead of joining an ambient one.
|
|
24
|
+
// This keeps the single SQLite connection free during long awaits.
|
|
37
25
|
function runWithoutAmbientTx(fn) {
|
|
38
26
|
return cds_1.default._with(undefined, fn);
|
|
39
27
|
}
|
|
28
|
+
/** True once the transaction has taken its database connection. */
|
|
29
|
+
function holdsConnection(tx) {
|
|
30
|
+
const state = tx;
|
|
31
|
+
return Boolean(state && (state.dbc || state.ready));
|
|
32
|
+
}
|
|
33
|
+
// Database reads that come before a provider call. An idle transaction stays idle: the read runs in
|
|
34
|
+
// a short transaction of its own, so no connection is held while the provider answers.
|
|
35
|
+
// A transaction that already holds its connection does the read itself.
|
|
36
|
+
function readOutside(tx, read) {
|
|
37
|
+
const idle = typeof tx.begin === 'function' && !holdsConnection(tx);
|
|
38
|
+
// cds.tx resolves to what the callback resolves to; its typing wraps that in a second promise
|
|
39
|
+
return idle ? runWithoutAmbientTx(async () => await cds_1.default.tx(read)) : read(tx);
|
|
40
|
+
}
|
|
40
41
|
/** Thrown inside an orphaned `cds.tx` callback after its caller already timed out. */
|
|
41
42
|
class DetachedTxAbortedError extends Error {
|
|
42
43
|
constructor(label) {
|
|
@@ -44,38 +45,21 @@ class DetachedTxAbortedError extends Error {
|
|
|
44
45
|
this.name = 'DetachedTxAbortedError';
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
* instead of hanging forever when no pooled connection becomes available.
|
|
50
|
-
*
|
|
51
|
-
* Why: the sign-service must commit its submit bookkeeping (claim, finalize,
|
|
52
|
-
* failure marker) independently of the caller's request transaction. When an
|
|
53
|
-
* in-process consumer awaits the action while its own request transaction
|
|
54
|
-
* holds the single pooled sqlite connection, the acquire can never succeed —
|
|
55
|
-
* without this guard that is a silent, zero-CPU, infinite hang.
|
|
56
|
-
*
|
|
57
|
-
* Guarantees:
|
|
58
|
-
* - On timeout, throws `BackendError` 503 `ODATANO_NESTED_TX_TIMEOUT` with a
|
|
59
|
-
* diagnosis pointing at KNOWN_ISSUES #11.
|
|
60
|
-
* - A late connection grant (after the timeout already fired) performs NO
|
|
61
|
-
* work: the callback forces the acquire via an explicit `begin()` and
|
|
62
|
-
* checks the abort flag right after it, so it rolls back immediately and
|
|
63
|
-
* the caller never observes an error for work that then silently happened
|
|
64
|
-
* anyway. (A flag check at callback ENTRY would run long before the lazy
|
|
65
|
-
* acquire and miss the timeout.)
|
|
66
|
-
*/
|
|
48
|
+
// New root transaction with a deadlock guard. Throws 503 ODATANO_NESTED_TX_TIMEOUT when no
|
|
49
|
+
// connection arrives in time. A connection granted after the timeout does no work.
|
|
67
50
|
async function detachedTx(label, fn, timeoutMs) {
|
|
68
51
|
const effectiveTimeout = timeoutMs ?? effectiveTimeoutMs();
|
|
69
52
|
let timedOut = false;
|
|
70
53
|
let timer;
|
|
71
54
|
const work = cds_1.default.tx(async (db) => {
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
// the abort flag — a late grant (after the caller already received the
|
|
75
|
-
// timeout error) must roll back before doing any work.
|
|
55
|
+
// The connection is acquired lazily by the first statement: force it now, then check the abort
|
|
56
|
+
// flag so a grant after the timeout rolls back before doing any work.
|
|
76
57
|
await db.begin();
|
|
77
58
|
if (timedOut)
|
|
78
59
|
throw new DetachedTxAbortedError(label);
|
|
60
|
+
// the timeout bounds the acquire only; once begun, the work runs to its own commit
|
|
61
|
+
if (timer)
|
|
62
|
+
clearTimeout(timer);
|
|
79
63
|
return fn(db);
|
|
80
64
|
});
|
|
81
65
|
const guard = new Promise((_, reject) => {
|
|
@@ -83,9 +67,9 @@ async function detachedTx(label, fn, timeoutMs) {
|
|
|
83
67
|
timedOut = true;
|
|
84
68
|
reject(new errors_1.BackendError(`${label}: could not begin a detached DB transaction within ${effectiveTimeout}ms. ` +
|
|
85
69
|
`Most likely the calling request still holds the pooled DB connection open ` +
|
|
86
|
-
`(in-process nested call
|
|
87
|
-
`transaction is open; detach your reads into a committed cds.tx first
|
|
88
|
-
`
|
|
70
|
+
`(in-process nested call: do not await this action while your request ` +
|
|
71
|
+
`transaction is open; detach your reads into a committed cds.tx first). ` +
|
|
72
|
+
`Alternatively the connection pool is exhausted.`, 503, error_codes_1.ERROR_CODES.NESTED_TX_TIMEOUT));
|
|
89
73
|
}, effectiveTimeout);
|
|
90
74
|
});
|
|
91
75
|
try {
|
|
@@ -95,9 +79,7 @@ async function detachedTx(label, fn, timeoutMs) {
|
|
|
95
79
|
if (timer)
|
|
96
80
|
clearTimeout(timer);
|
|
97
81
|
if (timedOut) {
|
|
98
|
-
// The orphaned acquire may still be granted
|
|
99
|
-
// itself via the flag. Observe the rejection so it never surfaces as an
|
|
100
|
-
// unhandled promise rejection.
|
|
82
|
+
// The orphaned acquire may still be granted; observe its rejection so it is never unhandled.
|
|
101
83
|
work.catch((e) => {
|
|
102
84
|
if (!(e instanceof DetachedTxAbortedError)) {
|
|
103
85
|
logger.warn(`Orphaned detached tx '${label}' failed after timeout: ${e instanceof Error ? e.message : String(e)}`);
|