@supalive/core 1.9.0 → 1.10.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-BQRlJY_1.d.ts +2192 -0
- package/dist/index-BQRlJY_1.d.ts.map +1 -0
- package/dist/index-D8O39FoZ.d.ts +2192 -0
- package/dist/index-D8O39FoZ.d.ts.map +1 -0
- package/dist/index-WMhtVzJA.d.ts +2192 -0
- package/dist/index-WMhtVzJA.d.ts.map +1 -0
- package/dist/mysql-CBSuONm5.d.ts +109 -0
- package/dist/mysql-CBSuONm5.d.ts.map +1 -0
- package/dist/mysql-CDenA4XE.d.ts +109 -0
- package/dist/mysql-CDenA4XE.d.ts.map +1 -0
- package/dist/mysql-DAfFK5v1.d.ts +109 -0
- package/dist/mysql-DAfFK5v1.d.ts.map +1 -0
- package/dist/postgres-BKGLPrKt.d.ts +113 -0
- package/dist/postgres-BKGLPrKt.d.ts.map +1 -0
- package/dist/postgres-CKBWXyY8.d.ts +113 -0
- package/dist/postgres-CKBWXyY8.d.ts.map +1 -0
- package/dist/postgres-DQxKs5Nu.d.ts +113 -0
- package/dist/postgres-DQxKs5Nu.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 +24 -124
- package/dist/src/exports/server.d.ts.map +1 -1
- package/dist/src/exports/server.js +128 -30
- package/dist/src/exports/server.js.map +1 -1
- package/dist/src/exports/sub-manager-worker-entry.d.ts +1 -0
- package/dist/src/exports/sub-manager-worker-entry.js +71 -0
- package/dist/src/exports/sub-manager-worker-entry.js.map +1 -0
- package/dist/src/exports/subscription-manager-worker-entry.js +3 -49
- package/dist/src/exports/subscription-manager-worker-entry.js.map +1 -1
- package/dist/src/exports/types.d.ts +2 -2
- package/dist/sub-worker-dispatch-G8V8asfR.js +810 -0
- package/dist/sub-worker-dispatch-G8V8asfR.js.map +1 -0
- package/dist/subscription-worker-dispatch-CSQV-PO3.js +810 -0
- package/dist/subscription-worker-dispatch-CSQV-PO3.js.map +1 -0
- package/dist/types_server-AQ8Jl2_R.d.ts +521 -0
- package/dist/types_server-AQ8Jl2_R.d.ts.map +1 -0
- package/dist/types_server-BB2WvXEA.d.ts +521 -0
- package/dist/types_server-BB2WvXEA.d.ts.map +1 -0
- package/dist/types_server-DU9JMSXd.d.ts +521 -0
- package/dist/types_server-DU9JMSXd.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { $r as WriteEntry, Gn as DbType, Hn as CoreInitLockCtx, Jn as PreparedQueries, Kn as LazyCommitTsParam, Qn as CacheLayer, Un as Database, Wn as DbQueryResult, Xn as SqlBuilder, Xr as ReadEntry, Zn as TxDatabase, qn as PooledClient, yr as CommitLogEntry } from "./index-D8O39FoZ.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-CKBWXyY8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-CKBWXyY8.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,WA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iDN,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 { $r as WriteEntry, Gn as DbType, Hn as CoreInitLockCtx, Jn as PreparedQueries, Kn as LazyCommitTsParam, Qn as CacheLayer, Un as Database, Wn as DbQueryResult, Xn as SqlBuilder, Xr as ReadEntry, Zn as TxDatabase, qn as PooledClient, yr as CommitLogEntry } from "./index-WMhtVzJA.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-DQxKs5Nu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-DQxKs5Nu.d.ts","names":[],"sources":["../src/db/postgres.ts"],"mappings":";;;;;cAiBa,UAAA,YAAsB,QAAA;cAE/B,MAAA,EAAQ,MAAA,EACR,MAAA,EAAQ,UA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A;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 WriteEntry, $t as TxContext, Ar as OccConflictError, Br as QueryCacheMetadataSchema, Cn as InsertData, Cr as DEFAULT_RETRY, Ct as QueryFn, Dr as MutationResult, Er as LiveResult, Et as createActionBuilder, Fr as Predicate, G as RPCError, Gr as RawPointReadSchema, Gt as DefsToMap, Hr as RangeRead, Ht as SupaliveDb, In as defineComputedField, Ir as PredicateSchema, J as ActionProcedures, Jr as RawReadEntry, Jt as ResultOf, K as WSClientOptions, Kr as RawRangeRead, Kt as ParamsOf, Ln as defineSchema, Lr as QueryCacheEntry, Mr as OrPredicateSchema, Nn as SchemaColumnsOptions, Nr as PointRead, Or as NO_RETRY, Ot as createMutationBuilder, Pn as SchemaDefinition, Pr as PointReadSchema, Q as MutationProcedures, Qr as RetryConfig, Qt as DbWriter, Rr as QueryCacheEntrySchema, Sn as InferSchema, Sr as CompareOperatorSchema, St as QueryCtx, Tr as LeafPredicateSchema, Tt as TypeOf, U as ClientPublicState, Un as Database, Ur as RangeReadSchema, Ut as sleep, Vr as QuerySpec, W as HeartbeatOptions, Wn as DbQueryResult, Wr as RawPointRead, Wt as AnyQueryDef, Xr as ReadEntry, Xt as defineQuery, Y as AppRouter, Yn as RawClient, Yr as RawReadEntrySchema, Yt as _resetGlobalDefs, Zr as ReadEntrySchema, Zt as DbReader, _r as CachedPgMetadata, _t as MutationCtx, a as CallOptions, ai as normalizeToBytes, at as router, br as CommitTs, bt as OutputOf, c as LiveQueryHandle, ct as ActionFn, d as WSClientMethods, dt as ContextOf, ei as WriteEntrySchema, et as PublicProcedures, f as createClient, fn as matchesPredicate, gr as BigIntSchema, gt as MutationConfig, hr as AndPredicateSchema, i as createCaller, ii as normalizeIdToBytes, jn as SchemaCodecs, jr as OrPredicate, kr as OccAbortError, kt as createQueryBuilder, l as LiveQueryState, lt as ActionProcedure, mn as ColumnCodec, mr as AndPredicate, n as CallerFromRouter, ni as WriteOpSchema, nt as RegisteredProcedure, o as ClientFromProcedures, ot as ActionConfig, q as WsClientManager, qn as PooledClient, qr as RawRangeReadSchema, qt as QueryDefinition, r as CallerOptions, ri as bytesFromJson, rt as Router, s as ClientOptions, st as ActionCtx, t as CallerFromProcedures, ti as WriteOp, tt as QueryProcedures, u as LiveQueryStatus, ut as AnyProcedure, vn as ComputedFieldConfig, vr as CachedPgMetadataSchema, vt as MutationFn, wn as Model, wr as LeafPredicate, wt as QueryProcedure, xr as CompareOperator, xt as QueryConfig, yr as CommitLogEntry, yt as MutationProcedure, zr as QueryCacheMetadata } from "../../index-
|
|
1
|
+
import { $ as ProcedureNames, $r as WriteEntry, $t as TxContext, Ar as OccConflictError, Br as QueryCacheMetadataSchema, Cn as InsertData, Cr as DEFAULT_RETRY, Ct as QueryFn, Dr as MutationResult, Er as LiveResult, Et as createActionBuilder, Fr as Predicate, G as RPCError, Gr as RawPointReadSchema, Gt as DefsToMap, Hr as RangeRead, Ht as SupaliveDb, In as defineComputedField, Ir as PredicateSchema, J as ActionProcedures, Jr as RawReadEntry, Jt as ResultOf, K as WSClientOptions, Kr as RawRangeRead, Kt as ParamsOf, Ln as defineSchema, Lr as QueryCacheEntry, Mr as OrPredicateSchema, Nn as SchemaColumnsOptions, Nr as PointRead, Or as NO_RETRY, Ot as createMutationBuilder, Pn as SchemaDefinition, Pr as PointReadSchema, Q as MutationProcedures, Qr as RetryConfig, Qt as DbWriter, Rr as QueryCacheEntrySchema, Sn as InferSchema, Sr as CompareOperatorSchema, St as QueryCtx, Tr as LeafPredicateSchema, Tt as TypeOf, U as ClientPublicState, Un as Database, Ur as RangeReadSchema, Ut as sleep, Vr as QuerySpec, W as HeartbeatOptions, Wn as DbQueryResult, Wr as RawPointRead, Wt as AnyQueryDef, Xr as ReadEntry, Xt as defineQuery, Y as AppRouter, Yn as RawClient, Yr as RawReadEntrySchema, Yt as _resetGlobalDefs, Zr as ReadEntrySchema, Zt as DbReader, _r as CachedPgMetadata, _t as MutationCtx, a as CallOptions, ai as normalizeToBytes, at as router, br as CommitTs, bt as OutputOf, c as LiveQueryHandle, ct as ActionFn, d as WSClientMethods, dt as ContextOf, ei as WriteEntrySchema, et as PublicProcedures, f as createClient, fn as matchesPredicate, gr as BigIntSchema, gt as MutationConfig, hr as AndPredicateSchema, i as createCaller, ii as normalizeIdToBytes, jn as SchemaCodecs, jr as OrPredicate, kr as OccAbortError, kt as createQueryBuilder, l as LiveQueryState, lt as ActionProcedure, mn as ColumnCodec, mr as AndPredicate, n as CallerFromRouter, ni as WriteOpSchema, nt as RegisteredProcedure, o as ClientFromProcedures, ot as ActionConfig, q as WsClientManager, qn as PooledClient, qr as RawRangeReadSchema, qt as QueryDefinition, r as CallerOptions, ri as bytesFromJson, rt as Router, s as ClientOptions, st as ActionCtx, t as CallerFromProcedures, ti as WriteOp, tt as QueryProcedures, u as LiveQueryStatus, ut as AnyProcedure, vn as ComputedFieldConfig, vr as CachedPgMetadataSchema, vt as MutationFn, wn as Model, wr as LeafPredicate, wt as QueryProcedure, xr as CompareOperator, xt as QueryConfig, yr as CommitLogEntry, yt as MutationProcedure, zr as QueryCacheMetadata } from "../../index-BQRlJY_1.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-CBSuONm5.js";
|
|
2
2
|
export { MySqlDatabase };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PgDatabase } from "../../postgres-
|
|
1
|
+
import { t as PgDatabase } from "../../postgres-BKGLPrKt.js";
|
|
2
2
|
export { PgDatabase };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ProcedureNames, An as ReturnQuery, At as patchZod$1, Bn as tableNameToId, Cn as InsertData, Ct as QueryFn, Dn as Prettify, Dt as createJobBuilder, En as OverrideField, Et as createActionBuilder, Fn as StoredSchemaColumnsOptions, In as defineComputedField, J as ActionProcedures, Ln as defineSchema, Mn as SchemaColumnMapping, Nn as SchemaColumnsOptions, On as QueryArgs, Ot as createMutationBuilder, Pn as SchemaDefinition, Q as MutationProcedures, Rn as schemaRegistry, Sn as InferSchema, St as QueryCtx, Tn as MutationArgs, Tt as TypeOf, Vn as trackSchema, X as ContextRegistry, Y as AppRouter, Z as JobProcedures, _n as ComputedField, _t as MutationCtx, an as OrderDirection, at as router, bn as DefineSchemaConfig, bt as OutputOf, cn as buildPredicateSql, ct as ActionFn, dn as jsonPathExtract, dt as ContextOf, en as IdAndCommitTs, et as PublicProcedures, fn as matchesPredicate, ft as JobConfig, gn as ComputedDataType, gt as MutationConfig, hn as ComputedCodec, ht as JobProcedure, in as OrderByOptions, it as getContextRegistry, jn as SchemaCodecs, jt as z$1, kn as ReturnLiveQuery, kt as createQueryBuilder, ln as jsonContains, lt as ActionProcedure, mn as ColumnCodec, mt as JobFn, nn as JsonHasKeyMultiOptions, nt as RegisteredProcedure, on as PaginationClause, ot as ActionConfig, pn as ActionArgs, pt as JobCtx, rn as JsonOpOptions, rt as Router, sn as QueryBuilder, st as ActionCtx, tn as JsonContainsOptions, tt as QueryProcedures, un as jsonPathExists, ut as AnyProcedure, vn as ComputedFieldConfig, vt as MutationFn, wn as Model, wt as QueryProcedure, xn as IndexDefinition, xt as QueryConfig, yn as DeclarativeIndex, yt as MutationProcedure, zn as shouldTrackSchema } from "../../index-
|
|
1
|
+
import { $ as ProcedureNames, An as ReturnQuery, At as patchZod$1, Bn as tableNameToId, Cn as InsertData, Ct as QueryFn, Dn as Prettify, Dt as createJobBuilder, En as OverrideField, Et as createActionBuilder, Fn as StoredSchemaColumnsOptions, In as defineComputedField, J as ActionProcedures, Ln as defineSchema, Mn as SchemaColumnMapping, Nn as SchemaColumnsOptions, On as QueryArgs, Ot as createMutationBuilder, Pn as SchemaDefinition, Q as MutationProcedures, Rn as schemaRegistry, Sn as InferSchema, St as QueryCtx, Tn as MutationArgs, Tt as TypeOf, Vn as trackSchema, X as ContextRegistry, Y as AppRouter, Z as JobProcedures, _n as ComputedField, _t as MutationCtx, an as OrderDirection, at as router, bn as DefineSchemaConfig, bt as OutputOf, cn as buildPredicateSql, ct as ActionFn, dn as jsonPathExtract, dt as ContextOf, en as IdAndCommitTs, et as PublicProcedures, fn as matchesPredicate, ft as JobConfig, gn as ComputedDataType, gt as MutationConfig, hn as ComputedCodec, ht as JobProcedure, in as OrderByOptions, it as getContextRegistry, jn as SchemaCodecs, jt as z$1, kn as ReturnLiveQuery, kt as createQueryBuilder, ln as jsonContains, lt as ActionProcedure, mn as ColumnCodec, mt as JobFn, nn as JsonHasKeyMultiOptions, nt as RegisteredProcedure, on as PaginationClause, ot as ActionConfig, pn as ActionArgs, pt as JobCtx, rn as JsonOpOptions, rt as Router, sn as QueryBuilder, st as ActionCtx, tn as JsonContainsOptions, tt as QueryProcedures, un as jsonPathExists, ut as AnyProcedure, vn as ComputedFieldConfig, vt as MutationFn, wn as Model, wt as QueryProcedure, xn as IndexDefinition, xt as QueryConfig, yn as DeclarativeIndex, yt as MutationProcedure, zn as shouldTrackSchema } from "../../index-BQRlJY_1.js";
|
|
2
2
|
import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-CiacMqje.js";
|
|
3
3
|
|
|
4
4
|
//#region src/exports/procedure.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pn as SchemaDefinition, Rn as schemaRegistry, Vn as trackSchema } from "../../index-
|
|
1
|
+
import { Pn as SchemaDefinition, Rn as schemaRegistry, Vn as trackSchema } from "../../index-BQRlJY_1.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 AffectedSubscription, Bt as ScheduleHandle, E as Context, Ft as IncomingJobRequest, Ht as SupaliveDb, It as JobClient, Lt as JobScheduler, Mt as DevScheduler, Nt as DevSchedulerOptions, Pt as EnqueueOptions, Qn as CacheLayer, Rt as QStashScheduler, Un as Database, Vt as ScheduledJobDef, ar as RegisterSubscriptionResult, cr as UnregisterSubscriptionResult, dr as UpdateSubscriptionReadSetParams, er as InvalidateWritesetParams, fr as UpdateSubscriptionReadSetParamsSchema, ir as RegisterSubscriptionParamsSchema,
|
|
2
|
-
import { t as MySqlDatabase } from "../../mysql-
|
|
3
|
-
import { t as PgDatabase } from "../../postgres-
|
|
4
|
-
import { b as SupaliveServerConfig, p as DatabaseConfig, u as SubId, x as UpstashConfig, y as SubscriptionManagerConfig } from "../../types_server-
|
|
1
|
+
import { $n as AffectedSubscription, Bt as ScheduleHandle, E as Context, Ft as IncomingJobRequest, Ht as SupaliveDb, It as JobClient, Lt as JobScheduler, Mt as DevScheduler, Nt as DevSchedulerOptions, Pt as EnqueueOptions, Qn as CacheLayer, Rt as QStashScheduler, Un as Database, Vt as ScheduledJobDef, ar as RegisterSubscriptionResult, cr as UnregisterSubscriptionResult, dr as UpdateSubscriptionReadSetParams, er as InvalidateWritesetParams, fr as UpdateSubscriptionReadSetParamsSchema, ir as RegisterSubscriptionParamsSchema, nr as InvalidateWritesetResult, or as UnregisterSubscriptionParams, pr as UpdateSubscriptionReadSetResult, rr as RegisterSubscriptionParams, rt as Router, sr as UnregisterSubscriptionParamsSchema, tr as InvalidateWritesetParamsSchema, zt as QStashSchedulerOptions } from "../../index-BQRlJY_1.js";
|
|
2
|
+
import { t as MySqlDatabase } from "../../mysql-CBSuONm5.js";
|
|
3
|
+
import { t as PgDatabase } from "../../postgres-BKGLPrKt.js";
|
|
4
|
+
import { C as SubManagerLink, S as SubManagerClient, b as SupaliveServerConfig, p as DatabaseConfig, u as SubId, x as UpstashConfig, y as SubscriptionManagerConfig } from "../../types_server-DU9JMSXd.js";
|
|
5
5
|
import pino, { Level } from "pino";
|
|
6
6
|
import Redis$1 from "ioredis";
|
|
7
7
|
|
|
@@ -190,7 +190,7 @@ declare const logger: pino.Logger<never, boolean>;
|
|
|
190
190
|
declare function logLevelOf(name: string): Level;
|
|
191
191
|
declare function serializeMapValue<K extends string | number | symbol, V>(map: Map<K, V>): Record<K, V>;
|
|
192
192
|
//#endregion
|
|
193
|
-
//#region src/server/
|
|
193
|
+
//#region src/server/sub-manager.d.ts
|
|
194
194
|
/**
|
|
195
195
|
* One process per deployment. Routes each subscription operation to one of N
|
|
196
196
|
* worker threads by hashing subId. Worker threads run in parallel on separate
|
|
@@ -199,14 +199,30 @@ declare function serializeMapValue<K extends string | number | symbol, V>(map: M
|
|
|
199
199
|
* raw payload. The worker validates and parses with Zod before executing.
|
|
200
200
|
*/
|
|
201
201
|
declare class SubscriptionManager {
|
|
202
|
-
private wss
|
|
203
|
-
private port
|
|
202
|
+
private wss?;
|
|
203
|
+
private port?;
|
|
204
|
+
private listen;
|
|
204
205
|
private workers;
|
|
205
206
|
private pruneInterval;
|
|
206
207
|
private static readonly PRUNE_INTERVAL_MS;
|
|
207
208
|
constructor(config: SubscriptionManagerConfig);
|
|
209
|
+
/**
|
|
210
|
+
* Build the single in-process worker for {@link SubscriptionManagerConfig.inline}
|
|
211
|
+
* mode. Reuses the host server's {@link SubscriptionManagerConfig.db} +
|
|
212
|
+
* {@link SubscriptionManagerConfig.cache} when provided (borrowed — not closed
|
|
213
|
+
* on stop); otherwise opens its own pool/cache from `database`/`upstash`.
|
|
214
|
+
*/
|
|
215
|
+
private buildInlineWorker;
|
|
208
216
|
start(): Promise<void>;
|
|
209
217
|
stop(): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* A direct, in-process {@link SubManagerLink} to this manager, for embedding
|
|
220
|
+
* it in the app server (pass as `SupaliveServerConfig.subManager`). Calls the
|
|
221
|
+
* dispatch handlers directly — no socket, no serialization. The recovery
|
|
222
|
+
* callbacks are no-ops: an in-process link never disconnects, so the app
|
|
223
|
+
* server's reconnect/buffer machinery is inert.
|
|
224
|
+
*/
|
|
225
|
+
localLink(): SubManagerLink;
|
|
210
226
|
private pruneCommitLogs;
|
|
211
227
|
/** Fan a watermark value out to every worker's in-memory copy. Worker 0 (the
|
|
212
228
|
* pruner/seeder) already has it, but re-sending is harmless — {@link
|
|
@@ -225,122 +241,6 @@ declare class SubscriptionManager {
|
|
|
225
241
|
private invalidateWriteset;
|
|
226
242
|
}
|
|
227
243
|
//#endregion
|
|
228
|
-
//#region src/server/subscription-manager-client.d.ts
|
|
229
|
-
/**
|
|
230
|
-
* Callback the app server registers to process invalidations that were
|
|
231
|
-
* deferred during a sub-manager outage. When the sub-manager reconnects and
|
|
232
|
-
* the buffered writeSets are flushed in one batched RPC, the resulting
|
|
233
|
-
* `affected[]` is handed to this callback — which is expected to do the
|
|
234
|
-
* same work as the normal per-mutation `reexecuteAffectedQuery` path.
|
|
235
|
-
*/
|
|
236
|
-
type AffectedHandler = (affected: AffectedSubscription[]) => Promise<void>;
|
|
237
|
-
/**
|
|
238
|
-
* Callback the app server registers to drive recovery on sub-manager
|
|
239
|
-
* reconnect. Iterates `serverSubscriptions`, reads `sl:reg:<subId>` from
|
|
240
|
-
* Redis, and re-registers each known sub. Resolves when complete; only then
|
|
241
|
-
* does the client's buffer flush and gated calls release.
|
|
242
|
-
*/
|
|
243
|
-
type RecoveryDriver = () => Promise<void>;
|
|
244
|
-
interface SubManagerClientOptions {
|
|
245
|
-
url: string;
|
|
246
|
-
/**
|
|
247
|
-
* Maximum number of buffered WriteEntry records held during an outage.
|
|
248
|
-
* If exceeded, the buffer is dropped — the commit-log replay path during
|
|
249
|
-
* the next register call will catch up any missed invalidations, at the
|
|
250
|
-
* cost of a brief recompute spike. Default 50_000 entries.
|
|
251
|
-
*/
|
|
252
|
-
invalidateBufferLimit?: number;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* RPC client for the (single) sub-manager process.
|
|
256
|
-
*
|
|
257
|
-
* Design (Convex-inspired):
|
|
258
|
-
* • The sub-manager is in-memory and ephemeral. There is no version
|
|
259
|
-
* protocol, no client-side registration registry, no OUT_OF_SYNC
|
|
260
|
-
* replay logic. All recovery is driven from the app server using
|
|
261
|
-
* state it already has (`serverSubscriptions`) plus registration
|
|
262
|
-
* records persisted to Redis at `sl:reg:<subId>`.
|
|
263
|
-
*
|
|
264
|
-
* • Out-of-order `updateSubscriptionReadSet` calls are filtered server
|
|
265
|
-
* side using `lastSnapshotTs` (monotonic DB commit timestamp).
|
|
266
|
-
*
|
|
267
|
-
* • On rpc-websockets reconnect, the client:
|
|
268
|
-
* 1. Transitions to `busy` (any in-flight `invalidateWriteset`
|
|
269
|
-
* buffers its writeSet).
|
|
270
|
-
* 2. Invokes the app server's `recoveryDriver` to re-register all
|
|
271
|
-
* known subs.
|
|
272
|
-
* 3. Flushes the buffer as one batched `invalidateWriteset` RPC and
|
|
273
|
-
* hands the resulting `affected[]` to `affectedHandler`.
|
|
274
|
-
* 4. Transitions to `ready`.
|
|
275
|
-
*
|
|
276
|
-
* • During an extended outage, the buffer is bounded; if exceeded, it
|
|
277
|
-
* is dropped and we rely on the commit-log replay built into
|
|
278
|
-
* `SubscriptionWorker.register()` to catch each sub up on the next
|
|
279
|
-
* re-register.
|
|
280
|
-
*/
|
|
281
|
-
declare class SubManagerClient {
|
|
282
|
-
private client;
|
|
283
|
-
private state;
|
|
284
|
-
private hasConnectedOnce;
|
|
285
|
-
/** Resolves whenever state transitions to 'ready'. Replaced on each busy→ready cycle. */
|
|
286
|
-
private readyPromise;
|
|
287
|
-
private resolveReady;
|
|
288
|
-
/** Writeset entries accumulated while state === 'busy'. Flushed as one RPC after recovery. */
|
|
289
|
-
private bufferedWriteSets;
|
|
290
|
-
private readonly bufferLimit;
|
|
291
|
-
private bufferDroppedDuringOutage;
|
|
292
|
-
private recoveryDriver?;
|
|
293
|
-
private affectedHandler?;
|
|
294
|
-
constructor(urlOrOptions: string | SubManagerClientOptions);
|
|
295
|
-
/**
|
|
296
|
-
* Wire up the app-server-driven recovery. Must be called before any
|
|
297
|
-
* disconnect/reconnect cycle for buffered writeSets to be flushed and
|
|
298
|
-
* subscriptions re-registered.
|
|
299
|
-
*/
|
|
300
|
-
setRecoveryDriver(driver: RecoveryDriver): void;
|
|
301
|
-
/**
|
|
302
|
-
* Wire up the handler invoked when batched invalidate results land
|
|
303
|
-
* after recovery. The handler is expected to drive
|
|
304
|
-
* `reexecuteAffectedQuery` for each entry.
|
|
305
|
-
*/
|
|
306
|
-
setAffectedHandler(handler: AffectedHandler): void;
|
|
307
|
-
registerSubscription(params: RegisterSubscriptionParams): Promise<RegisterSubscriptionResult>;
|
|
308
|
-
registerSubscriptionBatch(params: RegisterSubscriptionParams[]): Promise<RegisterSubscriptionResult[]>;
|
|
309
|
-
updateSubscriptionReadSet(params: UpdateSubscriptionReadSetParams): Promise<UpdateSubscriptionReadSetResult>;
|
|
310
|
-
unregisterSubscription(params: UnregisterSubscriptionParams): Promise<UnregisterSubscriptionResult>;
|
|
311
|
-
unregisterSubscriptions(params: UnregisterSubscriptionsParams): Promise<UnregisterSubscriptionsResult>;
|
|
312
|
-
/**
|
|
313
|
-
* Sends the writeSet to the sub-manager for invalidation, OR buffers it
|
|
314
|
-
* if the client is currently disconnected / recovering. Returns
|
|
315
|
-
* `{ affected: [] }` while buffering — the actual `affected` from the
|
|
316
|
-
* buffered batch is delivered via the registered `affectedHandler`
|
|
317
|
-
* after recovery completes.
|
|
318
|
-
*/
|
|
319
|
-
invalidateWriteset(params: InvalidateWritesetParams): Promise<InvalidateWritesetResult>;
|
|
320
|
-
/**
|
|
321
|
-
* Single point through which RPCs go. Throws on transport / server error.
|
|
322
|
-
* `registerSubscription`, `updateSubscriptionReadSet`, and
|
|
323
|
-
* `unregisterSubscription` are NOT gated on the ready state: during a
|
|
324
|
-
* disconnect they will fail at the socket layer, and during recovery
|
|
325
|
-
* (which itself uses these methods) gating would deadlock.
|
|
326
|
-
*/
|
|
327
|
-
private call;
|
|
328
|
-
private appendToBuffer;
|
|
329
|
-
private flushBuffer;
|
|
330
|
-
private markBusy;
|
|
331
|
-
private markReady;
|
|
332
|
-
private handleClose;
|
|
333
|
-
private handleOpen;
|
|
334
|
-
private runRecovery;
|
|
335
|
-
/**
|
|
336
|
-
* Test/inspection helpers.
|
|
337
|
-
*/
|
|
338
|
-
/** @internal */
|
|
339
|
-
isReady(): boolean;
|
|
340
|
-
/** @internal */
|
|
341
|
-
bufferSize(): number;
|
|
342
|
-
}
|
|
343
|
-
//#endregion
|
|
344
244
|
//#region src/db/init_db.d.ts
|
|
345
245
|
/**
|
|
346
246
|
* Current core runtime-bootstrap version. Bump this whenever core needs a new
|
|
@@ -426,5 +326,5 @@ declare function generateSubscriptionId(procedure: string, input: unknown | stri
|
|
|
426
326
|
*/
|
|
427
327
|
declare function generateCacheKey(queryName: string, input: unknown | string, queryIdentity: string): Promise<string>;
|
|
428
328
|
//#endregion
|
|
429
|
-
export { ANONYMOUS_IDENTITY, type AffectedSubscription, CORE_VERSION, CacheLayer, DB_QUERY_TIMEOUT_MS, DevScheduler, type DevSchedulerOptions, type EnqueueOptions, type IncomingJobRequest, InitCacheLayerOptions, InitDbOptions, type InvalidateWritesetParams, InvalidateWritesetParamsSchema, type InvalidateWritesetResult, JobClient, type JobScheduler, QStashScheduler, type QStashSchedulerOptions, type RegisterSubscriptionParams, RegisterSubscriptionParamsSchema, type RegisterSubscriptionResult, type ScheduleHandle, type ScheduledJobDef, type SubId, SubManagerClient, SubscriptionManager, SupaliveWebSocketServer, type UnregisterSubscriptionParams, UnregisterSubscriptionParamsSchema, type UnregisterSubscriptionResult, type UpdateSubscriptionReadSetParams, UpdateSubscriptionReadSetParamsSchema, type UpdateSubscriptionReadSetResult, appInstanceId, bootstrapDbTypes, createDatabase, generateCacheKey, generateSubscriptionId, getHashOf, initCacheLayer, initCore, initDatabase, isProduction, logLevelOf, logger, serializeMapValue };
|
|
329
|
+
export { ANONYMOUS_IDENTITY, type AffectedSubscription, CORE_VERSION, CacheLayer, DB_QUERY_TIMEOUT_MS, DevScheduler, type DevSchedulerOptions, type EnqueueOptions, type IncomingJobRequest, InitCacheLayerOptions, InitDbOptions, type InvalidateWritesetParams, InvalidateWritesetParamsSchema, type InvalidateWritesetResult, JobClient, type JobScheduler, QStashScheduler, type QStashSchedulerOptions, type RegisterSubscriptionParams, RegisterSubscriptionParamsSchema, type RegisterSubscriptionResult, type ScheduleHandle, type ScheduledJobDef, type SubId, SubManagerClient, type SubManagerLink, SubscriptionManager, SupaliveWebSocketServer, type UnregisterSubscriptionParams, UnregisterSubscriptionParamsSchema, type UnregisterSubscriptionResult, type UpdateSubscriptionReadSetParams, UpdateSubscriptionReadSetParamsSchema, type UpdateSubscriptionReadSetResult, appInstanceId, bootstrapDbTypes, createDatabase, generateCacheKey, generateSubscriptionId, getHashOf, initCacheLayer, initCore, initDatabase, isProduction, logLevelOf, logger, serializeMapValue };
|
|
430
330
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/supalive-server.ts","../../../src/logger.ts","../../../src/server/
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/supalive-server.ts","../../../src/logger.ts","../../../src/server/sub-manager.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;EA0K2B;EAAA,iBAxKlB,iBAAA;EAAA,QACT,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;EAkpC0D;EAAA,QAhpC1D,OAAA;EAAA,QAEA,QAAA;EAAA,QACA,mBAAA;EAAA,QACA,gBAAA;EAAA,QAEA,KAAA;cAMI,MAAA,EAAQ,oBAAA,CAAqB,QAAA;EArCjC;;;;;;;;;;;;EAAA,QAiJA,qBAAA;EAAA,QAqBA,kBAAA;EAOR,cAAA,CAAe,MAAA,EAAQ,MAAA,MAAY,QAAA;EAK7B,KAAA,IAAS,OAAA;EArJP;;;;;;EAAA,QA6KM,gBAAA;EApCN;EAoDR,WAAA,CAAY,IAAA;EA7CW;;;;;EAsDjB,WAAA,CAAY,IAAA,UAAc,IAAA,WAAe,IAAA,GAAO,cAAA,GAAiB,OAAA,CAAQ,cAAA;EAT/E;EAeM,SAAA,CAAU,QAAA,WAAmB,OAAA;EAN7B;;;;EAeN,YAAA,IAAgB,SAAA;EAIV,IAAA,IAAQ,OAAA;EAUd,QAAA;;;;;;EASA,aAAA;EAnBc;;;;;EAAA,QA4BA,iBAAA;EAAA,QA6EN,sBAAA;EAAA,QAQM,gBAAA;EAAA,QAiDA,aAAA;EAAA,QAeA,cAAA;EAAA,QAiBA,UAAA;EAjBA;;;;;;;EAAA,QAoDN,eAAA;EAwVM;;;;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