@lossless.org/client 1.4.0 → 1.5.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/core/interfaces.d.ts +7 -0
- package/dist_ts/index.d.ts +1 -1
- package/dist_ts/nosqldb/classes.collection.js +2 -3
- package/dist_ts/nosqldb/classes.connection.d.ts +8 -3
- package/dist_ts/nosqldb/classes.connection.js +11 -6
- package/dist_ts/nosqldb/classes.db.d.ts +13 -0
- package/dist_ts/nosqldb/classes.db.js +28 -1
- package/dist_ts/nosqldb/classes.doc.js +10 -2
- package/dist_ts/nosqldb/classes.easystore.d.ts +13 -0
- package/dist_ts/nosqldb/classes.easystore.js +16 -1
- package/dist_ts/nosqldb/engineidentity.d.ts +31 -0
- package/dist_ts/nosqldb/engineidentity.js +105 -0
- package/dist_ts/nosqldb/index.d.ts +2 -0
- package/dist_ts/nosqldb/index.js +1 -1
- package/dist_ts/nosqldb/lineage.js +3 -1
- package/dist_ts/objectstorage/classes.connection.js +2 -2
- package/dist_ts/sqldb/classes.clickhouseconnection.js +3 -2
- package/dist_ts/sqldb/classes.sqlconnection.d.ts +7 -5
- package/dist_ts/sqldb/classes.sqlconnection.js +3 -3
- package/dist_ts/sqldb/interfaces.d.ts +5 -0
- package/dist_ts/sqldb/interfaces.js +1 -1
- package/dist_ts/sqldb/internal.lease.d.ts +15 -0
- package/dist_ts/sqldb/internal.lease.js +2 -0
- package/dist_ts/sqldb/internal.sqlpool.d.ts +2 -1
- package/dist_ts/sqldb/internal.sqlpool.js +1 -1
- package/dist_ts/sqldb/plugins.d.ts +4 -0
- package/dist_ts/sqldb/plugins.js +7 -0
- package/dist_ts/sqldb/plugins.mariadb.d.ts +2 -3
- package/dist_ts/sqldb/plugins.mariadb.js +4 -4
- package/package.json +3 -3
- package/readme.md +24 -19
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/core/interfaces.ts +7 -0
- package/ts/index.ts +1 -1
- package/ts/nosqldb/classes.collection.ts +1 -2
- package/ts/nosqldb/classes.connection.ts +19 -7
- package/ts/nosqldb/classes.db.ts +38 -0
- package/ts/nosqldb/classes.doc.ts +14 -1
- package/ts/nosqldb/classes.easystore.ts +16 -0
- package/ts/nosqldb/engineidentity.ts +153 -0
- package/ts/nosqldb/index.ts +11 -0
- package/ts/nosqldb/lineage.ts +2 -0
- package/ts/objectstorage/classes.connection.ts +1 -1
- package/ts/sqldb/classes.clickhouseconnection.ts +2 -1
- package/ts/sqldb/classes.sqlconnection.ts +14 -11
- package/ts/sqldb/interfaces.ts +5 -0
- package/ts/sqldb/internal.lease.ts +16 -0
- package/ts/sqldb/internal.sqlpool.ts +2 -1
- package/ts/sqldb/plugins.mariadb.ts +3 -3
- package/ts/sqldb/plugins.ts +7 -0
|
@@ -11,7 +11,8 @@ export class ClickHouseConnection {
|
|
|
11
11
|
public readonly backend = 'clickhouse' as const;
|
|
12
12
|
public readonly metrics: SmartClickHouseDb;
|
|
13
13
|
public readonly capabilities: ICapabilities = Object.freeze({ backend: 'clickhouse',
|
|
14
|
-
transactions: 'unsupported', changeStreams: 'unsupported',
|
|
14
|
+
transactions: 'unsupported', changeStreams: 'unsupported', compositeGrouping: 'unsupported',
|
|
15
|
+
objectMetrics: 'unsupported', diskResidentScans: 'available' });
|
|
15
16
|
private client?: plugins.clickhouse.ClickHouseClient;
|
|
16
17
|
private readonly operations = new Map<Operation, () => void>();
|
|
17
18
|
private readonly tasks = new Set<Promise<unknown>>();
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import * as plugins from './plugins.
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
2
|
import { SqlTable } from './classes.sqltable.js';
|
|
3
|
-
import { SqlPool
|
|
3
|
+
import { SqlPool } from './internal.sqlpool.js';
|
|
4
|
+
import type { ISqlLeaseConnection } from './internal.lease.js';
|
|
4
5
|
import { Operation } from '../core/classes.operation.js';
|
|
5
6
|
import { LosslessClientError, backendError } from '../core/classes.error.js';
|
|
6
7
|
import type { ICapabilities, IOperationOptions, IReadiness } from '../core/interfaces.js';
|
|
7
8
|
import { quoteIdentifier, resultLimits, valueBytes } from './interfaces.js';
|
|
8
|
-
import type { IInsertOptions, IQueryOptions, ISqlMutationResult, ISqlStatement,
|
|
9
|
+
import type { IInsertOptions, IQueryOptions, ISqlMutationResult, ISqlStatement, ISqlWriteAcknowledgement,
|
|
10
|
+
TSqlValue } from './interfaces.js';
|
|
9
11
|
|
|
10
|
-
/** Options of a MariaDB-protocol connection. `tls` is
|
|
12
|
+
/** Options of a MariaDB-protocol connection. `tls` is this client's own TLS configuration, passed to the driver. */
|
|
11
13
|
export interface ISqlConnectionOptions {
|
|
12
14
|
backend: 'sqldb' | 'mariadb';
|
|
13
15
|
host: string;
|
|
@@ -17,11 +19,11 @@ export interface ISqlConnectionOptions {
|
|
|
17
19
|
database: string;
|
|
18
20
|
connectionLimit?: number;
|
|
19
21
|
timeoutMs?: number;
|
|
20
|
-
tls?: plugins.
|
|
22
|
+
tls?: boolean | (plugins.tls.SecureContextOptions & { rejectUnauthorized?: boolean });
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
interface ILease {
|
|
24
|
-
connection:
|
|
26
|
+
connection: ISqlLeaseConnection;
|
|
25
27
|
operation: Operation;
|
|
26
28
|
close: () => Promise<void>;
|
|
27
29
|
done: Promise<void>;
|
|
@@ -54,7 +56,7 @@ const boundValues = (statement: ISqlStatement): TSqlValue[] =>
|
|
|
54
56
|
? value.toISOString().replace('T', ' ').replace('Z', '')
|
|
55
57
|
: value instanceof Uint8Array ? Buffer.from(value) : value);
|
|
56
58
|
|
|
57
|
-
const mutationResult = (result:
|
|
59
|
+
const mutationResult = (result: ISqlWriteAcknowledgement): ISqlMutationResult => ({
|
|
58
60
|
affectedRows: result.affectedRows,
|
|
59
61
|
...(result.insertId === undefined ? {} : { insertId: BigInt(result.insertId) }),
|
|
60
62
|
completion: 'acknowledged',
|
|
@@ -81,7 +83,7 @@ export class SqlConnection {
|
|
|
81
83
|
}
|
|
82
84
|
this.backend = options.backend;
|
|
83
85
|
this.capabilities = Object.freeze({ backend: this.backend, transactions: 'available',
|
|
84
|
-
changeStreams: 'unsupported', objectMetrics: 'unsupported',
|
|
86
|
+
changeStreams: 'unsupported', compositeGrouping: 'unsupported', objectMetrics: 'unsupported',
|
|
85
87
|
diskResidentScans: this.backend === 'sqldb' ? 'unsupported' : 'available' });
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -130,7 +132,7 @@ export class SqlConnection {
|
|
|
130
132
|
const operation = new Operation(options, this.options.timeoutMs);
|
|
131
133
|
this.pendingOperations.add(operation);
|
|
132
134
|
const acquisition = (async (): Promise<ILease> => {
|
|
133
|
-
let connection:
|
|
135
|
+
let connection: ISqlLeaseConnection | undefined;
|
|
134
136
|
try {
|
|
135
137
|
operation.check();
|
|
136
138
|
connection = await pool.getConnection(operation);
|
|
@@ -174,7 +176,7 @@ export class SqlConnection {
|
|
|
174
176
|
try {
|
|
175
177
|
lease.operation.check();
|
|
176
178
|
dispatched = true;
|
|
177
|
-
const result = await lease.connection.execute<
|
|
179
|
+
const result = await lease.connection.execute<ISqlWriteAcknowledgement>(statement.sql, boundValues(statement));
|
|
178
180
|
return mutationResult(result);
|
|
179
181
|
} catch (error) {
|
|
180
182
|
if (dispatched && (lease.operation.signal.aborted || !lease.connection.isValid())) {
|
|
@@ -328,7 +330,8 @@ export class SqlTransaction {
|
|
|
328
330
|
|
|
329
331
|
public execute(statement: ISqlStatement): Promise<ISqlMutationResult> {
|
|
330
332
|
validateStatement(statement);
|
|
331
|
-
return this.run(async () => mutationResult(
|
|
333
|
+
return this.run(async () => mutationResult(
|
|
334
|
+
await this.lease.connection.execute<ISqlWriteAcknowledgement>(statement.sql, boundValues(statement))));
|
|
332
335
|
}
|
|
333
336
|
|
|
334
337
|
public query<Row = Record<string, unknown>>(statement: ISqlStatement, options: Pick<IQueryOptions, 'maxRows' | 'maxBytes'> = {}): Promise<Row[]> {
|
package/ts/sqldb/interfaces.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface ISqlMutationResult {
|
|
|
9
9
|
insertId?: bigint;
|
|
10
10
|
completion: 'acknowledged';
|
|
11
11
|
}
|
|
12
|
+
/** What a write acknowledgement carries on the wire; the driver's own result satisfies it. */
|
|
13
|
+
export interface ISqlWriteAcknowledgement {
|
|
14
|
+
affectedRows: number;
|
|
15
|
+
insertId?: number | bigint;
|
|
16
|
+
}
|
|
12
17
|
export interface IInsertOptions extends IOperationOptions { batchSize?: number; maxBatchBytes?: number }
|
|
13
18
|
export interface IClickHouseConnectionOptions {
|
|
14
19
|
backend: 'clickhouse';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a pooled connection offers the holder of its lease. The pool speaks the driver's types;
|
|
5
|
+
* this seam is the client's own, so the connection and transaction declarations never name the driver.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISqlLeaseConnection {
|
|
8
|
+
execute<Result>(sql: string, values?: readonly unknown[]): Promise<Result>;
|
|
9
|
+
beginTransaction(): Promise<void>;
|
|
10
|
+
commit(): Promise<void>;
|
|
11
|
+
rollback(): Promise<void>;
|
|
12
|
+
queryStream(sql: string, values?: readonly unknown[]): plugins.stream.Readable;
|
|
13
|
+
isValid(): boolean;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
release(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as plugins from './plugins.mariadb.js';
|
|
2
|
+
import type { ISqlLeaseConnection } from './internal.lease.js';
|
|
2
3
|
import type { Operation } from '../core/classes.operation.js';
|
|
3
4
|
import { LosslessClientError } from '../core/classes.error.js';
|
|
4
5
|
|
|
@@ -112,7 +113,7 @@ export class SqlPool {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/** A lease can never affect a physical connection after returning ownership to the pool. */
|
|
115
|
-
export class SqlPooledConnection {
|
|
116
|
+
export class SqlPooledConnection implements ISqlLeaseConnection {
|
|
116
117
|
private readonly tasks = new Set<Promise<unknown>>();
|
|
117
118
|
private readonly streams = new Set<plugins.stream.Readable>();
|
|
118
119
|
private released = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
// The MariaDB driver plus the shared Node built-ins. Only modules that speak to the driver import this.
|
|
1
2
|
import * as mariadb from 'mariadb';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { mariadb, stream, net };
|
|
3
|
+
export * from './plugins.js';
|
|
4
|
+
export { mariadb };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Node built-ins the relational families share. Driver packages stay in their own plugin modules,
|
|
2
|
+
// so a declaration that needs none of them never reaches an optional peer.
|
|
3
|
+
import * as net from 'node:net';
|
|
4
|
+
import * as stream from 'node:stream';
|
|
5
|
+
import * as tls from 'node:tls';
|
|
6
|
+
|
|
7
|
+
export { net, stream, tls };
|