@volter/world-core 3.0.69 → 3.0.71
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/capability-decision.cjs +63 -9
- package/capability-decision.d.cts +12 -6
- package/dist/capability-decision.cjs +63 -9
- package/dist/capability-decision.d.cts +12 -6
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/mysql/client.d.ts +28 -0
- package/dist/src/mysql/client.js +220 -0
- package/dist/src/mysql/index.d.ts +2 -0
- package/dist/src/mysql/index.js +5 -0
- package/dist/src/mysql/stream.d.ts +113 -0
- package/dist/src/mysql/stream.js +648 -0
- package/package.json +5 -1
- package/src/index.ts +1 -0
- package/src/mysql/client.ts +159 -0
- package/src/mysql/index.ts +5 -0
- package/src/mysql/stream.ts +490 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { TwinStream } from '../twin-fetch.js';
|
|
2
|
+
/** A column as the pack's engine describes it: MySQL's column type code (`MysqlType`) and flags. */
|
|
3
|
+
export type MysqlColumn = {
|
|
4
|
+
name: string;
|
|
5
|
+
type: number;
|
|
6
|
+
flags?: number;
|
|
7
|
+
charset?: number;
|
|
8
|
+
length?: number;
|
|
9
|
+
decimals?: number;
|
|
10
|
+
table?: string;
|
|
11
|
+
orgTable?: string;
|
|
12
|
+
orgName?: string;
|
|
13
|
+
schema?: string;
|
|
14
|
+
};
|
|
15
|
+
/** A statement's outcome: rows (each value as MySQL's text protocol carries it, or null), or a count, or MySQL's error. */
|
|
16
|
+
export type MysqlOutcome = {
|
|
17
|
+
columns: MysqlColumn[];
|
|
18
|
+
rows: (string | Uint8Array | null)[][];
|
|
19
|
+
warnings?: number;
|
|
20
|
+
} | {
|
|
21
|
+
affectedRows: number;
|
|
22
|
+
insertId?: number | bigint;
|
|
23
|
+
warnings?: number;
|
|
24
|
+
info?: string;
|
|
25
|
+
} | {
|
|
26
|
+
error: MysqlError;
|
|
27
|
+
};
|
|
28
|
+
export type MysqlError = {
|
|
29
|
+
errno: number;
|
|
30
|
+
sqlstate: string;
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
export type MysqlStreamOptions<Session> = {
|
|
34
|
+
/** The handshake's server version: the one the pack's engine reports for `VERSION()`. */
|
|
35
|
+
version: string;
|
|
36
|
+
/** Admit `user` to `database` (null: none named) when `check` accepts what the pack stores for it: the password, or
|
|
37
|
+
* MySQL's own stored form of it (`nativePasswordHash`, SHA1(SHA1(password)), as a server keeps it). */
|
|
38
|
+
connect(user: string, database: string | null, check: MysqlPasswordCheck): Promise<{
|
|
39
|
+
session: Session;
|
|
40
|
+
} | {
|
|
41
|
+
error: MysqlError;
|
|
42
|
+
}>;
|
|
43
|
+
/** Execute ONE statement (the kernel splits a script and binds parameters into the text) on the session. */
|
|
44
|
+
execute(session: Session, sql: string): Promise<MysqlOutcome>;
|
|
45
|
+
/** Whether the session holds an open transaction (SERVER_STATUS_IN_TRANS). */
|
|
46
|
+
inTransaction(session: Session): boolean;
|
|
47
|
+
/** Use another database on the session (COM_INIT_DB). */
|
|
48
|
+
useDatabase?(session: Session, database: string): Promise<MysqlError | null>;
|
|
49
|
+
/** The connection went away: roll back what it left open. */
|
|
50
|
+
close?(session: Session): void;
|
|
51
|
+
};
|
|
52
|
+
/** MySQL's column type codes. */
|
|
53
|
+
export declare const MysqlType: {
|
|
54
|
+
readonly DECIMAL: 0;
|
|
55
|
+
readonly TINY: 1;
|
|
56
|
+
readonly SHORT: 2;
|
|
57
|
+
readonly LONG: 3;
|
|
58
|
+
readonly FLOAT: 4;
|
|
59
|
+
readonly DOUBLE: 5;
|
|
60
|
+
readonly NULL: 6;
|
|
61
|
+
readonly TIMESTAMP: 7;
|
|
62
|
+
readonly LONGLONG: 8;
|
|
63
|
+
readonly INT24: 9;
|
|
64
|
+
readonly DATE: 10;
|
|
65
|
+
readonly TIME: 11;
|
|
66
|
+
readonly DATETIME: 12;
|
|
67
|
+
readonly YEAR: 13;
|
|
68
|
+
readonly VARCHAR: 15;
|
|
69
|
+
readonly BIT: 16;
|
|
70
|
+
readonly JSON: 245;
|
|
71
|
+
readonly NEWDECIMAL: 246;
|
|
72
|
+
readonly ENUM: 247;
|
|
73
|
+
readonly SET: 248;
|
|
74
|
+
readonly TINY_BLOB: 249;
|
|
75
|
+
readonly MEDIUM_BLOB: 250;
|
|
76
|
+
readonly LONG_BLOB: 251;
|
|
77
|
+
readonly BLOB: 252;
|
|
78
|
+
readonly VAR_STRING: 253;
|
|
79
|
+
readonly STRING: 254;
|
|
80
|
+
readonly GEOMETRY: 255;
|
|
81
|
+
};
|
|
82
|
+
export declare const MysqlFlag: {
|
|
83
|
+
readonly NOT_NULL: 1;
|
|
84
|
+
readonly PRI_KEY: 2;
|
|
85
|
+
readonly UNIQUE_KEY: 4;
|
|
86
|
+
readonly MULTIPLE_KEY: 8;
|
|
87
|
+
readonly BLOB: 16;
|
|
88
|
+
readonly UNSIGNED: 32;
|
|
89
|
+
readonly BINARY: 128;
|
|
90
|
+
readonly AUTO_INCREMENT: 512;
|
|
91
|
+
};
|
|
92
|
+
/** Whether the client's mysql_native_password answer proves a password: from the password itself, or from MySQL's
|
|
93
|
+
* stored form of it (hex SHA1(SHA1(password))), as a MySQL server checks it without holding the password. */
|
|
94
|
+
export type MysqlPasswordCheck = {
|
|
95
|
+
password(password: string): boolean;
|
|
96
|
+
storedHash(hex: string): boolean;
|
|
97
|
+
};
|
|
98
|
+
/** MySQL's stored form of a password for mysql_native_password: SHA1(SHA1(password)), hex. A pack keeps it when the
|
|
99
|
+
* password is made, beside whatever else it keeps, so the wire can admit the password without the pack holding it. */
|
|
100
|
+
export declare function nativePasswordHash(password: string): string;
|
|
101
|
+
/** mysql_native_password's token for `password` against `scramble`: SHA1(pw) XOR SHA1(scramble + SHA1(SHA1(pw))). */
|
|
102
|
+
export declare function nativePasswordToken(password: string, scramble: Uint8Array): Uint8Array;
|
|
103
|
+
/** A multi-statement script's statements, empty ones dropped. */
|
|
104
|
+
export declare function splitStatements(sql: string): string[];
|
|
105
|
+
export declare function countPlaceholders(sql: string): number;
|
|
106
|
+
/** A bound parameter: an integer, a float, text, bytes (a BLOB parameter, or text that is not UTF-8), a date or time. */
|
|
107
|
+
export type MysqlParam = null | bigint | number | string | Uint8Array | {
|
|
108
|
+
date: string;
|
|
109
|
+
};
|
|
110
|
+
/** `sql` with each `?` placeholder replaced by its parameter's literal. */
|
|
111
|
+
export declare function bindParameters(sql: string, params: MysqlParam[]): string;
|
|
112
|
+
/** A MySQL server as a TwinStream: the protocol here, the meaning in `options`. */
|
|
113
|
+
export declare function createMysqlStream<Session>(options: MysqlStreamOptions<Session>): TwinStream;
|