camusdb 0.1.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/LICENSE +21 -0
- package/README.md +950 -0
- package/dist/auth/credentials.d.ts +30 -0
- package/dist/auth/credentials.d.ts.map +1 -0
- package/dist/auth/credentials.js +23 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/login-client.d.ts +37 -0
- package/dist/auth/login-client.d.ts.map +1 -0
- package/dist/auth/login-client.js +8 -0
- package/dist/auth/login-client.js.map +1 -0
- package/dist/auth/rest-login-client.d.ts +17 -0
- package/dist/auth/rest-login-client.d.ts.map +1 -0
- package/dist/auth/rest-login-client.js +71 -0
- package/dist/auth/rest-login-client.js.map +1 -0
- package/dist/auth/token-provider.d.ts +123 -0
- package/dist/auth/token-provider.d.ts.map +1 -0
- package/dist/auth/token-provider.js +209 -0
- package/dist/auth/token-provider.js.map +1 -0
- package/dist/backup.d.ts +98 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +153 -0
- package/dist/backup.js.map +1 -0
- package/dist/cache.d.ts +90 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +121 -0
- package/dist/cache.js.map +1 -0
- package/dist/client.d.ts +406 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +724 -0
- package/dist/client.js.map +1 -0
- package/dist/column-type.d.ts +33 -0
- package/dist/column-type.d.ts.map +1 -0
- package/dist/column-type.js +50 -0
- package/dist/column-type.js.map +1 -0
- package/dist/column-value.d.ts +77 -0
- package/dist/column-value.d.ts.map +1 -0
- package/dist/column-value.js +60 -0
- package/dist/column-value.js.map +1 -0
- package/dist/config.d.ts +181 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +315 -0
- package/dist/config.js.map +1 -0
- package/dist/connection-string.d.ts +45 -0
- package/dist/connection-string.d.ts.map +1 -0
- package/dist/connection-string.js +170 -0
- package/dist/connection-string.js.map +1 -0
- package/dist/endpoint-pool.d.ts +70 -0
- package/dist/endpoint-pool.d.ts.map +1 -0
- package/dist/endpoint-pool.js +120 -0
- package/dist/endpoint-pool.js.map +1 -0
- package/dist/error-codes.d.ts +44 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +43 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +33 -0
- package/dist/errors.js.map +1 -0
- package/dist/hlc.d.ts +19 -0
- package/dist/hlc.d.ts.map +1 -0
- package/dist/hlc.js +11 -0
- package/dist/hlc.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +41 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +345 -0
- package/dist/json.js.map +1 -0
- package/dist/object-id.d.ts +39 -0
- package/dist/object-id.d.ts.map +1 -0
- package/dist/object-id.js +99 -0
- package/dist/object-id.js.map +1 -0
- package/dist/options.d.ts +77 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +68 -0
- package/dist/options.js.map +1 -0
- package/dist/prepared/binder.d.ts +20 -0
- package/dist/prepared/binder.d.ts.map +1 -0
- package/dist/prepared/binder.js +32 -0
- package/dist/prepared/binder.js.map +1 -0
- package/dist/prepared/policy.d.ts +81 -0
- package/dist/prepared/policy.d.ts.map +1 -0
- package/dist/prepared/policy.js +164 -0
- package/dist/prepared/policy.js.map +1 -0
- package/dist/query-stream.d.ts +55 -0
- package/dist/query-stream.d.ts.map +1 -0
- package/dist/query-stream.js +94 -0
- package/dist/query-stream.js.map +1 -0
- package/dist/result-set.d.ts +62 -0
- package/dist/result-set.d.ts.map +1 -0
- package/dist/result-set.js +100 -0
- package/dist/result-set.js.map +1 -0
- package/dist/retry.d.ts +38 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +93 -0
- package/dist/retry.js.map +1 -0
- package/dist/routing/advice.d.ts +63 -0
- package/dist/routing/advice.d.ts.map +1 -0
- package/dist/routing/advice.js +61 -0
- package/dist/routing/advice.js.map +1 -0
- package/dist/routing/route-cache.d.ts +53 -0
- package/dist/routing/route-cache.d.ts.map +1 -0
- package/dist/routing/route-cache.js +123 -0
- package/dist/routing/route-cache.js.map +1 -0
- package/dist/routing/router.d.ts +53 -0
- package/dist/routing/router.d.ts.map +1 -0
- package/dist/routing/router.js +89 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/row-source.d.ts +48 -0
- package/dist/row-source.d.ts.map +1 -0
- package/dist/row-source.js +35 -0
- package/dist/row-source.js.map +1 -0
- package/dist/runtime.d.ts +58 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +137 -0
- package/dist/runtime.js.map +1 -0
- package/dist/shared-registry.d.ts +32 -0
- package/dist/shared-registry.d.ts.map +1 -0
- package/dist/shared-registry.js +48 -0
- package/dist/shared-registry.js.map +1 -0
- package/dist/sql-syntax.d.ts +44 -0
- package/dist/sql-syntax.d.ts.map +1 -0
- package/dist/sql-syntax.js +83 -0
- package/dist/sql-syntax.js.map +1 -0
- package/dist/statements.d.ts +15 -0
- package/dist/statements.d.ts.map +1 -0
- package/dist/statements.js +90 -0
- package/dist/statements.js.map +1 -0
- package/dist/transaction.d.ts +117 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +204 -0
- package/dist/transaction.js.map +1 -0
- package/dist/transport/authenticating-transport.d.ts +63 -0
- package/dist/transport/authenticating-transport.d.ts.map +1 -0
- package/dist/transport/authenticating-transport.js +119 -0
- package/dist/transport/authenticating-transport.js.map +1 -0
- package/dist/transport/branch-statements.d.ts +39 -0
- package/dist/transport/branch-statements.d.ts.map +1 -0
- package/dist/transport/branch-statements.js +74 -0
- package/dist/transport/branch-statements.js.map +1 -0
- package/dist/transport/error-text.d.ts +26 -0
- package/dist/transport/error-text.d.ts.map +1 -0
- package/dist/transport/error-text.js +75 -0
- package/dist/transport/error-text.js.map +1 -0
- package/dist/transport/grpc/batcher.d.ts +127 -0
- package/dist/transport/grpc/batcher.d.ts.map +1 -0
- package/dist/transport/grpc/batcher.js +399 -0
- package/dist/transport/grpc/batcher.js.map +1 -0
- package/dist/transport/grpc/codec.d.ts +40 -0
- package/dist/transport/grpc/codec.d.ts.map +1 -0
- package/dist/transport/grpc/codec.js +231 -0
- package/dist/transport/grpc/codec.js.map +1 -0
- package/dist/transport/grpc/grpc-transport.d.ts +115 -0
- package/dist/transport/grpc/grpc-transport.d.ts.map +1 -0
- package/dist/transport/grpc/grpc-transport.js +577 -0
- package/dist/transport/grpc/grpc-transport.js.map +1 -0
- package/dist/transport/grpc/messages.d.ts +221 -0
- package/dist/transport/grpc/messages.d.ts.map +1 -0
- package/dist/transport/grpc/messages.js +56 -0
- package/dist/transport/grpc/messages.js.map +1 -0
- package/dist/transport/grpc/proto.d.ts +71 -0
- package/dist/transport/grpc/proto.d.ts.map +1 -0
- package/dist/transport/grpc/proto.js +67 -0
- package/dist/transport/grpc/proto.js.map +1 -0
- package/dist/transport/http.d.ts +62 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +169 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/ndjson-row-source.d.ts +38 -0
- package/dist/transport/ndjson-row-source.d.ts.map +1 -0
- package/dist/transport/ndjson-row-source.js +197 -0
- package/dist/transport/ndjson-row-source.js.map +1 -0
- package/dist/transport/rest-decode.d.ts +33 -0
- package/dist/transport/rest-decode.d.ts.map +1 -0
- package/dist/transport/rest-decode.js +162 -0
- package/dist/transport/rest-decode.js.map +1 -0
- package/dist/transport/rest-prepared-cache.d.ts +50 -0
- package/dist/transport/rest-prepared-cache.d.ts.map +1 -0
- package/dist/transport/rest-prepared-cache.js +101 -0
- package/dist/transport/rest-prepared-cache.js.map +1 -0
- package/dist/transport/rest-transport.d.ts +88 -0
- package/dist/transport/rest-transport.d.ts.map +1 -0
- package/dist/transport/rest-transport.js +388 -0
- package/dist/transport/rest-transport.js.map +1 -0
- package/dist/transport/transport-pool.d.ts +40 -0
- package/dist/transport/transport-pool.d.ts.map +1 -0
- package/dist/transport/transport-pool.js +48 -0
- package/dist/transport/transport-pool.js.map +1 -0
- package/dist/transport/transport.d.ts +199 -0
- package/dist/transport/transport.d.ts.map +1 -0
- package/dist/transport/transport.js +11 -0
- package/dist/transport/transport.js.map +1 -0
- package/dist/values/decode.d.ts +39 -0
- package/dist/values/decode.d.ts.map +1 -0
- package/dist/values/decode.js +75 -0
- package/dist/values/decode.js.map +1 -0
- package/dist/values/encode.d.ts +45 -0
- package/dist/values/encode.d.ts.map +1 -0
- package/dist/values/encode.js +271 -0
- package/dist/values/encode.js.map +1 -0
- package/dist/values/ticks.d.ts +31 -0
- package/dist/values/ticks.d.ts.map +1 -0
- package/dist/values/ticks.js +52 -0
- package/dist/values/ticks.js.map +1 -0
- package/dist/values/typed.d.ts +67 -0
- package/dist/values/typed.d.ts.map +1 -0
- package/dist/values/typed.js +134 -0
- package/dist/values/typed.js.map +1 -0
- package/dist/values/uuid.d.ts +27 -0
- package/dist/values/uuid.d.ts.map +1 -0
- package/dist/values/uuid.js +76 -0
- package/dist/values/uuid.js.map +1 -0
- package/dist/vector.d.ts +26 -0
- package/dist/vector.d.ts.map +1 -0
- package/dist/vector.js +48 -0
- package/dist/vector.js.map +1 -0
- package/package.json +86 -0
- package/proto/camus_sql.proto +566 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of CamusDB
|
|
3
|
+
*
|
|
4
|
+
* For the full copyright and license information, please view the LICENSE.txt
|
|
5
|
+
* file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
import type { CamusCacheMetadata } from '../cache.js';
|
|
8
|
+
import type { ColumnValue } from '../column-value.js';
|
|
9
|
+
import type { CamusProtocol } from '../config.js';
|
|
10
|
+
import type { CamusTransactionOptions } from '../options.js';
|
|
11
|
+
import type { CamusResultSet } from '../result-set.js';
|
|
12
|
+
import type { CamusRoutingAdvice } from '../routing/advice.js';
|
|
13
|
+
import type { CamusRowSource } from '../row-source.js';
|
|
14
|
+
/** One row of `SHOW BRANCHES` or `SHOW ANCESTORS`. */
|
|
15
|
+
export interface CamusBranchRow {
|
|
16
|
+
readonly database?: string | undefined;
|
|
17
|
+
readonly id?: string | undefined;
|
|
18
|
+
readonly depth: number;
|
|
19
|
+
readonly parent?: string | undefined;
|
|
20
|
+
readonly forkTimestamp?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A SQL request handed to a transport, in terms neither protocol owns.
|
|
24
|
+
*
|
|
25
|
+
* It carries everything a transport needs to run one statement: the resolved endpoint, the
|
|
26
|
+
* database, the SQL text, the bound parameters, and either the explicit transaction handle to join
|
|
27
|
+
* or the autocommit concurrency options the server should begin this statement's own short
|
|
28
|
+
* transaction with.
|
|
29
|
+
*/
|
|
30
|
+
export interface TransportSqlRequest {
|
|
31
|
+
readonly endpoint: string;
|
|
32
|
+
readonly database: string;
|
|
33
|
+
readonly sql: string;
|
|
34
|
+
readonly parameters?: ReadonlyMap<string, ColumnValue> | undefined;
|
|
35
|
+
/** The explicit transaction to resume. When set, `autocommitOptions` is ignored. */
|
|
36
|
+
readonly txnIdPT?: bigint | undefined;
|
|
37
|
+
readonly txnIdCounter?: number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Concurrency options for the short transaction the server begins for this statement. They apply
|
|
40
|
+
* only when there is no explicit transaction, and are absent on the read-query path, which has
|
|
41
|
+
* no locking mode.
|
|
42
|
+
*/
|
|
43
|
+
readonly autocommitOptions?: CamusTransactionOptions | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* An opaque transport routing hint. For the gRPC batching transport it is the reserved
|
|
46
|
+
* `BatchExecute` stream slot a transaction's operations pin to, so the server orders them. The
|
|
47
|
+
* REST transport ignores it.
|
|
48
|
+
*/
|
|
49
|
+
readonly streamSlot?: number | undefined;
|
|
50
|
+
readonly timeoutSeconds: number;
|
|
51
|
+
/**
|
|
52
|
+
* Run this statement as a prepared execution: the transport registers the SQL once, or reuses a
|
|
53
|
+
* registration it already holds, then sends only the handle and the values in the server's
|
|
54
|
+
* published binding order.
|
|
55
|
+
*
|
|
56
|
+
* It is a hint, not a demand. How a handle is scoped, invalidated, and replayed is the
|
|
57
|
+
* transport's business, and a transport that cannot prepare this statement runs it inline
|
|
58
|
+
* instead, with identical semantics.
|
|
59
|
+
*/
|
|
60
|
+
readonly prepared: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The highest routing-metadata version the caller accepts on this statement's response. Zero,
|
|
63
|
+
* the default, asks for none and keeps the exact pre-routing wire shape.
|
|
64
|
+
*/
|
|
65
|
+
readonly routingAcceptVersion: number;
|
|
66
|
+
readonly signal?: AbortSignal | undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A row insert handed to a transport.
|
|
70
|
+
*
|
|
71
|
+
* The typed row-level insert names a table and a column-to-value map rather than SQL text, so it
|
|
72
|
+
* cannot ride `TransportSqlRequest`. It is otherwise an ordinary statement, and goes through the
|
|
73
|
+
* same transport, and therefore the same authorization, endpoint health, and error translation, as
|
|
74
|
+
* everything else.
|
|
75
|
+
*/
|
|
76
|
+
export interface TransportInsertRequest {
|
|
77
|
+
readonly endpoint: string;
|
|
78
|
+
readonly database: string;
|
|
79
|
+
readonly table: string;
|
|
80
|
+
readonly values?: ReadonlyMap<string, ColumnValue> | undefined;
|
|
81
|
+
readonly txnIdPT?: bigint | undefined;
|
|
82
|
+
readonly txnIdCounter?: number | undefined;
|
|
83
|
+
readonly streamSlot?: number | undefined;
|
|
84
|
+
readonly timeoutSeconds: number;
|
|
85
|
+
readonly signal?: AbortSignal | undefined;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The identity the server minted for a transaction, plus the opaque stream slot its later
|
|
89
|
+
* operations must pin to. The slot is absent for a transport that does not pin.
|
|
90
|
+
*/
|
|
91
|
+
export interface StartTransactionResult {
|
|
92
|
+
readonly txnIdPT: bigint;
|
|
93
|
+
readonly txnIdCounter: number;
|
|
94
|
+
readonly streamSlot?: number | undefined;
|
|
95
|
+
}
|
|
96
|
+
/** A decoded query result, plus whatever advisory metadata the response carried. */
|
|
97
|
+
export interface QueryTransportResult {
|
|
98
|
+
readonly resultSet: CamusResultSet;
|
|
99
|
+
readonly cacheMetadata?: CamusCacheMetadata | undefined;
|
|
100
|
+
readonly routing?: CamusRoutingAdvice | undefined;
|
|
101
|
+
}
|
|
102
|
+
/** The affected-row count of a write statement, plus any routing advice its response carried. */
|
|
103
|
+
export interface NonQueryTransportResult {
|
|
104
|
+
readonly affectedRows: number;
|
|
105
|
+
readonly routing?: CamusRoutingAdvice | undefined;
|
|
106
|
+
}
|
|
107
|
+
/** A statement the server registered: the placeholder names it declares, in binding order. */
|
|
108
|
+
export interface PreparedStatementInfo {
|
|
109
|
+
readonly parameterNames: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The seam between the client surface and the wire protocol.
|
|
113
|
+
*
|
|
114
|
+
* One implementation speaks REST and JSON, another speaks gRPC. The client layer is
|
|
115
|
+
* protocol-agnostic and works entirely in CamusDB domain types whichever one is chosen.
|
|
116
|
+
*
|
|
117
|
+
* Every method performs exactly one round trip and turns a protocol-level failure into a
|
|
118
|
+
* `CamusError` carrying the server's `CADBxxxx` code. Retry policies that do not depend on the
|
|
119
|
+
* protocol — the `CADB0509` finalize loop, the transient create-database loop — stay in the client
|
|
120
|
+
* layer, so each transport call is a single attempt.
|
|
121
|
+
*/
|
|
122
|
+
export interface CamusTransport {
|
|
123
|
+
/** The protocol this transport implements. */
|
|
124
|
+
readonly protocol: CamusProtocol;
|
|
125
|
+
/** Begins an explicit transaction and reports the handle the server minted. */
|
|
126
|
+
startTransaction(endpoint: string, database: string, options: CamusTransactionOptions, timeoutSeconds: number, signal?: AbortSignal): Promise<StartTransactionResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Commits or rolls back the transaction the handle names. It is a single attempt: the caller
|
|
129
|
+
* owns the `CADB0509` finalize-retry loop. `streamSlot` is the slot `startTransaction` reported;
|
|
130
|
+
* gRPC pins the finalize to the same stream as the transaction's statements, and REST ignores it.
|
|
131
|
+
*/
|
|
132
|
+
finalizeTransaction(commit: boolean, endpoint: string, database: string, txnIdPT: bigint, txnIdCounter: number, streamSlot: number | undefined, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
133
|
+
/** Runs a `SELECT` and reports its decoded rows plus any cache and routing metadata. */
|
|
134
|
+
executeQuery(request: TransportSqlRequest): Promise<QueryTransportResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Runs a `SELECT` and reports a source whose rows are pulled as the caller advances, so a large
|
|
137
|
+
* result never fully materializes on this side.
|
|
138
|
+
*
|
|
139
|
+
* REST streams the NDJSON body row by row. gRPC multiplexes its data plane over shared streams
|
|
140
|
+
* that decode a whole result before returning, so it buffers and replays through the same
|
|
141
|
+
* interface: correct, and uniform for the caller, but not incremental.
|
|
142
|
+
*
|
|
143
|
+
* The streaming path gives up the buffered path's transparent retry of a serializable conflict.
|
|
144
|
+
* Rows can reach the caller before the autocommit transaction commits, so a late conflict is
|
|
145
|
+
* reported while reading rather than retried.
|
|
146
|
+
*/
|
|
147
|
+
executeQueryStream(request: TransportSqlRequest): Promise<CamusRowSource>;
|
|
148
|
+
/** Runs an `INSERT`, `UPDATE`, or `DELETE` and reports the affected-row count. */
|
|
149
|
+
executeNonQuery(request: TransportSqlRequest): Promise<NonQueryTransportResult>;
|
|
150
|
+
/**
|
|
151
|
+
* Inserts one row through the server's typed row-level surface — the same operation `INSERT INTO`
|
|
152
|
+
* performs, written as a table plus a column-to-value map instead of SQL text.
|
|
153
|
+
*/
|
|
154
|
+
insert(request: TransportInsertRequest): Promise<number>;
|
|
155
|
+
/** Runs a DDL statement. */
|
|
156
|
+
executeDdl(request: TransportSqlRequest): Promise<boolean>;
|
|
157
|
+
/**
|
|
158
|
+
* Registers SQL as a prepared statement and reports the placeholder names in binding order, or
|
|
159
|
+
* reuses a registration this transport already holds for it.
|
|
160
|
+
*
|
|
161
|
+
* A caller receives no handle. A handle's lifetime is a property of the transport that minted it
|
|
162
|
+
* — a gRPC handle dies with its stream, a REST handle with an idle timeout or a node restart —
|
|
163
|
+
* so it stays inside, where it can be checked and renewed. What a caller gets is the statement's
|
|
164
|
+
* binding order, and the knowledge that later prepared executions will be cheap.
|
|
165
|
+
*
|
|
166
|
+
* It is idempotent per endpoint, database, and SQL; concurrent first calls share one
|
|
167
|
+
* registration.
|
|
168
|
+
*/
|
|
169
|
+
prepare(endpoint: string, database: string, sql: string, timeoutSeconds: number, signal?: AbortSignal): Promise<PreparedStatementInfo>;
|
|
170
|
+
/**
|
|
171
|
+
* Releases this transport's registrations for a statement, both locally and on the server.
|
|
172
|
+
*
|
|
173
|
+
* It is best-effort by contract. A handle whose stream, node, or idle window is already gone was
|
|
174
|
+
* freed by the server anyway, so a failure here means the work was already done. Skipping it
|
|
175
|
+
* entirely is safe for the same reason: it exists so a long-lived client that cycles through
|
|
176
|
+
* many distinct statements stays under the server's caps instead of meeting them.
|
|
177
|
+
*/
|
|
178
|
+
closePrepared(endpoint: string, database: string, sql: string, signal?: AbortSignal): Promise<void>;
|
|
179
|
+
/** A liveness check. Reports true when the server answers. */
|
|
180
|
+
ping(endpoint: string, timeoutSeconds: number, signal?: AbortSignal): Promise<boolean>;
|
|
181
|
+
/** Creates a database. It is a single attempt: the caller owns the transient-retry loop. */
|
|
182
|
+
createDatabase(endpoint: string, database: string, ifNotExists: boolean, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
183
|
+
/** Creates a copy-on-write branch database. A single attempt, like `createDatabase`. */
|
|
184
|
+
createBranchDatabase(endpoint: string, branchName: string, sourceDatabaseName: string, ifNotExists: boolean, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
185
|
+
/** Drops a database. */
|
|
186
|
+
dropDatabase(endpoint: string, database: string, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
187
|
+
/** Every transitive descendant of a database. */
|
|
188
|
+
showBranches(endpoint: string, database: string, timeoutSeconds: number, signal?: AbortSignal): Promise<CamusBranchRow[]>;
|
|
189
|
+
/** The full ancestry chain of a database. */
|
|
190
|
+
showAncestors(endpoint: string, database: string, timeoutSeconds: number, signal?: AbortSignal): Promise<CamusBranchRow[]>;
|
|
191
|
+
/** Releases every connection, stream, and channel this transport holds. */
|
|
192
|
+
close(): Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
/** True when a transaction handle is present on a request. */
|
|
195
|
+
export declare function hasTransaction(request: Pick<TransportSqlRequest, 'txnIdPT' | 'txnIdCounter'>): request is typeof request & {
|
|
196
|
+
txnIdPT: bigint;
|
|
197
|
+
txnIdCounter: number;
|
|
198
|
+
};
|
|
199
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,KAAK,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C;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAEvE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of CamusDB
|
|
3
|
+
*
|
|
4
|
+
* For the full copyright and license information, please view the LICENSE.txt
|
|
5
|
+
* file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
/** True when a transaction handle is present on a request. */
|
|
8
|
+
export function hasTransaction(request) {
|
|
9
|
+
return request.txnIdPT !== undefined && request.txnIdCounter !== undefined;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8QH,8DAA8D;AAC9D,MAAM,UAAU,cAAc,CAC5B,OAA8D;IAE9D,OAAO,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of CamusDB
|
|
3
|
+
*
|
|
4
|
+
* For the full copyright and license information, please view the LICENSE.txt
|
|
5
|
+
* file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
import type { ColumnValue } from '../column-value.js';
|
|
8
|
+
/**
|
|
9
|
+
* How an `int64` column reaches a caller.
|
|
10
|
+
*
|
|
11
|
+
* - `auto` (the default) — a `number` when the value is inside the safe integer range, a `bigint`
|
|
12
|
+
* otherwise. Every value round-trips exactly, and ordinary counters and identifiers stay
|
|
13
|
+
* numbers.
|
|
14
|
+
* - `number` — always a `number`. A value above 2^53 loses precision. Choose it only when the
|
|
15
|
+
* schema cannot hold one.
|
|
16
|
+
* - `bigint` — always a `bigint`. Choose it when one uniform type matters more than convenience.
|
|
17
|
+
*/
|
|
18
|
+
export type Int64Mode = 'auto' | 'number' | 'bigint';
|
|
19
|
+
/** How a cell is turned into a JavaScript value. */
|
|
20
|
+
export interface DecodeOptions {
|
|
21
|
+
readonly int64: Int64Mode;
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_DECODE_OPTIONS: DecodeOptions;
|
|
24
|
+
/**
|
|
25
|
+
* The JavaScript value for one cell.
|
|
26
|
+
*
|
|
27
|
+
* - `Null` — `null`.
|
|
28
|
+
* - `Id` and `String` — `string`.
|
|
29
|
+
* - `Integer64` — `number` or `bigint`, per `options.int64`.
|
|
30
|
+
* - `Float64` and `Float32` — `number`.
|
|
31
|
+
* - `Bool` — `boolean`.
|
|
32
|
+
* - `Bytes` — `Uint8Array`.
|
|
33
|
+
* - `Date` and `DateTime` — `Date`, in UTC. Sub-millisecond precision is truncated; read
|
|
34
|
+
* `longValue` from the raw row for the exact stored tick count.
|
|
35
|
+
* - `Uuid` — the canonical lowercase hyphenated `string`.
|
|
36
|
+
* - `Array` — an array of the values above.
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeValue(value: ColumnValue, options?: DecodeOptions): unknown;
|
|
39
|
+
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/values/decode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErD,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAgD,CAAC;AAEtF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,GAAE,aAAsC,GAAG,OAAO,CAmCxG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of CamusDB
|
|
3
|
+
*
|
|
4
|
+
* For the full copyright and license information, please view the LICENSE.txt
|
|
5
|
+
* file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
import { ColumnType } from '../column-type.js';
|
|
8
|
+
import { ticksToDate } from './ticks.js';
|
|
9
|
+
import { halvesToUuid } from './uuid.js';
|
|
10
|
+
export const DEFAULT_DECODE_OPTIONS = Object.freeze({ int64: 'auto' });
|
|
11
|
+
/**
|
|
12
|
+
* The JavaScript value for one cell.
|
|
13
|
+
*
|
|
14
|
+
* - `Null` — `null`.
|
|
15
|
+
* - `Id` and `String` — `string`.
|
|
16
|
+
* - `Integer64` — `number` or `bigint`, per `options.int64`.
|
|
17
|
+
* - `Float64` and `Float32` — `number`.
|
|
18
|
+
* - `Bool` — `boolean`.
|
|
19
|
+
* - `Bytes` — `Uint8Array`.
|
|
20
|
+
* - `Date` and `DateTime` — `Date`, in UTC. Sub-millisecond precision is truncated; read
|
|
21
|
+
* `longValue` from the raw row for the exact stored tick count.
|
|
22
|
+
* - `Uuid` — the canonical lowercase hyphenated `string`.
|
|
23
|
+
* - `Array` — an array of the values above.
|
|
24
|
+
*/
|
|
25
|
+
export function decodeValue(value, options = DEFAULT_DECODE_OPTIONS) {
|
|
26
|
+
switch (value.type) {
|
|
27
|
+
case ColumnType.Null:
|
|
28
|
+
return null;
|
|
29
|
+
case ColumnType.Id:
|
|
30
|
+
case ColumnType.String:
|
|
31
|
+
return value.strValue ?? '';
|
|
32
|
+
case ColumnType.Integer64:
|
|
33
|
+
return decodeInt64(value.longValue ?? 0n, options.int64);
|
|
34
|
+
case ColumnType.Float64:
|
|
35
|
+
case ColumnType.Float32:
|
|
36
|
+
return value.floatValue ?? 0;
|
|
37
|
+
case ColumnType.Bool:
|
|
38
|
+
return value.boolValue ?? false;
|
|
39
|
+
case ColumnType.Bytes:
|
|
40
|
+
return value.bytesValue ?? new Uint8Array(0);
|
|
41
|
+
case ColumnType.Date:
|
|
42
|
+
case ColumnType.DateTime:
|
|
43
|
+
return ticksToDate(value.longValue ?? 0n);
|
|
44
|
+
case ColumnType.Uuid:
|
|
45
|
+
return decodeUuid(value);
|
|
46
|
+
case ColumnType.Array:
|
|
47
|
+
return (value.arrayValues ?? []).map((item) => decodeValue(item, options));
|
|
48
|
+
default:
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function decodeInt64(value, mode) {
|
|
53
|
+
switch (mode) {
|
|
54
|
+
case 'bigint':
|
|
55
|
+
return value;
|
|
56
|
+
case 'number':
|
|
57
|
+
return Number(value);
|
|
58
|
+
default:
|
|
59
|
+
return value >= MIN_SAFE && value <= MAX_SAFE ? Number(value) : value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
|
|
63
|
+
const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
|
|
64
|
+
function decodeUuid(value) {
|
|
65
|
+
const high = value.uuidHigh ?? 0n;
|
|
66
|
+
const low = value.longValue ?? 0n;
|
|
67
|
+
// The raw halves are authoritative. The canonical string is the fallback for a response that
|
|
68
|
+
// carried only it, and for the all-zeros UUID, whose halves are indistinguishable from absent.
|
|
69
|
+
if (high === 0n && low === 0n && value.uuidValue)
|
|
70
|
+
return value.uuidValue.toLowerCase();
|
|
71
|
+
if (high === 0n && low === 0n && value.strValue)
|
|
72
|
+
return value.strValue.toLowerCase();
|
|
73
|
+
return halvesToUuid(high, low);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/values/decode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,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E,OAAO,CAAC,CAAC,CAAC;QAE7E;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAa,EAAE,IAAe;IACjD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC;QAEf,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QAEvB;YACE,OAAO,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEjD,SAAS,UAAU,CAAC,KAAkB;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;IAElC,6FAA6F;IAC7F,+FAA+F;IAC/F,IAAI,IAAI,KAAK,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;IACvF,IAAI,IAAI,KAAK,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAErF,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of CamusDB
|
|
3
|
+
*
|
|
4
|
+
* For the full copyright and license information, please view the LICENSE.txt
|
|
5
|
+
* file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
import { ColumnType } from '../column-type.js';
|
|
8
|
+
import type { ColumnValue } from '../column-value.js';
|
|
9
|
+
/**
|
|
10
|
+
* A value a caller may bind to a parameter: a plain JavaScript value the driver infers a column
|
|
11
|
+
* type from, or a `camus.*` helper that states the type.
|
|
12
|
+
*/
|
|
13
|
+
export type ParameterValue = unknown;
|
|
14
|
+
/** Bound parameters, keyed by placeholder name. A leading `@` is optional. */
|
|
15
|
+
export type Parameters = Readonly<Record<string, ParameterValue>>;
|
|
16
|
+
/**
|
|
17
|
+
* The wire form of one bound parameter.
|
|
18
|
+
*
|
|
19
|
+
* A `camus.*` helper carries its own column type. Anything else is inferred from the JavaScript
|
|
20
|
+
* value:
|
|
21
|
+
*
|
|
22
|
+
* - `null` and `undefined` — `Null`.
|
|
23
|
+
* - `boolean` — `Bool`.
|
|
24
|
+
* - `number` — `Integer64` when it is an integer, `Float64` otherwise.
|
|
25
|
+
* - `bigint` — `Integer64`.
|
|
26
|
+
* - `string` — `String`. A UUID string is **not** detected: state it with `camus.uuid`.
|
|
27
|
+
* - `Date` — `DateTime`. Use `camus.date` for a date-only column.
|
|
28
|
+
* - `Uint8Array`, `Buffer`, `ArrayBuffer` — `Bytes`.
|
|
29
|
+
* - `Float32Array` — `Bytes`, packed as a vector. It is the natural JavaScript form of an
|
|
30
|
+
* embedding, and a packed float32 buffer has no other meaning in CamusDB.
|
|
31
|
+
* - `CamusObjectId` — `Id`.
|
|
32
|
+
* - an array — `Array`, with the element type inferred from the first element that is not null.
|
|
33
|
+
*/
|
|
34
|
+
export declare function encodeParameter(value: ParameterValue): ColumnValue;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the wire dictionary for a statement's parameters, or `undefined` when there are none.
|
|
37
|
+
*
|
|
38
|
+
* Placeholder names reach the server with a leading `@`, which is how the server publishes them
|
|
39
|
+
* for a prepared statement. A caller may write the name either way: `{ year: 1974 }` and
|
|
40
|
+
* `{ '@year': 1974 }` produce the same request.
|
|
41
|
+
*/
|
|
42
|
+
export declare function encodeParameters(parameters: Parameters | undefined): Map<string, ColumnValue> | undefined;
|
|
43
|
+
/** Encodes one value against a declared column type. Used for array elements. */
|
|
44
|
+
export declare function encodeAs(value: unknown, declared: ColumnType): ColumnValue;
|
|
45
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/values/encode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAkB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;AAErC,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CAIlE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS,CA0BzG;AAED,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,GAAG,WAAW,CA0C1E"}
|