@supalive/core 1.18.0 → 1.20.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/index-BuWa503L.d.ts +2445 -0
- package/dist/index-BuWa503L.d.ts.map +1 -0
- package/dist/index-CBIjmPUS.d.ts +2444 -0
- package/dist/index-CBIjmPUS.d.ts.map +1 -0
- package/dist/index-CKo6HvJc.d.ts +2455 -0
- package/dist/index-CKo6HvJc.d.ts.map +1 -0
- package/dist/index-DShKjpzF.d.ts +2453 -0
- package/dist/index-DShKjpzF.d.ts.map +1 -0
- package/dist/index-Dcxf_Gm-.d.ts +2454 -0
- package/dist/index-Dcxf_Gm-.d.ts.map +1 -0
- package/dist/index-DsBAE32T.d.ts +2459 -0
- package/dist/index-DsBAE32T.d.ts.map +1 -0
- package/dist/logger-DrXccWFZ.js +346 -0
- package/dist/logger-DrXccWFZ.js.map +1 -0
- package/dist/mysql-B2u0Ye4x.d.ts +114 -0
- package/dist/mysql-B2u0Ye4x.d.ts.map +1 -0
- package/dist/mysql-BHW-tAqt.d.ts +114 -0
- package/dist/mysql-BHW-tAqt.d.ts.map +1 -0
- package/dist/mysql-C79_qNQO.d.ts +114 -0
- package/dist/mysql-C79_qNQO.d.ts.map +1 -0
- package/dist/mysql-C_TTCZ8j.d.ts +114 -0
- package/dist/mysql-C_TTCZ8j.d.ts.map +1 -0
- package/dist/mysql-CyzJqrvO.d.ts +114 -0
- package/dist/mysql-CyzJqrvO.d.ts.map +1 -0
- package/dist/mysql-ygH2EMGn.js +622 -0
- package/dist/mysql-ygH2EMGn.js.map +1 -0
- package/dist/mysql-z9Jefhd6.d.ts +114 -0
- package/dist/mysql-z9Jefhd6.d.ts.map +1 -0
- package/dist/object-storage-DTVmZq3l.d.ts +110 -0
- package/dist/object-storage-DTVmZq3l.d.ts.map +1 -0
- package/dist/one-shot-query-9mCboWaB.js +565 -0
- package/dist/one-shot-query-9mCboWaB.js.map +1 -0
- package/dist/one-shot-query-B9SjfcCD.js +550 -0
- package/dist/one-shot-query-B9SjfcCD.js.map +1 -0
- package/dist/one-shot-query-BBiv9LGP.js +565 -0
- package/dist/one-shot-query-BBiv9LGP.js.map +1 -0
- package/dist/one-shot-query-Bxz_N-NE.js +563 -0
- package/dist/one-shot-query-Bxz_N-NE.js.map +1 -0
- package/dist/one-shot-query-DE9oQU40.js +550 -0
- package/dist/one-shot-query-DE9oQU40.js.map +1 -0
- package/dist/one-shot-query-adoWqGLs.js +565 -0
- package/dist/one-shot-query-adoWqGLs.js.map +1 -0
- package/dist/overlap-checker-CCgq_Tpa.js +284 -0
- package/dist/overlap-checker-CCgq_Tpa.js.map +1 -0
- package/dist/postgres-B2FLN1Kw.d.ts +118 -0
- package/dist/postgres-B2FLN1Kw.d.ts.map +1 -0
- package/dist/postgres-C7xHWbij.d.ts +118 -0
- package/dist/postgres-C7xHWbij.d.ts.map +1 -0
- package/dist/postgres-DBMAv_dq.d.ts +118 -0
- package/dist/postgres-DBMAv_dq.d.ts.map +1 -0
- package/dist/postgres-DBuP9ON_.d.ts +118 -0
- package/dist/postgres-DBuP9ON_.d.ts.map +1 -0
- package/dist/postgres-DwiUT_A6.js +867 -0
- package/dist/postgres-DwiUT_A6.js.map +1 -0
- package/dist/postgres-I4sgdBnG.d.ts +118 -0
- package/dist/postgres-I4sgdBnG.d.ts.map +1 -0
- package/dist/postgres-SM8muZqN.d.ts +118 -0
- package/dist/postgres-SM8muZqN.d.ts.map +1 -0
- package/dist/router-DP2ThAwh.js.map +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.js +47 -50
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/exports/mysql.d.ts +1 -1
- package/dist/src/exports/mysql.js +1 -1
- package/dist/src/exports/postgres.d.ts +1 -1
- package/dist/src/exports/postgres.js +1 -1
- package/dist/src/exports/procedure.d.ts +1 -1
- package/dist/src/exports/schema-sql.d.ts +1 -1
- package/dist/src/exports/server.d.ts +11 -4
- package/dist/src/exports/server.d.ts.map +1 -1
- package/dist/src/exports/server.js +31 -410
- package/dist/src/exports/server.js.map +1 -1
- package/dist/src/exports/storage.d.ts +4 -2
- package/dist/src/exports/storage.d.ts.map +1 -1
- package/dist/src/exports/storage.js +23 -1
- package/dist/src/exports/storage.js.map +1 -1
- package/dist/src/exports/sub-manager-worker-entry.js +1 -1
- package/dist/src/exports/types.d.ts +2 -2
- package/dist/sub-worker-dispatch-BLujn13f.js +792 -0
- package/dist/sub-worker-dispatch-BLujn13f.js.map +1 -0
- package/dist/types_server-BCst4TfZ.d.ts +703 -0
- package/dist/types_server-BCst4TfZ.d.ts.map +1 -0
- package/dist/types_server-BYwLkwbC.d.ts +691 -0
- package/dist/types_server-BYwLkwbC.d.ts.map +1 -0
- package/dist/types_server-Bvrohyc8.d.ts +691 -0
- package/dist/types_server-Bvrohyc8.d.ts.map +1 -0
- package/dist/types_server-C6oCm9oC.d.ts +691 -0
- package/dist/types_server-C6oCm9oC.d.ts.map +1 -0
- package/dist/types_server-CHJLfdxb.d.ts +691 -0
- package/dist/types_server-CHJLfdxb.d.ts.map +1 -0
- package/dist/types_server-DnO_fp-F.d.ts +691 -0
- package/dist/types_server-DnO_fp-F.d.ts.map +1 -0
- package/dist/types_server-gSgzZHuD.d.ts +703 -0
- package/dist/types_server-gSgzZHuD.d.ts.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Jn as DbQueryResult, Kn as CoreInitLockCtx, Qn as PreparedQueries, Xn as LazyCommitTsParam, Yn as DbType, Zn as PooledClient, er as SqlBuilder, ii as WriteEntry, nr as CacheLayer, qn as Database, ti as ReadEntry, tr as TxDatabase, wr as CommitLogEntry } from "./index-Dcxf_Gm-.js";
|
|
2
|
+
import { Pool, PoolOptions } from "mysql2/promise";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/mysql.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* mysql2's PoolOptions does not have a per-statement timeout field; we
|
|
8
|
+
* carry our own. Set 0 to disable.
|
|
9
|
+
*/
|
|
10
|
+
type MySqlPoolOptions = PoolOptions & {
|
|
11
|
+
queryTimeoutMs?: number;
|
|
12
|
+
};
|
|
13
|
+
declare class MySqlDatabase implements Database {
|
|
14
|
+
constructor(logger: Logger, config: MySqlPoolOptions, pool?: Pool | undefined);
|
|
15
|
+
private logger;
|
|
16
|
+
config: PoolOptions;
|
|
17
|
+
protected queryTimeoutMs: number;
|
|
18
|
+
private pool;
|
|
19
|
+
readonly dbType: DbType;
|
|
20
|
+
readonly sqlBuilder: SqlBuilder;
|
|
21
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
22
|
+
protected sqlCache: Map<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetches actual column types from MySQL for `table` and returns a
|
|
25
|
+
* map of DB column name → MySQL type string (as produced by `COLUMN_TYPE`,
|
|
26
|
+
* e.g. `bigint`, `integer`, `varchar(32)`, `text`, `json`).
|
|
27
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
28
|
+
*/
|
|
29
|
+
loadColumnTypesFromMySql(table: string): Promise<Map<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
32
|
+
* batched write, so it can't await — populate the cache via
|
|
33
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
34
|
+
* missing (programmer error / bootstrap skipped).
|
|
35
|
+
*/
|
|
36
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
39
|
+
* client supplied, attempts the cache key first and falls through to
|
|
40
|
+
* MySQL on miss (writing the result back to Redis). This is the
|
|
41
|
+
* "one server queries MySQL, the rest read from Redis" pattern for cold
|
|
42
|
+
* starts in a multi-instance deploy. Without Redis, always queries MySQL.
|
|
43
|
+
*
|
|
44
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
45
|
+
* user table in the connected database is loaded.
|
|
46
|
+
*
|
|
47
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
48
|
+
* environment (typically a schema version / deploy version). The
|
|
49
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
50
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
51
|
+
*/
|
|
52
|
+
bootstrapColumnTypes(opts: {
|
|
53
|
+
redis?: CacheLayer;
|
|
54
|
+
cacheKey: string;
|
|
55
|
+
tables?: string[];
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
59
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
60
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
61
|
+
*/
|
|
62
|
+
invalidateColumnTypes(table?: string): void;
|
|
63
|
+
/** Replace this instance's caches with shared references from a parent.
|
|
64
|
+
* Used by getTransactionClient so types loaded once at startup are
|
|
65
|
+
* visible inside transactions. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
/** Enumerate the user-defined tables in the connected database for mysql — used
|
|
68
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
69
|
+
private listUserTables;
|
|
70
|
+
getCoreVersion(): Promise<bigint>;
|
|
71
|
+
getAppMigration(): Promise<bigint>;
|
|
72
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
73
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
74
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
75
|
+
getClient(): Promise<PooledClient>;
|
|
76
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
77
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
78
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
79
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
80
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
81
|
+
getNextTimestamp(): Promise<bigint>;
|
|
82
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
83
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
84
|
+
private mysqlPrepareBatchWrites;
|
|
85
|
+
private mysqlPrepareInsertBatch;
|
|
86
|
+
private mysqlPrepareUpdateSingle;
|
|
87
|
+
private mysqlPrepareDeleteBatch;
|
|
88
|
+
private mysqlPrepareCommitLogs;
|
|
89
|
+
/**
|
|
90
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
91
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
92
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
93
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
94
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
95
|
+
*/
|
|
96
|
+
private mysqlPrepareValidatePointReadsByCommitTs;
|
|
97
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
98
|
+
success: boolean;
|
|
99
|
+
}>;
|
|
100
|
+
private mysqlApplyWrites;
|
|
101
|
+
private validatePointReadsByCommitTs;
|
|
102
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
103
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
104
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
105
|
+
hasCommitForPoints(beginTs: bigint, endTs: bigint, points: {
|
|
106
|
+
tableId: Uint8Array;
|
|
107
|
+
id: Uint8Array;
|
|
108
|
+
}[]): Promise<boolean>;
|
|
109
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
110
|
+
close(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { MySqlDatabase as t };
|
|
114
|
+
//# sourceMappingURL=mysql-BHW-tAqt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql-BHW-tAqt.d.ts","names":[],"sources":["../src/db/mysql.ts"],"mappings":";;;;;;;;;KAgEY,gBAAA,GAAmB,WAAW;EAAK,cAAc;AAAA;AAAA,cAEhD,aAAA,YAAyB,QAAA;cAElC,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,gBAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAaA,MAAA;EACD,MAAA,EAAQ,WAAA;EAAA,UACL,cAAA;EAAA,QACF,IAAA;EAAA,SACC,MAAA,EAAQ,MAAA;EAAA,SACR,UAAA,EAAY,UAAA;EAMd,WAAA,EAAa,GAAA,SAAY,GAAA;EAAA,UAGtB,QAAA,EAAU,GAAA;EA+IK;;;;;;EAvInB,wBAAA,CAAyB,KAAA,WAAgB,OAAA,CAAQ,GAAA;EAiN5B;;;;;;EAzL3B,cAAA,CAAe,KAAA,WAAgB,GAAA;EAsNe;;;;;;;;;;;;;;;EA9LxC,oBAAA,CAAqB,IAAA;IACzB,KAAA,GAAQ,UAAA;IACR,QAAA;IACA,MAAA;EAAA,IACE,OAAA;EAgtBqE;;;;;EAtqBzE,qBAAA,CAAsB,KAAA;EArIsB;;;EAoJ5C,WAAA,CACE,WAAA,EAAa,GAAA,SAAY,GAAA,mBACzB,QAAA,EAAU,GAAA;EApJV;;EAAA,QA4JY,cAAA;EASR,cAAA,IAAkB,OAAA;EAOlB,eAAA,IAAmB,OAAA;EAYzB,uBAAA,CAAwB,SAAA;EAWlB,gBAAA,CAAiB,EAAA,GAAK,GAAA,EAAK,eAAA,KAAoB,OAAA,SAAgB,OAAA;EAqC/D,KAAA,UAAe,GAAA,UAAa,MAAA,eAAyB,OAA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Yn as DbType, Zn as PooledClient, er as SqlBuilder, ii as WriteEntry, nr as CacheLayer, qn as Database, ti as ReadEntry, tr as TxDatabase, wr as CommitLogEntry } from "./index-DsBAE32T.js";
|
|
2
|
+
import { Pool, PoolOptions } from "mysql2/promise";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/mysql.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* mysql2's PoolOptions does not have a per-statement timeout field; we
|
|
8
|
+
* carry our own. Set 0 to disable.
|
|
9
|
+
*/
|
|
10
|
+
type MySqlPoolOptions = PoolOptions & {
|
|
11
|
+
queryTimeoutMs?: number;
|
|
12
|
+
};
|
|
13
|
+
declare class MySqlDatabase implements Database {
|
|
14
|
+
constructor(logger: Logger, config: MySqlPoolOptions, pool?: Pool | undefined);
|
|
15
|
+
private logger;
|
|
16
|
+
config: PoolOptions;
|
|
17
|
+
protected queryTimeoutMs: number;
|
|
18
|
+
private pool;
|
|
19
|
+
readonly dbType: DbType;
|
|
20
|
+
readonly sqlBuilder: SqlBuilder;
|
|
21
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
22
|
+
protected sqlCache: Map<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetches actual column types from MySQL for `table` and returns a
|
|
25
|
+
* map of DB column name → MySQL type string (as produced by `COLUMN_TYPE`,
|
|
26
|
+
* e.g. `bigint`, `integer`, `varchar(32)`, `text`, `json`).
|
|
27
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
28
|
+
*/
|
|
29
|
+
loadColumnTypesFromMySql(table: string): Promise<Map<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
32
|
+
* batched write, so it can't await — populate the cache via
|
|
33
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
34
|
+
* missing (programmer error / bootstrap skipped).
|
|
35
|
+
*/
|
|
36
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
39
|
+
* client supplied, attempts the cache key first and falls through to
|
|
40
|
+
* MySQL on miss (writing the result back to Redis). This is the
|
|
41
|
+
* "one server queries MySQL, the rest read from Redis" pattern for cold
|
|
42
|
+
* starts in a multi-instance deploy. Without Redis, always queries MySQL.
|
|
43
|
+
*
|
|
44
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
45
|
+
* user table in the connected database is loaded.
|
|
46
|
+
*
|
|
47
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
48
|
+
* environment (typically a schema version / deploy version). The
|
|
49
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
50
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
51
|
+
*/
|
|
52
|
+
bootstrapColumnTypes(opts: {
|
|
53
|
+
redis?: CacheLayer;
|
|
54
|
+
cacheKey: string;
|
|
55
|
+
tables?: string[];
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
59
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
60
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
61
|
+
*/
|
|
62
|
+
invalidateColumnTypes(table?: string): void;
|
|
63
|
+
/** Replace this instance's caches with shared references from a parent.
|
|
64
|
+
* Used by getTransactionClient so types loaded once at startup are
|
|
65
|
+
* visible inside transactions. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
/** Enumerate the user-defined tables in the connected database for mysql — used
|
|
68
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
69
|
+
private listUserTables;
|
|
70
|
+
getCoreVersion(): Promise<bigint>;
|
|
71
|
+
getAppMigration(): Promise<bigint>;
|
|
72
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
73
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
74
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
75
|
+
getClient(): Promise<PooledClient>;
|
|
76
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
77
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
78
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
79
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
80
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
81
|
+
getNextTimestamp(): Promise<bigint>;
|
|
82
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
83
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
84
|
+
private mysqlPrepareBatchWrites;
|
|
85
|
+
private mysqlPrepareInsertBatch;
|
|
86
|
+
private mysqlPrepareUpdateSingle;
|
|
87
|
+
private mysqlPrepareDeleteBatch;
|
|
88
|
+
private mysqlPrepareCommitLogs;
|
|
89
|
+
/**
|
|
90
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
91
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
92
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
93
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
94
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
95
|
+
*/
|
|
96
|
+
private mysqlPrepareValidatePointReadsByCommitTs;
|
|
97
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
98
|
+
success: boolean;
|
|
99
|
+
}>;
|
|
100
|
+
private mysqlApplyWrites;
|
|
101
|
+
private validatePointReadsByCommitTs;
|
|
102
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
103
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
104
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
105
|
+
hasCommitForPoints(beginTs: bigint, endTs: bigint, points: {
|
|
106
|
+
tableId: Uint8Array;
|
|
107
|
+
id: Uint8Array;
|
|
108
|
+
}[]): Promise<boolean>;
|
|
109
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
110
|
+
close(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { MySqlDatabase as t };
|
|
114
|
+
//# sourceMappingURL=mysql-C79_qNQO.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql-C79_qNQO.d.ts","names":[],"sources":["../src/db/mysql.ts"],"mappings":";;;;;;;;;KAgEY,gBAAA,GAAmB,WAAW;EAAK,cAAc;AAAA;AAAA,cAEhD,aAAA,YAAyB,QAAA;cAElC,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,gBAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAaA,MAAA;EACD,MAAA,EAAQ,WAAA;EAAA,UACL,cAAA;EAAA,QACF,IAAA;EAAA,SACC,MAAA,EAAQ,MAAA;EAAA,SACR,UAAA,EAAY,UAAA;EAMd,WAAA,EAAa,GAAA,SAAY,GAAA;EAAA,UAGtB,QAAA,EAAU,GAAA;EA+IK;;;;;;EAvInB,wBAAA,CAAyB,KAAA,WAAgB,OAAA,CAAQ,GAAA;EAiN5B;;;;;;EAzL3B,cAAA,CAAe,KAAA,WAAgB,GAAA;EAsNe;;;;;;;;;;;;;;;EA9LxC,oBAAA,CAAqB,IAAA;IACzB,KAAA,GAAQ,UAAA;IACR,QAAA;IACA,MAAA;EAAA,IACE,OAAA;EAgtBqE;;;;;EAtqBzE,qBAAA,CAAsB,KAAA;EArIsB;;;EAoJ5C,WAAA,CACE,WAAA,EAAa,GAA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AY,EAAA,EAAI,UAAA;EAAA,MAClC,OAAA;EAoBG,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Jn as DbQueryResult, Kn as CoreInitLockCtx, Qn as PreparedQueries, Xn as LazyCommitTsParam, Yn as DbType, Zn as PooledClient, er as SqlBuilder, ii as WriteEntry, nr as CacheLayer, qn as Database, ti as ReadEntry, tr as TxDatabase, wr as CommitLogEntry } from "./index-BuWa503L.js";
|
|
2
|
+
import { Pool, PoolOptions } from "mysql2/promise";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/mysql.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* mysql2's PoolOptions does not have a per-statement timeout field; we
|
|
8
|
+
* carry our own. Set 0 to disable.
|
|
9
|
+
*/
|
|
10
|
+
type MySqlPoolOptions = PoolOptions & {
|
|
11
|
+
queryTimeoutMs?: number;
|
|
12
|
+
};
|
|
13
|
+
declare class MySqlDatabase implements Database {
|
|
14
|
+
constructor(logger: Logger, config: MySqlPoolOptions, pool?: Pool | undefined);
|
|
15
|
+
private logger;
|
|
16
|
+
config: PoolOptions;
|
|
17
|
+
protected queryTimeoutMs: number;
|
|
18
|
+
private pool;
|
|
19
|
+
readonly dbType: DbType;
|
|
20
|
+
readonly sqlBuilder: SqlBuilder;
|
|
21
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
22
|
+
protected sqlCache: Map<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetches actual column types from MySQL for `table` and returns a
|
|
25
|
+
* map of DB column name → MySQL type string (as produced by `COLUMN_TYPE`,
|
|
26
|
+
* e.g. `bigint`, `integer`, `varchar(32)`, `text`, `json`).
|
|
27
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
28
|
+
*/
|
|
29
|
+
loadColumnTypesFromMySql(table: string): Promise<Map<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
32
|
+
* batched write, so it can't await — populate the cache via
|
|
33
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
34
|
+
* missing (programmer error / bootstrap skipped).
|
|
35
|
+
*/
|
|
36
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
39
|
+
* client supplied, attempts the cache key first and falls through to
|
|
40
|
+
* MySQL on miss (writing the result back to Redis). This is the
|
|
41
|
+
* "one server queries MySQL, the rest read from Redis" pattern for cold
|
|
42
|
+
* starts in a multi-instance deploy. Without Redis, always queries MySQL.
|
|
43
|
+
*
|
|
44
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
45
|
+
* user table in the connected database is loaded.
|
|
46
|
+
*
|
|
47
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
48
|
+
* environment (typically a schema version / deploy version). The
|
|
49
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
50
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
51
|
+
*/
|
|
52
|
+
bootstrapColumnTypes(opts: {
|
|
53
|
+
redis?: CacheLayer;
|
|
54
|
+
cacheKey: string;
|
|
55
|
+
tables?: string[];
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
59
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
60
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
61
|
+
*/
|
|
62
|
+
invalidateColumnTypes(table?: string): void;
|
|
63
|
+
/** Replace this instance's caches with shared references from a parent.
|
|
64
|
+
* Used by getTransactionClient so types loaded once at startup are
|
|
65
|
+
* visible inside transactions. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
/** Enumerate the user-defined tables in the connected database for mysql — used
|
|
68
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
69
|
+
private listUserTables;
|
|
70
|
+
getCoreVersion(): Promise<bigint>;
|
|
71
|
+
getAppMigration(): Promise<bigint>;
|
|
72
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
73
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
74
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
75
|
+
getClient(): Promise<PooledClient>;
|
|
76
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
77
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
78
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
79
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
80
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
81
|
+
getNextTimestamp(): Promise<bigint>;
|
|
82
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
83
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
84
|
+
private mysqlPrepareBatchWrites;
|
|
85
|
+
private mysqlPrepareInsertBatch;
|
|
86
|
+
private mysqlPrepareUpdateSingle;
|
|
87
|
+
private mysqlPrepareDeleteBatch;
|
|
88
|
+
private mysqlPrepareCommitLogs;
|
|
89
|
+
/**
|
|
90
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
91
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
92
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
93
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
94
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
95
|
+
*/
|
|
96
|
+
private mysqlPrepareValidatePointReadsByCommitTs;
|
|
97
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
98
|
+
success: boolean;
|
|
99
|
+
}>;
|
|
100
|
+
private mysqlApplyWrites;
|
|
101
|
+
private validatePointReadsByCommitTs;
|
|
102
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
103
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
104
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
105
|
+
hasCommitForPoints(beginTs: bigint, endTs: bigint, points: {
|
|
106
|
+
tableId: Uint8Array;
|
|
107
|
+
id: Uint8Array;
|
|
108
|
+
}[]): Promise<boolean>;
|
|
109
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
110
|
+
close(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { MySqlDatabase as t };
|
|
114
|
+
//# sourceMappingURL=mysql-C_TTCZ8j.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql-C_TTCZ8j.d.ts","names":[],"sources":["../src/db/mysql.ts"],"mappings":";;;;;;;;;KAgEY,gBAAA,GAAmB,WAAW;EAAK,cAAc;AAAA;AAAA,cAEhD,aAAA,YAAyB,QAAA;cAElC,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,gBAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAaA,MAAA;EACD,MAAA,EAAQ,WAAA;EAAA,UACL,cAAA;EAAA,QACF,IAAA;EAAA,SACC,MAAA,EAAQ,MAAA;EAAA,SACR,UAAA,EAAY,UAAA;EAMd,WAAA,EAAa,GAAA,SAAY,GAAA;EAAA,UAGtB,QAAA,EAAU,GAAA;EA+IK;;;;;;EAvInB,wBAAA,CAAyB,KAAA,WAAgB,OAAA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;EAAA,QAqCC,gBAAA;EAAA,QAyDA,4BAAA;EAwCR,qBAAA,CAAsB,EAAA,WAAa,OAAA;EAQnC,iBAAA,IAAqB,OAAA;EAQrB,sBAAA,CAAuB,OAAA,UAAiB,KAAA,UAAe,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmBxF,kBAAA,CACJ,OAAA,UACA,KAAA,UACA,MAAA;IAAU,OAAA,EAAS,UAAA;IAAY,EAAA,EAAI,UAAA;EAAA,MAClC,OAAA;EAoBG,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Jn as DbQueryResult, Kn as CoreInitLockCtx, Qn as PreparedQueries, Xn as LazyCommitTsParam, Yn as DbType, Zn as PooledClient, er as SqlBuilder, ii as WriteEntry, nr as CacheLayer, qn as Database, ti as ReadEntry, tr as TxDatabase, wr as CommitLogEntry } from "./index-CKo6HvJc.js";
|
|
2
|
+
import { Pool, PoolOptions } from "mysql2/promise";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/mysql.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* mysql2's PoolOptions does not have a per-statement timeout field; we
|
|
8
|
+
* carry our own. Set 0 to disable.
|
|
9
|
+
*/
|
|
10
|
+
type MySqlPoolOptions = PoolOptions & {
|
|
11
|
+
queryTimeoutMs?: number;
|
|
12
|
+
};
|
|
13
|
+
declare class MySqlDatabase implements Database {
|
|
14
|
+
constructor(logger: Logger, config: MySqlPoolOptions, pool?: Pool | undefined);
|
|
15
|
+
private logger;
|
|
16
|
+
config: PoolOptions;
|
|
17
|
+
protected queryTimeoutMs: number;
|
|
18
|
+
private pool;
|
|
19
|
+
readonly dbType: DbType;
|
|
20
|
+
readonly sqlBuilder: SqlBuilder;
|
|
21
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
22
|
+
protected sqlCache: Map<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetches actual column types from MySQL for `table` and returns a
|
|
25
|
+
* map of DB column name → MySQL type string (as produced by `COLUMN_TYPE`,
|
|
26
|
+
* e.g. `bigint`, `integer`, `varchar(32)`, `text`, `json`).
|
|
27
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
28
|
+
*/
|
|
29
|
+
loadColumnTypesFromMySql(table: string): Promise<Map<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
32
|
+
* batched write, so it can't await — populate the cache via
|
|
33
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
34
|
+
* missing (programmer error / bootstrap skipped).
|
|
35
|
+
*/
|
|
36
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
39
|
+
* client supplied, attempts the cache key first and falls through to
|
|
40
|
+
* MySQL on miss (writing the result back to Redis). This is the
|
|
41
|
+
* "one server queries MySQL, the rest read from Redis" pattern for cold
|
|
42
|
+
* starts in a multi-instance deploy. Without Redis, always queries MySQL.
|
|
43
|
+
*
|
|
44
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
45
|
+
* user table in the connected database is loaded.
|
|
46
|
+
*
|
|
47
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
48
|
+
* environment (typically a schema version / deploy version). The
|
|
49
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
50
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
51
|
+
*/
|
|
52
|
+
bootstrapColumnTypes(opts: {
|
|
53
|
+
redis?: CacheLayer;
|
|
54
|
+
cacheKey: string;
|
|
55
|
+
tables?: string[];
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
59
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
60
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
61
|
+
*/
|
|
62
|
+
invalidateColumnTypes(table?: string): void;
|
|
63
|
+
/** Replace this instance's caches with shared references from a parent.
|
|
64
|
+
* Used by getTransactionClient so types loaded once at startup are
|
|
65
|
+
* visible inside transactions. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
/** Enumerate the user-defined tables in the connected database for mysql — used
|
|
68
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
69
|
+
private listUserTables;
|
|
70
|
+
getCoreVersion(): Promise<bigint>;
|
|
71
|
+
getAppMigration(): Promise<bigint>;
|
|
72
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
73
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
74
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
75
|
+
getClient(): Promise<PooledClient>;
|
|
76
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
77
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
78
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
79
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
80
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
81
|
+
getNextTimestamp(): Promise<bigint>;
|
|
82
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
83
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
84
|
+
private mysqlPrepareBatchWrites;
|
|
85
|
+
private mysqlPrepareInsertBatch;
|
|
86
|
+
private mysqlPrepareUpdateSingle;
|
|
87
|
+
private mysqlPrepareDeleteBatch;
|
|
88
|
+
private mysqlPrepareCommitLogs;
|
|
89
|
+
/**
|
|
90
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
91
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
92
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
93
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
94
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
95
|
+
*/
|
|
96
|
+
private mysqlPrepareValidatePointReadsByCommitTs;
|
|
97
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
98
|
+
success: boolean;
|
|
99
|
+
}>;
|
|
100
|
+
private mysqlApplyWrites;
|
|
101
|
+
private validatePointReadsByCommitTs;
|
|
102
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
103
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
104
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
105
|
+
hasCommitForPoints(beginTs: bigint, endTs: bigint, points: {
|
|
106
|
+
tableId: Uint8Array;
|
|
107
|
+
id: Uint8Array;
|
|
108
|
+
}[]): Promise<boolean>;
|
|
109
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
110
|
+
close(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { MySqlDatabase as t };
|
|
114
|
+
//# sourceMappingURL=mysql-CyzJqrvO.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql-CyzJqrvO.d.ts","names":[],"sources":["../src/db/mysql.ts"],"mappings":";;;;;;;;;KAgEY,gBAAA,GAAmB,WAAW;EAAK,cAAc;AAAA;AAAA,cAEhD,aAAA,YAAyB,QAAA;cAElC,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,gBAAA,EAC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