@supalive/core 1.3.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/index-BGITtVcD.d.ts +2106 -0
- package/dist/index-BGITtVcD.d.ts.map +1 -0
- package/dist/index-CbYOjwGh.d.ts +2105 -0
- package/dist/index-CbYOjwGh.d.ts.map +1 -0
- package/dist/index-DTNBHQPY.d.ts +2106 -0
- package/dist/index-DTNBHQPY.d.ts.map +1 -0
- package/dist/mysql-BRyidTZD.d.ts +109 -0
- package/dist/mysql-BRyidTZD.d.ts.map +1 -0
- package/dist/mysql-CLcFRLam.d.ts +109 -0
- package/dist/mysql-CLcFRLam.d.ts.map +1 -0
- package/dist/mysql-Dp6BDecZ.d.ts +109 -0
- package/dist/mysql-Dp6BDecZ.d.ts.map +1 -0
- package/dist/object-storage-354KU6Mj.d.ts +77 -0
- package/dist/object-storage-354KU6Mj.d.ts.map +1 -0
- package/dist/object-storage-hhZSz8qM.d.ts +69 -0
- package/dist/object-storage-hhZSz8qM.d.ts.map +1 -0
- package/dist/postgres-CONYSAv6.d.ts +113 -0
- package/dist/postgres-CONYSAv6.d.ts.map +1 -0
- package/dist/postgres-Dh4ATweM.d.ts +113 -0
- package/dist/postgres-Dh4ATweM.d.ts.map +1 -0
- package/dist/postgres-Dsa4m0wv.d.ts +113 -0
- package/dist/postgres-Dsa4m0wv.d.ts.map +1 -0
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/exports/mysql.d.ts +1 -1
- package/dist/src/exports/postgres.d.ts +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 +4 -4
- package/dist/src/exports/server.d.ts.map +1 -1
- package/dist/src/exports/server.js +5 -2
- package/dist/src/exports/server.js.map +1 -1
- package/dist/src/exports/storage.d.ts +30 -13
- package/dist/src/exports/storage.d.ts.map +1 -1
- package/dist/src/exports/storage.js +19 -10
- package/dist/src/exports/storage.js.map +1 -1
- package/dist/src/exports/types.d.ts +2 -2
- package/dist/types_server-BXn_YC0a.d.ts +301 -0
- package/dist/types_server-BXn_YC0a.d.ts.map +1 -0
- package/dist/types_server-CDu9dPnG.d.ts +301 -0
- package/dist/types_server-CDu9dPnG.d.ts.map +1 -0
- package/dist/types_server-CmofdaIn.d.ts +301 -0
- package/dist/types_server-CmofdaIn.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Bn as DbType, Gn as SqlBuilder, Gr as ReadEntry, Hn as PooledClient, Jr as WriteEntry, Kn as TxDatabase, Ln as CoreInitLockCtx, Rn as Database, Un as PreparedQueries, Vn as LazyCommitTsParam, mr as CommitLogEntry, qn as CacheLayer, zn as DbQueryResult } from "./index-BGITtVcD.js";
|
|
2
|
+
import { Pool, PoolConfig } from "pg";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/postgres.d.ts
|
|
6
|
+
declare class PgDatabase implements Database {
|
|
7
|
+
constructor(logger: Logger, config: PoolConfig, pool?: Pool | undefined);
|
|
8
|
+
private logger;
|
|
9
|
+
config: PoolConfig;
|
|
10
|
+
private pool;
|
|
11
|
+
readonly sqlBuilder: SqlBuilder;
|
|
12
|
+
readonly dbType: DbType;
|
|
13
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
14
|
+
protected sqlCache: Map<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches actual column types from Postgres for `table` and returns a
|
|
17
|
+
* map of DB column name → PG type string (as produced by `format_type`,
|
|
18
|
+
* e.g. `bigint`, `integer`, `character varying(32)`, `text[]`, `jsonb`).
|
|
19
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
20
|
+
*/
|
|
21
|
+
loadColumnTypesFromPg(table: string): Promise<Map<string, string>>;
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
24
|
+
* batched write, so it can't await — populate the cache via
|
|
25
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
26
|
+
* missing (programmer error / bootstrap skipped).
|
|
27
|
+
*/
|
|
28
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
29
|
+
/**
|
|
30
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
31
|
+
* client supplied, attempts the cache key first and falls through to
|
|
32
|
+
* Postgres on miss (writing the result back to Redis). This is the
|
|
33
|
+
* "one server queries PG, the rest read from Redis" pattern for cold
|
|
34
|
+
* starts in a multi-instance deploy. Without Redis, always queries PG.
|
|
35
|
+
*
|
|
36
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
37
|
+
* user table in the connected database is loaded.
|
|
38
|
+
*
|
|
39
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
40
|
+
* environment (typically a schema version / deploy version). The
|
|
41
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
42
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
43
|
+
*/
|
|
44
|
+
bootstrapColumnTypes(opts: {
|
|
45
|
+
redis?: CacheLayer;
|
|
46
|
+
cacheKey: string;
|
|
47
|
+
tables?: string[];
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
51
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
52
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
53
|
+
*/
|
|
54
|
+
private invalidateColumnTypes;
|
|
55
|
+
/** Enumerate the user-defined tables in the connected database — used
|
|
56
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
57
|
+
private listUserTables;
|
|
58
|
+
getCoreVersion(): Promise<bigint>;
|
|
59
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
60
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
61
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
62
|
+
getClient(): Promise<PooledClient>;
|
|
63
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
64
|
+
/** Internal: replace this instance's caches with shared references from
|
|
65
|
+
* a parent. Used by PgDatabase.getTransactionClient. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
68
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
69
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
70
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
71
|
+
getNextTimestamp(): Promise<bigint>;
|
|
72
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
73
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
74
|
+
private pgPrepareBatchWrites;
|
|
75
|
+
private pgPrepareInsertSingle;
|
|
76
|
+
private pgPrepareInsertBatch;
|
|
77
|
+
private pgPrepareUpdateSingle;
|
|
78
|
+
private pgPrepareUpdateBatch;
|
|
79
|
+
private pgPrepareDeleteSingle;
|
|
80
|
+
private pgPrepareDeleteBatch;
|
|
81
|
+
private buildOrGetInsertSql;
|
|
82
|
+
private buildOrGetUpdateSql;
|
|
83
|
+
private buildOrGetDeleteSql;
|
|
84
|
+
private pgPrepareCommitLogs;
|
|
85
|
+
/**
|
|
86
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
87
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
88
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
89
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
90
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
91
|
+
*/
|
|
92
|
+
private pgPrepareValidatePointReadsByCommitTs;
|
|
93
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
94
|
+
success: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
private pgApplyWrites;
|
|
97
|
+
/**
|
|
98
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
99
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
100
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
101
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
102
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
103
|
+
*/
|
|
104
|
+
private validatePointReadsByCommitTs;
|
|
105
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
106
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
107
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
108
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
109
|
+
close(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { PgDatabase as t };
|
|
113
|
+
//# sourceMappingURL=postgres-CONYSAv6.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-CONYSAv6.d.ts","names":[],"sources":["../src/db/postgres.ts"],"mappings":";;;;;cAiBa,UAAA,YAAsB,QAAA;cAE/B,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAWA,MAAA;EACD,MAAA,EAAQ,UAAA;EAAA,QACP,IAAA;EAAA,SACC,UAAA,EAAY,UAAA;EAAA,SACZ,MAAA,EAAQ,MAAA;EAMV,WAAA,EAAa,GAAA,SAAY,GAAA;EAAA,UAGtB,QAAA,EAAU,GAAA;EAHY;;;;;;EAW1B,qBAAA,CAAsB,KAAA,WAAgB,OA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EAkDF,YAAA,CACJ,OAAA,UACA,OAAA,EAAS,eAAA,EACT,QAAA,WACC,OAAA;IAAU,OAAA;EAAA;EAAA,QAqCC,aAAA;EApwBa;;;;;;;EAAA,QA+2Bb,4BAAA;EA0CR,qBAAA,CAAsB,EAAA,WAAa,OAAA;EAQnC,iBAAA,IAAqB,OAAA;EAQrB,sBAAA,CAAuB,OAAA,UAAiB,KAAA,UAAe,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmBxF,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Bn as DbType, Gn as SqlBuilder, Gr as ReadEntry, Hn as PooledClient, Jr as WriteEntry, Kn as TxDatabase, Ln as CoreInitLockCtx, Rn as Database, Un as PreparedQueries, Vn as LazyCommitTsParam, mr as CommitLogEntry, qn as CacheLayer, zn as DbQueryResult } from "./index-DTNBHQPY.js";
|
|
2
|
+
import { Pool, PoolConfig } from "pg";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/postgres.d.ts
|
|
6
|
+
declare class PgDatabase implements Database {
|
|
7
|
+
constructor(logger: Logger, config: PoolConfig, pool?: Pool | undefined);
|
|
8
|
+
private logger;
|
|
9
|
+
config: PoolConfig;
|
|
10
|
+
private pool;
|
|
11
|
+
readonly sqlBuilder: SqlBuilder;
|
|
12
|
+
readonly dbType: DbType;
|
|
13
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
14
|
+
protected sqlCache: Map<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches actual column types from Postgres for `table` and returns a
|
|
17
|
+
* map of DB column name → PG type string (as produced by `format_type`,
|
|
18
|
+
* e.g. `bigint`, `integer`, `character varying(32)`, `text[]`, `jsonb`).
|
|
19
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
20
|
+
*/
|
|
21
|
+
loadColumnTypesFromPg(table: string): Promise<Map<string, string>>;
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
24
|
+
* batched write, so it can't await — populate the cache via
|
|
25
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
26
|
+
* missing (programmer error / bootstrap skipped).
|
|
27
|
+
*/
|
|
28
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
29
|
+
/**
|
|
30
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
31
|
+
* client supplied, attempts the cache key first and falls through to
|
|
32
|
+
* Postgres on miss (writing the result back to Redis). This is the
|
|
33
|
+
* "one server queries PG, the rest read from Redis" pattern for cold
|
|
34
|
+
* starts in a multi-instance deploy. Without Redis, always queries PG.
|
|
35
|
+
*
|
|
36
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
37
|
+
* user table in the connected database is loaded.
|
|
38
|
+
*
|
|
39
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
40
|
+
* environment (typically a schema version / deploy version). The
|
|
41
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
42
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
43
|
+
*/
|
|
44
|
+
bootstrapColumnTypes(opts: {
|
|
45
|
+
redis?: CacheLayer;
|
|
46
|
+
cacheKey: string;
|
|
47
|
+
tables?: string[];
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
51
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
52
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
53
|
+
*/
|
|
54
|
+
private invalidateColumnTypes;
|
|
55
|
+
/** Enumerate the user-defined tables in the connected database — used
|
|
56
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
57
|
+
private listUserTables;
|
|
58
|
+
getCoreVersion(): Promise<bigint>;
|
|
59
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
60
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
61
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
62
|
+
getClient(): Promise<PooledClient>;
|
|
63
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
64
|
+
/** Internal: replace this instance's caches with shared references from
|
|
65
|
+
* a parent. Used by PgDatabase.getTransactionClient. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
68
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
69
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
70
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
71
|
+
getNextTimestamp(): Promise<bigint>;
|
|
72
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
73
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
74
|
+
private pgPrepareBatchWrites;
|
|
75
|
+
private pgPrepareInsertSingle;
|
|
76
|
+
private pgPrepareInsertBatch;
|
|
77
|
+
private pgPrepareUpdateSingle;
|
|
78
|
+
private pgPrepareUpdateBatch;
|
|
79
|
+
private pgPrepareDeleteSingle;
|
|
80
|
+
private pgPrepareDeleteBatch;
|
|
81
|
+
private buildOrGetInsertSql;
|
|
82
|
+
private buildOrGetUpdateSql;
|
|
83
|
+
private buildOrGetDeleteSql;
|
|
84
|
+
private pgPrepareCommitLogs;
|
|
85
|
+
/**
|
|
86
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
87
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
88
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
89
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
90
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
91
|
+
*/
|
|
92
|
+
private pgPrepareValidatePointReadsByCommitTs;
|
|
93
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
94
|
+
success: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
private pgApplyWrites;
|
|
97
|
+
/**
|
|
98
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
99
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
100
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
101
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
102
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
103
|
+
*/
|
|
104
|
+
private validatePointReadsByCommitTs;
|
|
105
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
106
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
107
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
108
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
109
|
+
close(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { PgDatabase as t };
|
|
113
|
+
//# sourceMappingURL=postgres-Dh4ATweM.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-Dh4ATweM.d.ts","names":[],"sources":["../src/db/postgres.ts"],"mappings":";;;;;cAiBa,UAAA,YAAsB,QAAA;cAE/B,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,UAAA,EACR,IAAA,GAAM,IAAA;EAAA,QAWA,MAAA;EACD,MAAA,EAAQ,UAAA;EAAA,QACP,IAAA;EAAA,SACC,UAAA,EAAY,UA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QAsEN,qBAAA;EAAA,QAgBM,oBAAA;EAAA,QAiDN,mBAAA;EAAA,QAqBA,mBAAA;EAAA,QA4BA,mBAAA;EAAA,QAcM,mBAAA;EA3qBR;;;;;;;EAAA,QAytBE,qCAAA;EAkDF,YAAA,CACJ,OAAA,UACA,OAAA,EAAS,eAAA,EACT,QAAA,WACC,OAAA;IAAU,OAAA;EAAA;EAAA,QAqCC,aAAA;EApwBa;;;;;;;EAAA,QA+2Bb,4BAAA;EA0CR,qBAAA,CAAsB,EAAA,WAAa,OAAA;EAQnC,iBAAA,IAAqB,OAAA;EAQrB,sBAAA,CAAuB,OAAA,UAAiB,KAAA,UAAe,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmBxF,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Bn as DbType, Gn as SqlBuilder, Gr as ReadEntry, Hn as PooledClient, Jr as WriteEntry, Kn as TxDatabase, Ln as CoreInitLockCtx, Rn as Database, Un as PreparedQueries, Vn as LazyCommitTsParam, mr as CommitLogEntry, qn as CacheLayer, zn as DbQueryResult } from "./index-CbYOjwGh.js";
|
|
2
|
+
import { Pool, PoolConfig } from "pg";
|
|
3
|
+
import { Logger } from "pino";
|
|
4
|
+
|
|
5
|
+
//#region src/db/postgres.d.ts
|
|
6
|
+
declare class PgDatabase implements Database {
|
|
7
|
+
constructor(logger: Logger, config: PoolConfig, pool?: Pool | undefined);
|
|
8
|
+
private logger;
|
|
9
|
+
config: PoolConfig;
|
|
10
|
+
private pool;
|
|
11
|
+
readonly sqlBuilder: SqlBuilder;
|
|
12
|
+
readonly dbType: DbType;
|
|
13
|
+
columnTypes: Map<string, Map<string, string>>;
|
|
14
|
+
protected sqlCache: Map<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches actual column types from Postgres for `table` and returns a
|
|
17
|
+
* map of DB column name → PG type string (as produced by `format_type`,
|
|
18
|
+
* e.g. `bigint`, `integer`, `character varying(32)`, `text[]`, `jsonb`).
|
|
19
|
+
* No caching here — see {@link getColumnTypes} for the cached path.
|
|
20
|
+
*/
|
|
21
|
+
loadColumnTypesFromPg(table: string): Promise<Map<string, string>>;
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous column-type lookup. The apply path calls this on every
|
|
24
|
+
* batched write, so it can't await — populate the cache via
|
|
25
|
+
* {@link bootstrapColumnTypes} at server start. Throws if `table` is
|
|
26
|
+
* missing (programmer error / bootstrap skipped).
|
|
27
|
+
*/
|
|
28
|
+
getColumnTypes(table: string): Map<string, string> | null;
|
|
29
|
+
/**
|
|
30
|
+
* Eagerly load column types into the in-memory cache. With a Redis
|
|
31
|
+
* client supplied, attempts the cache key first and falls through to
|
|
32
|
+
* Postgres on miss (writing the result back to Redis). This is the
|
|
33
|
+
* "one server queries PG, the rest read from Redis" pattern for cold
|
|
34
|
+
* starts in a multi-instance deploy. Without Redis, always queries PG.
|
|
35
|
+
*
|
|
36
|
+
* Pass `tables` to limit the load to a specific list; otherwise every
|
|
37
|
+
* user table in the connected database is loaded.
|
|
38
|
+
*
|
|
39
|
+
* The Redis cache key should encode whatever invalidates types in your
|
|
40
|
+
* environment (typically a schema version / deploy version). The
|
|
41
|
+
* subscriber in supalive-server.ts is expected to publish a reload
|
|
42
|
+
* signal after migrations and invoke {@link invalidateColumnTypes}.
|
|
43
|
+
*/
|
|
44
|
+
bootstrapColumnTypes(opts: {
|
|
45
|
+
redis?: CacheLayer;
|
|
46
|
+
cacheKey: string;
|
|
47
|
+
tables?: string[];
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Invalidate cached types (and dependent SQL) for `table`, or the entire
|
|
51
|
+
* cache if `table` is omitted. The Redis-pubsub reload signal in
|
|
52
|
+
* supalive-server.ts is expected to call this on schema changes.
|
|
53
|
+
*/
|
|
54
|
+
private invalidateColumnTypes;
|
|
55
|
+
/** Enumerate the user-defined tables in the connected database — used
|
|
56
|
+
* by bootstrapColumnTypes() when no explicit list is provided. */
|
|
57
|
+
private listUserTables;
|
|
58
|
+
getCoreVersion(): Promise<bigint>;
|
|
59
|
+
coreMigrationStatements(toVersion: bigint): string[];
|
|
60
|
+
withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
|
|
61
|
+
query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
|
|
62
|
+
getClient(): Promise<PooledClient>;
|
|
63
|
+
getTransactionClient(): Promise<TxDatabase>;
|
|
64
|
+
/** Internal: replace this instance's caches with shared references from
|
|
65
|
+
* a parent. Used by PgDatabase.getTransactionClient. */
|
|
66
|
+
adoptCaches(columnTypes: Map<string, Map<string, string>>, sqlCache: Map<string, string>): void;
|
|
67
|
+
getLatestSnapshotTimestamp(): Promise<bigint>;
|
|
68
|
+
updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
|
|
69
|
+
getMinSnapshotTimestamp(): Promise<bigint>;
|
|
70
|
+
updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
|
|
71
|
+
getNextTimestamp(): Promise<bigint>;
|
|
72
|
+
attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
|
|
73
|
+
prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
|
|
74
|
+
private pgPrepareBatchWrites;
|
|
75
|
+
private pgPrepareInsertSingle;
|
|
76
|
+
private pgPrepareInsertBatch;
|
|
77
|
+
private pgPrepareUpdateSingle;
|
|
78
|
+
private pgPrepareUpdateBatch;
|
|
79
|
+
private pgPrepareDeleteSingle;
|
|
80
|
+
private pgPrepareDeleteBatch;
|
|
81
|
+
private buildOrGetInsertSql;
|
|
82
|
+
private buildOrGetUpdateSql;
|
|
83
|
+
private buildOrGetDeleteSql;
|
|
84
|
+
private pgPrepareCommitLogs;
|
|
85
|
+
/**
|
|
86
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
87
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
88
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
89
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
90
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
91
|
+
*/
|
|
92
|
+
private pgPrepareValidatePointReadsByCommitTs;
|
|
93
|
+
commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
|
|
94
|
+
success: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
private pgApplyWrites;
|
|
97
|
+
/**
|
|
98
|
+
* Point-only OCC check. For each genuine point read, compare the row's
|
|
99
|
+
* current commit_ts against the value captured at read time. A `null`
|
|
100
|
+
* expectedCommitTs means "row didn't exist when we read"; any row found
|
|
101
|
+
* now is a conflict. Reads whose row is being written in this same txn
|
|
102
|
+
* are skipped — the CAS UPDATE/DELETE already validated those.
|
|
103
|
+
*/
|
|
104
|
+
private validatePointReadsByCommitTs;
|
|
105
|
+
pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
|
|
106
|
+
getMinCommitLogTs(): Promise<bigint | null>;
|
|
107
|
+
getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
108
|
+
getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
|
|
109
|
+
close(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { PgDatabase as t };
|
|
113
|
+
//# sourceMappingURL=postgres-Dsa4m0wv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-Dsa4m0wv.d.ts","names":[],"sources":["../src/db/postgres.ts"],"mappings":";;;;;cAiBa,UAAA,YAAsB,QAAA;cAE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V,QAAA,EAAU,iBAAA,GACT,OAAA,CAAQ,eAAA;EAAA,QAoBG,oBAAA;EAAA,QA2BN,qBAAA;EAAA,QAkBM,oBAAA;EAAA,QA+DN,qBAAA;EAAA,QAwBM,oBAAA;EAAA,QAsEN,qBAAA;EAAA,QAgBM,oBAAA;EAAA,QAiDN,mBAAA;EAAA,QAqBA,mBAAA;EAAA,QA4BA,mBAAA;EAAA,QAcM,mBAAA;EA3qBR;;;;;;;EAAA,QAytBE,qCAAA;EAkDF,YAAA,CACJ,OAAA,UACA,OAAA,EAAS,eAAA,EACT,QAAA,WACC,OAAA;IAAU,OAAA;EAAA;EAAA,QAqCC,aAAA;EApwBa;;;;;;;EAAA,QA+2Bb,4BAAA;EA0CR,qBAAA,CAAsB,EAAA,WAAa,OAAA;EAQnC,iBAAA,IAAqB,OAAA;EAQrB,sBAAA,CAAuB,OAAA,UAAiB,KAAA,UAAe,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmBxF,oBAAA,CAAqB,OAAA,UAAiB,SAAA,UAAmB,QAAA,EAAU,UAAA,KAAe,OAAA,CAAQ,cAAA;EAmB1F,KAAA,IAAS,OAAA;AAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ProcedureNames, $r as normalizeIdToBytes, Ar as Predicate, Br as RawPointReadSchema, Bt as SupaliveDb, Cr as NO_RETRY, Ct as QueryFn, Dr as OrPredicateSchema, En as SchemaCodecs, Er as OrPredicate, Et as createActionBuilder, Fr as QueryCacheMetadataSchema, G as RPCError, Gr as ReadEntry, Gt as QueryDefinition, Hn as PooledClient, Hr as RawRangeReadSchema, Ht as AnyQueryDef, Ir as QuerySpec, J as ActionProcedures, Jr as WriteEntry, Jt as defineQuery, K as WSClientOptions, Kr as ReadEntrySchema, Kt as ResultOf, Lr as RangeRead, Mn as defineSchema, Mr as QueryCacheEntry, Nr as QueryCacheEntrySchema, On as SchemaColumnsOptions, Or as PointRead, Ot as createMutationBuilder, Pr as QueryCacheMetadata, Q as MutationProcedures, Qr as bytesFromJson, Rn as Database, Rr as RangeReadSchema, Sr as MutationResult, St as QueryCtx, Tr as OccConflictError, Tt as TypeOf, U as ClientPublicState, Ur as RawReadEntry, Ut as DefsToMap, Vr as RawRangeRead, Vt as sleep, W as HeartbeatOptions, Wn as RawClient, Wr as RawReadEntrySchema, Wt as ParamsOf, Xr as WriteOp, Xt as DbWriter, Y as AppRouter, Yr as WriteEntrySchema, Yt as DbReader, Zr as WriteOpSchema, Zt as TxContext, _n as InferSchema, _r as CompareOperatorSchema, _t as MutationCtx, a as CallOptions, at as router, br as LeafPredicateSchema, bt as OutputOf, c as LiveQueryHandle, ct as ActionFn, d as WSClientMethods, dr as BigIntSchema, dt as ContextOf, ei as normalizeToBytes, et as PublicProcedures, f as createClient, fr as CachedPgMetadata, gr as CompareOperator, gt as MutationConfig, hr as CommitTs, i as createCaller, jn as defineComputedField, jr as PredicateSchema, kn as SchemaDefinition, kr as PointReadSchema, kt as createQueryBuilder, l as LiveQueryState, ln as ColumnCodec, lr as AndPredicate, lt as ActionProcedure, mr as CommitLogEntry, n as CallerFromRouter, nt as RegisteredProcedure, o as ClientFromProcedures, ot as ActionConfig, pn as ComputedFieldConfig, pr as CachedPgMetadataSchema, q as WsClientManager, qr as RetryConfig, qt as _resetGlobalDefs, r as CallerOptions, rt as Router, s as ClientOptions, sn as matchesPredicate, st as ActionCtx, t as CallerFromProcedures, tt as QueryProcedures, u as LiveQueryStatus, ur as AndPredicateSchema, ut as AnyProcedure, vn as InsertData, vr as DEFAULT_RETRY, vt as MutationFn, wr as OccAbortError, wt as QueryProcedure, xr as LiveResult, xt as QueryConfig, yn as Model, yr as LeafPredicate, yt as MutationProcedure, zn as DbQueryResult, zr as RawPointRead } from "../../index-
|
|
1
|
+
import { $ as ProcedureNames, $r as normalizeIdToBytes, Ar as Predicate, Br as RawPointReadSchema, Bt as SupaliveDb, Cr as NO_RETRY, Ct as QueryFn, Dr as OrPredicateSchema, En as SchemaCodecs, Er as OrPredicate, Et as createActionBuilder, Fr as QueryCacheMetadataSchema, G as RPCError, Gr as ReadEntry, Gt as QueryDefinition, Hn as PooledClient, Hr as RawRangeReadSchema, Ht as AnyQueryDef, Ir as QuerySpec, J as ActionProcedures, Jr as WriteEntry, Jt as defineQuery, K as WSClientOptions, Kr as ReadEntrySchema, Kt as ResultOf, Lr as RangeRead, Mn as defineSchema, Mr as QueryCacheEntry, Nr as QueryCacheEntrySchema, On as SchemaColumnsOptions, Or as PointRead, Ot as createMutationBuilder, Pr as QueryCacheMetadata, Q as MutationProcedures, Qr as bytesFromJson, Rn as Database, Rr as RangeReadSchema, Sr as MutationResult, St as QueryCtx, Tr as OccConflictError, Tt as TypeOf, U as ClientPublicState, Ur as RawReadEntry, Ut as DefsToMap, Vr as RawRangeRead, Vt as sleep, W as HeartbeatOptions, Wn as RawClient, Wr as RawReadEntrySchema, Wt as ParamsOf, Xr as WriteOp, Xt as DbWriter, Y as AppRouter, Yr as WriteEntrySchema, Yt as DbReader, Zr as WriteOpSchema, Zt as TxContext, _n as InferSchema, _r as CompareOperatorSchema, _t as MutationCtx, a as CallOptions, at as router, br as LeafPredicateSchema, bt as OutputOf, c as LiveQueryHandle, ct as ActionFn, d as WSClientMethods, dr as BigIntSchema, dt as ContextOf, ei as normalizeToBytes, et as PublicProcedures, f as createClient, fr as CachedPgMetadata, gr as CompareOperator, gt as MutationConfig, hr as CommitTs, i as createCaller, jn as defineComputedField, jr as PredicateSchema, kn as SchemaDefinition, kr as PointReadSchema, kt as createQueryBuilder, l as LiveQueryState, ln as ColumnCodec, lr as AndPredicate, lt as ActionProcedure, mr as CommitLogEntry, n as CallerFromRouter, nt as RegisteredProcedure, o as ClientFromProcedures, ot as ActionConfig, pn as ComputedFieldConfig, pr as CachedPgMetadataSchema, q as WsClientManager, qr as RetryConfig, qt as _resetGlobalDefs, r as CallerOptions, rt as Router, s as ClientOptions, sn as matchesPredicate, st as ActionCtx, t as CallerFromProcedures, tt as QueryProcedures, u as LiveQueryStatus, ur as AndPredicateSchema, ut as AnyProcedure, vn as InsertData, vr as DEFAULT_RETRY, vt as MutationFn, wr as OccAbortError, wt as QueryProcedure, xr as LiveResult, xt as QueryConfig, yn as Model, yr as LeafPredicate, yt as MutationProcedure, zn as DbQueryResult, zr as RawPointRead } from "../../index-DTNBHQPY.js";
|
|
2
2
|
export { type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, AndPredicate, AndPredicateSchema, type AnyProcedure, type AnyQueryDef, type AppRouter, BigIntSchema, CachedPgMetadata, CachedPgMetadataSchema, type CallOptions, CallerFromProcedures, CallerFromRouter, CallerOptions, type ClientFromProcedures, type ClientOptions, type ClientPublicState, type ColumnCodec, CommitLogEntry, CommitTs, CompareOperator, CompareOperatorSchema, type ComputedFieldConfig, type ContextOf, DEFAULT_RETRY, type Database, type DbQueryResult, DbReader, DbReader as ReadContext, DbWriter, DbWriter as WritableContext, type DefsToMap, type HeartbeatOptions, type InferSchema, type InsertData, LeafPredicate, LeafPredicateSchema, type LiveQueryHandle, type LiveQueryState, type LiveQueryStatus, LiveResult, type Model, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, MutationResult, NO_RETRY, OccAbortError, OccConflictError, OrPredicate, OrPredicateSchema, type OutputOf, type ParamsOf, PointRead, PointReadSchema, type PooledClient, Predicate, PredicateSchema, type ProcedureNames, type PublicProcedures, QueryCacheEntry, QueryCacheEntrySchema, QueryCacheMetadata, QueryCacheMetadataSchema, type QueryConfig, type QueryCtx, type QueryDefinition, type QueryFn, type QueryProcedure, type QueryProcedures, QuerySpec, RPCError, RangeRead, RangeReadSchema, type RawClient, RawPointRead, RawPointReadSchema, RawRangeRead, RawRangeReadSchema, RawReadEntry, RawReadEntrySchema, ReadEntry, ReadEntrySchema, type RegisteredProcedure, type ResultOf, RetryConfig, type Router, type SchemaCodecs, type SchemaColumnsOptions, type SchemaDefinition, SupaliveDb, TxContext, type TypeOf, type WSClientMethods, type WSClientOptions, WriteEntry, WriteEntrySchema, WriteOp, WriteOpSchema, WsClientManager, _resetGlobalDefs, bytesFromJson, createActionBuilder, createCaller, createClient, createMutationBuilder, createQueryBuilder, defineComputedField, defineQuery, defineSchema, matchesPredicate, normalizeIdToBytes, normalizeToBytes, router, sleep };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MySqlDatabase } from "../../mysql-
|
|
1
|
+
import { t as MySqlDatabase } from "../../mysql-BRyidTZD.js";
|
|
2
2
|
export { MySqlDatabase };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PgDatabase } from "../../postgres-
|
|
1
|
+
import { t as PgDatabase } from "../../postgres-Dh4ATweM.js";
|
|
2
2
|
export { PgDatabase };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as ProcedureNames, $t as JsonContainsOptions, An as StoredSchemaColumnsOptions, Cn as QueryArgs, Ct as QueryFn, Dn as SchemaColumnMapping, Dt as createJobBuilder, En as SchemaCodecs, Et as createActionBuilder, Fn as tableNameToId, In as trackSchema, J as ActionProcedures, Mn as defineSchema, Nn as schemaRegistry, On as SchemaColumnsOptions, Ot as createMutationBuilder, Pn as shouldTrackSchema, Q as MutationProcedures, Qt as IdAndCommitTs, Sn as Prettify, St as QueryCtx, Tn as ReturnQuery, Tt as TypeOf, X as ContextRegistry, Y as AppRouter, Z as JobProcedures, _n as InferSchema, _t as MutationCtx, an as jsonPathExists, at as router, bn as MutationArgs, bt as OutputOf, cn as ActionArgs, ct as ActionFn, dn as ComputedDataType, dt as ContextOf, en as JsonHasKeyMultiOptions, et as PublicProcedures, fn as ComputedField, ft as JobConfig, gn as IndexDefinition, gt as MutationConfig, hn as DefineSchemaConfig, ht as JobProcedure, in as jsonContains, it as getContextRegistry, jn as defineComputedField, kn as SchemaDefinition, kt as createQueryBuilder, ln as ColumnCodec, lt as ActionProcedure, mn as DeclarativeIndex, mt as JobFn, nn as QueryBuilder, nt as RegisteredProcedure, on as jsonPathExtract, ot as ActionConfig, pn as ComputedFieldConfig, pt as JobCtx, rn as buildPredicateSql, rt as Router, sn as matchesPredicate, st as ActionCtx, tn as JsonOpOptions, tt as QueryProcedures, un as ComputedCodec, ut as AnyProcedure, vn as InsertData, vt as MutationFn, wn as ReturnLiveQuery, wt as QueryProcedure, xn as OverrideField, xt as QueryConfig, yn as Model, yt as MutationProcedure } from "../../index-
|
|
1
|
+
import { $ as ProcedureNames, $t as JsonContainsOptions, An as StoredSchemaColumnsOptions, Cn as QueryArgs, Ct as QueryFn, Dn as SchemaColumnMapping, Dt as createJobBuilder, En as SchemaCodecs, Et as createActionBuilder, Fn as tableNameToId, In as trackSchema, J as ActionProcedures, Mn as defineSchema, Nn as schemaRegistry, On as SchemaColumnsOptions, Ot as createMutationBuilder, Pn as shouldTrackSchema, Q as MutationProcedures, Qt as IdAndCommitTs, Sn as Prettify, St as QueryCtx, Tn as ReturnQuery, Tt as TypeOf, X as ContextRegistry, Y as AppRouter, Z as JobProcedures, _n as InferSchema, _t as MutationCtx, an as jsonPathExists, at as router, bn as MutationArgs, bt as OutputOf, cn as ActionArgs, ct as ActionFn, dn as ComputedDataType, dt as ContextOf, en as JsonHasKeyMultiOptions, et as PublicProcedures, fn as ComputedField, ft as JobConfig, gn as IndexDefinition, gt as MutationConfig, hn as DefineSchemaConfig, ht as JobProcedure, in as jsonContains, it as getContextRegistry, jn as defineComputedField, kn as SchemaDefinition, kt as createQueryBuilder, ln as ColumnCodec, lt as ActionProcedure, mn as DeclarativeIndex, mt as JobFn, nn as QueryBuilder, nt as RegisteredProcedure, on as jsonPathExtract, ot as ActionConfig, pn as ComputedFieldConfig, pt as JobCtx, rn as buildPredicateSql, rt as Router, sn as matchesPredicate, st as ActionCtx, tn as JsonOpOptions, tt as QueryProcedures, un as ComputedCodec, ut as AnyProcedure, vn as InsertData, vt as MutationFn, wn as ReturnLiveQuery, wt as QueryProcedure, xn as OverrideField, xt as QueryConfig, yn as Model, yt as MutationProcedure } from "../../index-DTNBHQPY.js";
|
|
2
2
|
import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-CiacMqje.js";
|
|
3
3
|
export { ActionArgs, type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, type AnyProcedure, type AppRouter, ColumnCodec, ComputedCodec, ComputedDataType, ComputedField, ComputedFieldConfig, type ContextOf, ContextRegistry, DeclarativeIndex, DefineSchemaConfig, IdAndCommitTs, IndexDefinition, InferSchema, InsertData, type JobConfig, type JobCtx, type JobFn, type JobProcedure, type JobProcedures, JsonContainsOptions, JsonHasKeyMultiOptions, JsonOpOptions, Model, MutationArgs, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, type OutputOf, OverrideField, Prettify, type ProcedureNames, type PublicProcedures, QueryArgs, QueryBuilder, type QueryConfig, type QueryCtx, type QueryFn, type QueryProcedure, type QueryProcedures, type RegisteredProcedure, ReturnLiveQuery, ReturnQuery, type Router, SchemaCodecs, SchemaColumnMapping, SchemaColumnsOptions, SchemaDefinition, StoredSchemaColumnsOptions, type TypeOf, buildPredicateSql, createActionBuilder, createJobBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { In as trackSchema, Nn as schemaRegistry, kn as SchemaDefinition } from "../../index-
|
|
1
|
+
import { In as trackSchema, Nn as schemaRegistry, kn as SchemaDefinition } from "../../index-DTNBHQPY.js";
|
|
2
2
|
|
|
3
3
|
//#region src/db/schema-sql.d.ts
|
|
4
4
|
type SqlDialect = "postgres" | "mysql";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $n as RegisterSubscriptionParamsSchema, At as DevScheduler, Bt as SupaliveDb, E as Context, Ft as JobScheduler, It as QStashScheduler, Jn as AffectedSubscription, Lt as QStashSchedulerOptions, Mt as EnqueueOptions, Nt as IncomingJobRequest, Pt as JobClient, Qn as RegisterSubscriptionParams, Rn as Database, Rt as ScheduleHandle, Xn as InvalidateWritesetParamsSchema, Yn as InvalidateWritesetParams, Zn as InvalidateWritesetResult, ar as UnregisterSubscriptionsResult, cr as UpdateSubscriptionReadSetResult, er as RegisterSubscriptionResult, ir as UnregisterSubscriptionsParams, jt as DevSchedulerOptions, nr as UnregisterSubscriptionParamsSchema, or as UpdateSubscriptionReadSetParams, qn as CacheLayer, rr as UnregisterSubscriptionResult, rt as Router, sr as UpdateSubscriptionReadSetParamsSchema, tr as UnregisterSubscriptionParams, zt as ScheduledJobDef } from "../../index-
|
|
2
|
-
import { t as MySqlDatabase } from "../../mysql-
|
|
3
|
-
import { t as PgDatabase } from "../../postgres-
|
|
4
|
-
import { b as UpstashConfig, f as DatabaseConfig, u as SubId, v as SubscriptionManagerConfig, y as SupaliveServerConfig } from "../../types_server-
|
|
1
|
+
import { $n as RegisterSubscriptionParamsSchema, At as DevScheduler, Bt as SupaliveDb, E as Context, Ft as JobScheduler, It as QStashScheduler, Jn as AffectedSubscription, Lt as QStashSchedulerOptions, Mt as EnqueueOptions, Nt as IncomingJobRequest, Pt as JobClient, Qn as RegisterSubscriptionParams, Rn as Database, Rt as ScheduleHandle, Xn as InvalidateWritesetParamsSchema, Yn as InvalidateWritesetParams, Zn as InvalidateWritesetResult, ar as UnregisterSubscriptionsResult, cr as UpdateSubscriptionReadSetResult, er as RegisterSubscriptionResult, ir as UnregisterSubscriptionsParams, jt as DevSchedulerOptions, nr as UnregisterSubscriptionParamsSchema, or as UpdateSubscriptionReadSetParams, qn as CacheLayer, rr as UnregisterSubscriptionResult, rt as Router, sr as UpdateSubscriptionReadSetParamsSchema, tr as UnregisterSubscriptionParams, zt as ScheduledJobDef } from "../../index-DTNBHQPY.js";
|
|
2
|
+
import { t as MySqlDatabase } from "../../mysql-BRyidTZD.js";
|
|
3
|
+
import { t as PgDatabase } from "../../postgres-Dh4ATweM.js";
|
|
4
|
+
import { b as UpstashConfig, f as DatabaseConfig, u as SubId, v as SubscriptionManagerConfig, y as SupaliveServerConfig } from "../../types_server-CDu9dPnG.js";
|
|
5
5
|
import pino, { Level } from "pino";
|
|
6
6
|
import Redis$1 from "ioredis";
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/supalive-server.ts","../../../src/logger.ts","../../../src/server/subscription-manager.ts","../../../src/server/subscription-manager-client.ts","../../../src/db/init_db.ts","../../../src/server/sub_hash.ts"],"mappings":";;;;;;;;;;;cA4Ha,uBAAA,kBAAyC,OAAA;EAAA,QAC5C,MAAA;EAAA,QACA,UAAA;EAAA,QAEA,UAAA;EAAA,QACA,GAAA;EAAA,QAEA,KAAA;EAAA,QACA,QAAA;EAAA,QACA,EAAA;EAAA,QACA,eAAA;EAAA,QACA,MAAA;EAAA,QAMA,kBAAA;EAAA,QAIA,WAAA;EAAA,QAEA,SAAA;EAAA,QACA,OAAA;EAAA,QACA,SAAA;EAAA,QACA,UAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/supalive-server.ts","../../../src/logger.ts","../../../src/server/subscription-manager.ts","../../../src/server/subscription-manager-client.ts","../../../src/db/init_db.ts","../../../src/server/sub_hash.ts"],"mappings":";;;;;;;;;;;cA4Ha,uBAAA,kBAAyC,OAAA;EAAA,QAC5C,MAAA;EAAA,QACA,UAAA;EAAA,QAEA,UAAA;EAAA,QACA,GAAA;EAAA,QAEA,KAAA;EAAA,QACA,QAAA;EAAA,QACA,EAAA;EAAA,QACA,eAAA;EAAA,QACA,MAAA;EAAA,QAMA,kBAAA;EAAA,QAIA,WAAA;EAAA,QAEA,SAAA;EAAA,QACA,OAAA;EAAA,QACA,SAAA;EAAA,QACA,UAAA;EA6mCsC;EAAA,QA3mCtC,OAAA;EAAA,QAEA,QAAA;EAAA,QACA,mBAAA;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,aAAa;EAEtB,eAAA;EAEA,iBAAA;EAEA,iBAAA;EAEA,oBAAA;EAEA,eAAA;AAAA;AAAA,iBAGY,cAAA,CAAe,MAAA,EAAQ,qBAAA;EAA0B,UAAA,EAAY,UAAA;EAAY,cAAA,GAAiB,OAAA;AAAA;;;;iBC/JpF,SAAA,CAAU,KAAA,YAAiB,OAAO;;;;;cAS3C,kBAAA;;;;;;;;;iBAgDS,sBAAA,CACpB,SAAA,UACA,KAAA,oBACA,aAAA,WACC,OAAO;;;;;;iBAWY,gBAAA,CACpB,SAAA,UACA,KAAA,oBACA,aAAA,WACC,OAAO"}
|
|
@@ -388,7 +388,11 @@ var QStashScheduler = class {
|
|
|
388
388
|
client;
|
|
389
389
|
receiver;
|
|
390
390
|
constructor(opts) {
|
|
391
|
-
this.client = new Client$1({
|
|
391
|
+
this.client = new Client$1({
|
|
392
|
+
baseUrl: opts.baseUrl,
|
|
393
|
+
token: opts.token,
|
|
394
|
+
devMode: opts.devMode
|
|
395
|
+
});
|
|
392
396
|
this.receiver = new Receiver({
|
|
393
397
|
currentSigningKey: opts.currentSigningKey,
|
|
394
398
|
nextSigningKey: opts.nextSigningKey
|
|
@@ -822,7 +826,6 @@ var SupaliveWebSocketServer = class {
|
|
|
822
826
|
});
|
|
823
827
|
this.scheduler = config.scheduler;
|
|
824
828
|
this.jobPath = normalizeJobPath(config.jobPath ?? "/_jobs");
|
|
825
|
-
if (!this.config.publicUrl) throw new Error("publicUrl config is required when a scheduler is configured (used to build job endpoints)");
|
|
826
829
|
this.jobClient = new JobClient(this.scheduler, (name) => this.endpointFor(name));
|
|
827
830
|
this.oneShotDeps = {
|
|
828
831
|
db: this.db,
|