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,120 @@
|
|
|
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 { CamusError } from './errors.js';
|
|
8
|
+
import { CamusErrorCode } from './error-codes.js';
|
|
9
|
+
import { SharedRegistry } from './shared-registry.js';
|
|
10
|
+
/**
|
|
11
|
+
* The endpoints one deployment's clients rotate through, and which of them are set aside after
|
|
12
|
+
* failing to answer at all.
|
|
13
|
+
*
|
|
14
|
+
* A pool is shared per endpoint list rather than owned by one client. The rotation and the health
|
|
15
|
+
* it depends on are properties of the deployment; a per-client pool would restart its rotation at
|
|
16
|
+
* the first endpoint on every request.
|
|
17
|
+
*
|
|
18
|
+
* Quarantine expires. A pool that outlives the request that marked an endpoint cannot mark it
|
|
19
|
+
* forever: with a single endpoint configured — the common case — the first refused connection
|
|
20
|
+
* would otherwise end the process's ability to reach the database at all, long after the node came
|
|
21
|
+
* back. An endpoint is set aside for `QUARANTINE_PERIOD_MS` and then drawn again; a node that is
|
|
22
|
+
* still down is simply marked again by the request that draws it, at a cost of one failed request
|
|
23
|
+
* per period.
|
|
24
|
+
*/
|
|
25
|
+
export class CamusEndpointPool {
|
|
26
|
+
/** How long an endpoint that failed at the transport level is passed over. */
|
|
27
|
+
static QUARANTINE_PERIOD_MS = 30_000;
|
|
28
|
+
static shared = new SharedRegistry();
|
|
29
|
+
/**
|
|
30
|
+
* The process-wide pool for an endpoint list, built on first use. Keyed by the list alone, so
|
|
31
|
+
* clients that differ only in database, credentials, or timeout share one rotation and one view
|
|
32
|
+
* of which nodes are answering.
|
|
33
|
+
*/
|
|
34
|
+
static forEndpoints(endpointList) {
|
|
35
|
+
return CamusEndpointPool.shared.get(endpointList, () => new CamusEndpointPool(endpointList));
|
|
36
|
+
}
|
|
37
|
+
/** @internal Test hook: drops every shared pool. */
|
|
38
|
+
static resetShared() {
|
|
39
|
+
CamusEndpointPool.shared.clear();
|
|
40
|
+
}
|
|
41
|
+
endpoints;
|
|
42
|
+
/**
|
|
43
|
+
* Monotonic-clock deadlines, indexed alongside `endpoints`. Zero — the initial value — is in the
|
|
44
|
+
* past, so an endpoint that has never failed needs no special case.
|
|
45
|
+
*/
|
|
46
|
+
quarantinedUntil;
|
|
47
|
+
nextIndex = 0;
|
|
48
|
+
/** @internal Test hook: the monotonic clock this pool reads. */
|
|
49
|
+
clock = () => performance.now();
|
|
50
|
+
constructor(endpointList) {
|
|
51
|
+
this.endpoints = endpointList
|
|
52
|
+
.split(',')
|
|
53
|
+
.map((endpoint) => endpoint.trim())
|
|
54
|
+
.filter((endpoint) => endpoint.length > 0);
|
|
55
|
+
if (this.endpoints.length === 0) {
|
|
56
|
+
throw new CamusError(CamusErrorCode.Generic, 'Endpoint is required.');
|
|
57
|
+
}
|
|
58
|
+
this.quarantinedUntil = new Array(this.endpoints.length).fill(0);
|
|
59
|
+
}
|
|
60
|
+
/** Every configured endpoint, in the order it was written. */
|
|
61
|
+
get members() {
|
|
62
|
+
return this.endpoints;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The next endpoint to send to, skipping those in quarantine.
|
|
66
|
+
*
|
|
67
|
+
* When every endpoint is quarantined the one closest to leaving is returned rather than an
|
|
68
|
+
* error. The deployment is evidently down, and letting the request go and fail against the real
|
|
69
|
+
* node reports why, where a synthetic "no endpoints" would replace the server's diagnosis with
|
|
70
|
+
* the driver's bookkeeping.
|
|
71
|
+
*/
|
|
72
|
+
next() {
|
|
73
|
+
const now = this.clock();
|
|
74
|
+
let fallback = -1;
|
|
75
|
+
for (let i = 0; i < this.endpoints.length; i++) {
|
|
76
|
+
const index = this.nextIndex;
|
|
77
|
+
this.nextIndex = (this.nextIndex + 1) % this.endpoints.length;
|
|
78
|
+
if (this.quarantinedUntil[index] <= now)
|
|
79
|
+
return this.endpoints[index];
|
|
80
|
+
if (fallback < 0 || this.quarantinedUntil[index] < this.quarantinedUntil[fallback]) {
|
|
81
|
+
fallback = index;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return this.endpoints[fallback === -1 ? 0 : fallback];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether an endpoint is currently set aside. Learned routing reads it before preferring an
|
|
88
|
+
* endpoint, so a route pointing at a node that stopped answering falls back to rotation. An
|
|
89
|
+
* address the pool does not know reports as not quarantined.
|
|
90
|
+
*/
|
|
91
|
+
isQuarantined(endpoint) {
|
|
92
|
+
const index = this.indexOf(endpoint);
|
|
93
|
+
if (index < 0)
|
|
94
|
+
return false;
|
|
95
|
+
return this.quarantinedUntil[index] > this.clock();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Whether an address is one of the configured endpoints. The routing trust map uses it to refuse
|
|
99
|
+
* mapping a node identity to any address the operator did not list.
|
|
100
|
+
*/
|
|
101
|
+
contains(endpoint) {
|
|
102
|
+
return this.indexOf(endpoint) >= 0;
|
|
103
|
+
}
|
|
104
|
+
/** Sets an endpoint aside, so the endpoints that are answering carry the traffic meanwhile. */
|
|
105
|
+
markUnreachable(endpoint) {
|
|
106
|
+
const index = this.indexOf(endpoint);
|
|
107
|
+
if (index < 0)
|
|
108
|
+
return;
|
|
109
|
+
this.quarantinedUntil[index] = this.clock() + CamusEndpointPool.QUARANTINE_PERIOD_MS;
|
|
110
|
+
}
|
|
111
|
+
indexOf(endpoint) {
|
|
112
|
+
const wanted = endpoint.toLowerCase();
|
|
113
|
+
for (let i = 0; i < this.endpoints.length; i++) {
|
|
114
|
+
if (this.endpoints[i].toLowerCase() === wanted)
|
|
115
|
+
return i;
|
|
116
|
+
}
|
|
117
|
+
return -1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=endpoint-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-pool.js","sourceRoot":"","sources":["../src/endpoint-pool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,iBAAiB;IAC5B,8EAA8E;IAC9E,MAAM,CAAU,oBAAoB,GAAG,MAAM,CAAC;IAEtC,MAAM,CAAU,MAAM,GAAG,IAAI,cAAc,EAAqB,CAAC;IAEzE;;;;O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CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,iBAAiB,CAAC,oBAAoB,CAAC;IACvF,CAAC;IAEO,OAAO,CAAC,QAAgB;QAC9B,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,KAAK,MAAM;gBAAE,OAAO,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* The server error codes this driver reacts to. Every other `CADBxxxx` code reaches the caller
|
|
9
|
+
* unchanged on `CamusError.code`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CamusErrorCode: {
|
|
12
|
+
/** The driver's own generic code, used when the far end supplied none. */
|
|
13
|
+
readonly Generic: "CADB0000";
|
|
14
|
+
/** A parameter cannot be mapped to a wire value. Raised locally, before any request. */
|
|
15
|
+
readonly InvalidParameter: "CADB0400";
|
|
16
|
+
/** A byte payload read as a vector has a length that is not a multiple of four. */
|
|
17
|
+
readonly InvalidVector: "CADB0410";
|
|
18
|
+
/** The database already exists. Also raised when `IF NOT EXISTS` loses a registration race. */
|
|
19
|
+
readonly DatabaseAlreadyExists: "CADB0012";
|
|
20
|
+
/**
|
|
21
|
+
* The commit or rollback outcome is not resolved yet. The transaction is not dead: the same
|
|
22
|
+
* finalize must be re-issued on the same handle, never replayed from `BEGIN`.
|
|
23
|
+
*/
|
|
24
|
+
readonly FinalizeUnresolved: "CADB0509";
|
|
25
|
+
/**
|
|
26
|
+
* No token, an invalid or expired token, an unknown user, or a wrong password (HTTP 401). Every
|
|
27
|
+
* authentication failure returns this one code so replies cannot be used to enumerate accounts.
|
|
28
|
+
*/
|
|
29
|
+
readonly AuthenticationFailed: "CADB0516";
|
|
30
|
+
/** Authenticated, but without the privilege the statement needs (HTTP 403). Never retried. */
|
|
31
|
+
readonly InsufficientPrivilege: "CADB0517";
|
|
32
|
+
/** The login rate limit was exceeded, or the key derivation function is saturated (HTTP 429). */
|
|
33
|
+
readonly TooManyAuthAttempts: "CADB0518";
|
|
34
|
+
/** A request that carries a credential arrived over a plaintext connection (HTTP 400). */
|
|
35
|
+
readonly InsecureTransport: "CADB0519";
|
|
36
|
+
/** The named prepared statement is gone: it expired, or the node that held it restarted. */
|
|
37
|
+
readonly UnknownPreparedStatement: "CADB0520";
|
|
38
|
+
/** The per-principal prepared-statement cap is full. */
|
|
39
|
+
readonly PreparedStatementLimitExceeded: "CADB0521";
|
|
40
|
+
/** The statement runs in its own internal transaction and is refused inside an explicit one. */
|
|
41
|
+
readonly StatementNotAllowedInTransaction: "CADB0538";
|
|
42
|
+
};
|
|
43
|
+
export type CamusErrorCode = (typeof CamusErrorCode)[keyof typeof CamusErrorCode];
|
|
44
|
+
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,0EAA0E;;IAG1E,wFAAwF;;IAGxF,mFAAmF;;IAGnF,+FAA+F;;IAG/F;;;OAGG;;IAGH;;;OAGG;;IAGH,8FAA8F;;IAG9F,iGAAiG;;IAGjG,0FAA0F;;IAG1F,4FAA4F;;IAG5F,wDAAwD;;IAGxD,gGAAgG;;CAExF,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* The server error codes this driver reacts to. Every other `CADBxxxx` code reaches the caller
|
|
9
|
+
* unchanged on `CamusError.code`.
|
|
10
|
+
*/
|
|
11
|
+
export const CamusErrorCode = {
|
|
12
|
+
/** The driver's own generic code, used when the far end supplied none. */
|
|
13
|
+
Generic: 'CADB0000',
|
|
14
|
+
/** A parameter cannot be mapped to a wire value. Raised locally, before any request. */
|
|
15
|
+
InvalidParameter: 'CADB0400',
|
|
16
|
+
/** A byte payload read as a vector has a length that is not a multiple of four. */
|
|
17
|
+
InvalidVector: 'CADB0410',
|
|
18
|
+
/** The database already exists. Also raised when `IF NOT EXISTS` loses a registration race. */
|
|
19
|
+
DatabaseAlreadyExists: 'CADB0012',
|
|
20
|
+
/**
|
|
21
|
+
* The commit or rollback outcome is not resolved yet. The transaction is not dead: the same
|
|
22
|
+
* finalize must be re-issued on the same handle, never replayed from `BEGIN`.
|
|
23
|
+
*/
|
|
24
|
+
FinalizeUnresolved: 'CADB0509',
|
|
25
|
+
/**
|
|
26
|
+
* No token, an invalid or expired token, an unknown user, or a wrong password (HTTP 401). Every
|
|
27
|
+
* authentication failure returns this one code so replies cannot be used to enumerate accounts.
|
|
28
|
+
*/
|
|
29
|
+
AuthenticationFailed: 'CADB0516',
|
|
30
|
+
/** Authenticated, but without the privilege the statement needs (HTTP 403). Never retried. */
|
|
31
|
+
InsufficientPrivilege: 'CADB0517',
|
|
32
|
+
/** The login rate limit was exceeded, or the key derivation function is saturated (HTTP 429). */
|
|
33
|
+
TooManyAuthAttempts: 'CADB0518',
|
|
34
|
+
/** A request that carries a credential arrived over a plaintext connection (HTTP 400). */
|
|
35
|
+
InsecureTransport: 'CADB0519',
|
|
36
|
+
/** The named prepared statement is gone: it expired, or the node that held it restarted. */
|
|
37
|
+
UnknownPreparedStatement: 'CADB0520',
|
|
38
|
+
/** The per-principal prepared-statement cap is full. */
|
|
39
|
+
PreparedStatementLimitExceeded: 'CADB0521',
|
|
40
|
+
/** The statement runs in its own internal transaction and is refused inside an explicit one. */
|
|
41
|
+
StatementNotAllowedInTransaction: 'CADB0538',
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,0EAA0E;IAC1E,OAAO,EAAE,UAAU;IAEnB,wFAAwF;IACxF,gBAAgB,EAAE,UAAU;IAE5B,mFAAmF;IACnF,aAAa,EAAE,UAAU;IAEzB,+FAA+F;IAC/F,qBAAqB,EAAE,UAAU;IAEjC;;;OAGG;IACH,kBAAkB,EAAE,UAAU;IAE9B;;;OAGG;IACH,oBAAoB,EAAE,UAAU;IAEhC,8FAA8F;IAC9F,qBAAqB,EAAE,UAAU;IAEjC,iGAAiG;IACjG,mBAAmB,EAAE,UAAU;IAE/B,0FAA0F;IAC1F,iBAAiB,EAAE,UAAU;IAE7B,4FAA4F;IAC5F,wBAAwB,EAAE,UAAU;IAEpC,wDAAwD;IACxD,8BAA8B,EAAE,UAAU;IAE1C,gGAAgG;IAChG,gCAAgC,EAAE,UAAU;CACpC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Every failure this driver raises for a database-level problem.
|
|
9
|
+
*
|
|
10
|
+
* `code` is the server's `CADBxxxx` code, taken from the HTTP body's `code` field or from the
|
|
11
|
+
* `camus-error-code` gRPC trailer. It is the value to switch on; the message is human text and is
|
|
12
|
+
* not a stable contract. `CADB0000` is the generic code the driver uses when the far end supplied
|
|
13
|
+
* none.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CamusError extends Error {
|
|
16
|
+
readonly name = "CamusError";
|
|
17
|
+
readonly code: string;
|
|
18
|
+
constructor(code: string, message: string, options?: {
|
|
19
|
+
cause?: unknown;
|
|
20
|
+
});
|
|
21
|
+
/** True when `value` is a `CamusError`, including one raised by another copy of this package. */
|
|
22
|
+
static is(value: unknown): value is CamusError;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAkB,IAAI,gBAAgB;IAEtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAQxE,iGAAiG;IACjG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU;CAS/C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Every failure this driver raises for a database-level problem.
|
|
9
|
+
*
|
|
10
|
+
* `code` is the server's `CADBxxxx` code, taken from the HTTP body's `code` field or from the
|
|
11
|
+
* `camus-error-code` gRPC trailer. It is the value to switch on; the message is human text and is
|
|
12
|
+
* not a stable contract. `CADB0000` is the generic code the driver uses when the far end supplied
|
|
13
|
+
* none.
|
|
14
|
+
*/
|
|
15
|
+
export class CamusError extends Error {
|
|
16
|
+
name = 'CamusError';
|
|
17
|
+
code;
|
|
18
|
+
constructor(code, message, options) {
|
|
19
|
+
super(message, options);
|
|
20
|
+
this.code = code;
|
|
21
|
+
// Keeps `instanceof` working when the package is compiled down to ES5 by a consumer's bundler.
|
|
22
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
23
|
+
}
|
|
24
|
+
/** True when `value` is a `CamusError`, including one raised by another copy of this package. */
|
|
25
|
+
static is(value) {
|
|
26
|
+
return (value instanceof CamusError ||
|
|
27
|
+
(typeof value === 'object' &&
|
|
28
|
+
value !== null &&
|
|
29
|
+
value.name === 'CamusError' &&
|
|
30
|
+
typeof value.code === 'string'));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACjB,IAAI,GAAG,YAAY,CAAC;IAE7B,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe,EAAE,OAA6B;QACtE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,+FAA+F;QAC/F,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,iGAAiG;IACjG,MAAM,CAAC,EAAE,CAAC,KAAc;QACtB,OAAO,CACL,KAAK,YAAY,UAAU;YAC3B,CAAC,OAAO,KAAK,KAAK,QAAQ;gBACxB,KAAK,KAAK,IAAI;gBACb,KAA4B,CAAC,IAAI,KAAK,YAAY;gBACnD,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC,CAC1D,CAAC;IACJ,CAAC;CACF"}
|
package/dist/hlc.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* One instant on the cluster's hybrid logical clock, as a response envelope reports it.
|
|
9
|
+
*
|
|
10
|
+
* `l` is the physical component in milliseconds and `c` is the logical counter that orders events
|
|
11
|
+
* inside one millisecond. The node dimension is not part of a cache report, so it is absent here.
|
|
12
|
+
*/
|
|
13
|
+
export interface CamusHlcTimestamp {
|
|
14
|
+
readonly l: bigint;
|
|
15
|
+
readonly c: number;
|
|
16
|
+
}
|
|
17
|
+
/** `l:c`, the form the server writes an instant in. */
|
|
18
|
+
export declare function formatHlc(timestamp: CamusHlcTimestamp): string;
|
|
19
|
+
//# sourceMappingURL=hlc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hlc.d.ts","sourceRoot":"","sources":["../src/hlc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAE9D"}
|
package/dist/hlc.js
ADDED
|
@@ -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
|
+
/** `l:c`, the form the server writes an instant in. */
|
|
8
|
+
export function formatHlc(timestamp) {
|
|
9
|
+
return `${timestamp.l.toString()}:${timestamp.c.toString()}`;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=hlc.js.map
|
package/dist/hlc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hlc.js","sourceRoot":"","sources":["../src/hlc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,uDAAuD;AACvD,MAAM,UAAU,SAAS,CAAC,SAA4B;IACpD,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC/D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* The CamusDB connector for Node.js.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { CamusClient } from 'camusdb';
|
|
12
|
+
*
|
|
13
|
+
* const client = new CamusClient({ endpoint: 'http://localhost:8082', database: 'test' });
|
|
14
|
+
*
|
|
15
|
+
* const { rows } = await client.query<Robot>('SELECT * FROM robots WHERE year = @year', { year: 1974 });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { CamusClient } from './client.js';
|
|
19
|
+
export type { AutocommitStatementOptions, ExecuteResult, QueryResult, StatementOptions, TransactionRunOptions, } from './client.js';
|
|
20
|
+
export { CamusTransaction } from './transaction.js';
|
|
21
|
+
export { CamusQueryStream } from './query-stream.js';
|
|
22
|
+
export { CamusBackupClient } from './backup.js';
|
|
23
|
+
export type { CamusBackupGcDeletion, CamusBackupGcOrphan, CamusBackupGcResult, CamusBackupInfo, } from './backup.js';
|
|
24
|
+
export { CamusProtocol, CamusRoutingMode, DEFAULT_BATCH_OPTIONS } from './config.js';
|
|
25
|
+
export type { CamusClientOptions, GrpcBatchOptions, ResolvedConfig } from './config.js';
|
|
26
|
+
export { parseConnectionString, redactConnectionString } from './connection-string.js';
|
|
27
|
+
export { CamusIsolationLevel, CamusLocking, CamusTransactionMode, DEFAULT_TRANSACTION_OPTIONS, OPTIMISTIC_TRANSACTION_OPTIONS, SNAPSHOT_TRANSACTION_OPTIONS, } from './options.js';
|
|
28
|
+
export type { CamusTransactionOptions } from './options.js';
|
|
29
|
+
export { CamusError } from './errors.js';
|
|
30
|
+
export { CamusErrorCode } from './error-codes.js';
|
|
31
|
+
export { computeDelayMs, isRetryable, withRetry } from './retry.js';
|
|
32
|
+
export type { RetryOptions } from './retry.js';
|
|
33
|
+
export { ColumnType, columnTypeName, isColumnType } from './column-type.js';
|
|
34
|
+
export type { ColumnValue } from './column-value.js';
|
|
35
|
+
export { camus } from './values/typed.js';
|
|
36
|
+
export type { TypedParameter } from './values/typed.js';
|
|
37
|
+
export type { Parameters, ParameterValue } from './values/encode.js';
|
|
38
|
+
export type { DecodeOptions, Int64Mode } from './values/decode.js';
|
|
39
|
+
export { decodeValue } from './values/decode.js';
|
|
40
|
+
export { CamusObjectId } from './object-id.js';
|
|
41
|
+
export { CamusVector } from './vector.js';
|
|
42
|
+
export { TICKS_PER_DAY, TICKS_PER_MILLISECOND, UNIX_EPOCH_TICKS, dateToDayTicks, dateToTicks, ticksToDate, } from './values/ticks.js';
|
|
43
|
+
export { bytesToUuid, isUuid, uuidToBytes } from './values/uuid.js';
|
|
44
|
+
export { CamusResultSet } from './result-set.js';
|
|
45
|
+
export type { CamusColumn } from './result-set.js';
|
|
46
|
+
export type { CamusBranchRow } from './transport/transport.js';
|
|
47
|
+
export { CamusCacheStatus, cacheHint, evictAllCacheStatement, evictCacheStatement } from './cache.js';
|
|
48
|
+
export type { CamusCacheMetadata } from './cache.js';
|
|
49
|
+
export { CamusRoutingDisposition, ROUTING_ACCEPT_VERSION } from './routing/advice.js';
|
|
50
|
+
export type { CamusRoutingAdvice } from './routing/advice.js';
|
|
51
|
+
export { formatHlc } from './hlc.js';
|
|
52
|
+
export type { CamusHlcTimestamp } from './hlc.js';
|
|
53
|
+
export { CamusTransportPool } from './transport/transport-pool.js';
|
|
54
|
+
export { delimitIdentifier, sqlLiteral, validateBareName, validateIdentifier, validateSqlLiteral, } from './sql-syntax.js';
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EACV,0BAA0B,EAC1B,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrF,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EACL,mBAA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EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtG,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIrD,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACtF,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAI9D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* The CamusDB connector for Node.js.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { CamusClient } from 'camusdb';
|
|
12
|
+
*
|
|
13
|
+
* const client = new CamusClient({ endpoint: 'http://localhost:8082', database: 'test' });
|
|
14
|
+
*
|
|
15
|
+
* const { rows } = await client.query<Robot>('SELECT * FROM robots WHERE year = @year', { year: 1974 });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
// ─── The client ─────────────────────────────────────────────────────────────
|
|
19
|
+
export { CamusClient } from './client.js';
|
|
20
|
+
export { CamusTransaction } from './transaction.js';
|
|
21
|
+
export { CamusQueryStream } from './query-stream.js';
|
|
22
|
+
export { CamusBackupClient } from './backup.js';
|
|
23
|
+
// ─── Configuration ──────────────────────────────────────────────────────────
|
|
24
|
+
export { CamusProtocol, CamusRoutingMode, DEFAULT_BATCH_OPTIONS } from './config.js';
|
|
25
|
+
export { parseConnectionString, redactConnectionString } from './connection-string.js';
|
|
26
|
+
export { CamusIsolationLevel, CamusLocking, CamusTransactionMode, DEFAULT_TRANSACTION_OPTIONS, OPTIMISTIC_TRANSACTION_OPTIONS, SNAPSHOT_TRANSACTION_OPTIONS, } from './options.js';
|
|
27
|
+
// ─── Errors and retries ─────────────────────────────────────────────────────
|
|
28
|
+
export { CamusError } from './errors.js';
|
|
29
|
+
export { CamusErrorCode } from './error-codes.js';
|
|
30
|
+
export { computeDelayMs, isRetryable, withRetry } from './retry.js';
|
|
31
|
+
// ─── Values ─────────────────────────────────────────────────────────────────
|
|
32
|
+
export { ColumnType, columnTypeName, isColumnType } from './column-type.js';
|
|
33
|
+
export { camus } from './values/typed.js';
|
|
34
|
+
export { decodeValue } from './values/decode.js';
|
|
35
|
+
export { CamusObjectId } from './object-id.js';
|
|
36
|
+
export { CamusVector } from './vector.js';
|
|
37
|
+
export { TICKS_PER_DAY, TICKS_PER_MILLISECOND, UNIX_EPOCH_TICKS, dateToDayTicks, dateToTicks, ticksToDate, } from './values/ticks.js';
|
|
38
|
+
export { bytesToUuid, isUuid, uuidToBytes } from './values/uuid.js';
|
|
39
|
+
// ─── Results ────────────────────────────────────────────────────────────────
|
|
40
|
+
export { CamusResultSet } from './result-set.js';
|
|
41
|
+
// ─── The query result cache ─────────────────────────────────────────────────
|
|
42
|
+
export { CamusCacheStatus, cacheHint, evictAllCacheStatement, evictCacheStatement } from './cache.js';
|
|
43
|
+
// ─── Learned routing ────────────────────────────────────────────────────────
|
|
44
|
+
export { CamusRoutingDisposition, ROUTING_ACCEPT_VERSION } from './routing/advice.js';
|
|
45
|
+
// ─── Clocks ─────────────────────────────────────────────────────────────────
|
|
46
|
+
export { formatHlc } from './hlc.js';
|
|
47
|
+
// ─── Process lifetime ───────────────────────────────────────────────────────
|
|
48
|
+
export { CamusTransportPool } from './transport/transport-pool.js';
|
|
49
|
+
// ─── SQL text helpers ───────────────────────────────────────────────────────
|
|
50
|
+
export { delimitIdentifier, sqlLiteral, validateBareName, validateIdentifier, validateSqlLiteral, } from './sql-syntax.js';
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AAEH,+EAA+E;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAS1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,+EAA+E;AAE/E,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGrF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAGtB,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGpE,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpE,+EAA+E;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,+EAA+E;AAE/E,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtG,+EAA+E;AAE/E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGtF,+EAA+E;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,+EAA+E;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,+EAA+E;AAE/E,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* A JSON reader and writer that keeps 64-bit integers exact.
|
|
9
|
+
*
|
|
10
|
+
* CamusDB is a 64-bit database. An `int64` column, a transaction's physical-time component, and a
|
|
11
|
+
* date's tick count all reach the wire as JSON numbers whose value can exceed 2^53, which is where
|
|
12
|
+
* a JavaScript number stops being able to name every integer. `JSON.parse` would round such a
|
|
13
|
+
* value silently, and `JSON.stringify` refuses a `bigint` outright. Both are unacceptable in a
|
|
14
|
+
* driver: a row must come back holding what was written.
|
|
15
|
+
*
|
|
16
|
+
* So this module reads an integer that does not fit a `number` as a `bigint`, and writes a
|
|
17
|
+
* `bigint` as the bare digits a JSON number is. Everything else behaves exactly as the built-in
|
|
18
|
+
* functions do.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Parses JSON text, reading an integer outside the safe range as a `bigint`.
|
|
22
|
+
*
|
|
23
|
+
* The common reply holds no such integer, and the built-in parser is far faster than any parser
|
|
24
|
+
* written in JavaScript. So the text is first tested for a run of 16 or more digits — the shortest
|
|
25
|
+
* run that can leave the safe range. Without one the built-in parser is exact and is used. A run
|
|
26
|
+
* inside a string literal costs nothing but a slower parse of that one reply.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseLossless(text: string): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Serializes a value as JSON, writing a `bigint` as a JSON number.
|
|
31
|
+
*
|
|
32
|
+
* `undefined`, a function, and a symbol are omitted from an object and become `null` in an array,
|
|
33
|
+
* which is what `JSON.stringify` does. A value with a `toJSON` method is replaced by its result,
|
|
34
|
+
* also as `JSON.stringify` does.
|
|
35
|
+
*/
|
|
36
|
+
export declare function stringifyLossless(value: unknown): string;
|
|
37
|
+
/** Reads a value that may have arrived as a number, a bigint, or a numeric string. */
|
|
38
|
+
export declare function asBigInt(value: unknown, fallback?: bigint): bigint;
|
|
39
|
+
/** Reads a value that may have arrived as a number or a bigint, as a `number`. */
|
|
40
|
+
export declare function asNumber(value: unknown, fallback?: number): number;
|
|
41
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAID;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIxD;AAwVD,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAK,GAAG,MAAM,CAe9D;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAI,GAAG,MAAM,CAa7D"}
|