@supalive/core 1.12.0 → 1.13.1

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.
Files changed (219) hide show
  1. package/dist/db-ClCicssQ.js.map +1 -1
  2. package/dist/helper-zdJT5FUc.js +58 -0
  3. package/dist/helper-zdJT5FUc.js.map +1 -0
  4. package/dist/index-BIIcgvu8.d.ts +2300 -0
  5. package/dist/index-BIIcgvu8.d.ts.map +1 -0
  6. package/dist/index-BedlCLem.d.ts +2292 -0
  7. package/dist/index-BedlCLem.d.ts.map +1 -0
  8. package/dist/index-BnV8LnOf.d.ts +2286 -0
  9. package/dist/index-BnV8LnOf.d.ts.map +1 -0
  10. package/dist/index-BziK63TZ.d.ts +2271 -0
  11. package/dist/index-BziK63TZ.d.ts.map +1 -0
  12. package/dist/index-C_i3U4cd.d.ts +2302 -0
  13. package/dist/index-C_i3U4cd.d.ts.map +1 -0
  14. package/dist/index-D31hMBDE.d.ts +2288 -0
  15. package/dist/index-D31hMBDE.d.ts.map +1 -0
  16. package/dist/index-DZhReQWB.d.ts +2288 -0
  17. package/dist/index-DZhReQWB.d.ts.map +1 -0
  18. package/dist/index-DlG8HDCO.d.ts +2215 -0
  19. package/dist/index-DlG8HDCO.d.ts.map +1 -0
  20. package/dist/index-Wgi_dGzj.d.ts +2215 -0
  21. package/dist/index-Wgi_dGzj.d.ts.map +1 -0
  22. package/dist/index-j3YTMNlF.d.ts +2223 -0
  23. package/dist/index-j3YTMNlF.d.ts.map +1 -0
  24. package/dist/mysql-BBbilD4I.js +614 -0
  25. package/dist/mysql-BBbilD4I.js.map +1 -0
  26. package/dist/mysql-BHJ2mrwZ.d.ts +113 -0
  27. package/dist/mysql-BHJ2mrwZ.d.ts.map +1 -0
  28. package/dist/mysql-BPWGBeum.js +623 -0
  29. package/dist/mysql-BPWGBeum.js.map +1 -0
  30. package/dist/mysql-BQbHJ_rK.js +617 -0
  31. package/dist/mysql-BQbHJ_rK.js.map +1 -0
  32. package/dist/mysql-BXoAON7c.d.ts +113 -0
  33. package/dist/mysql-BXoAON7c.d.ts.map +1 -0
  34. package/dist/mysql-BgfCUYGt.d.ts +113 -0
  35. package/dist/mysql-BgfCUYGt.d.ts.map +1 -0
  36. package/dist/mysql-Br7MqUXg.js +620 -0
  37. package/dist/mysql-Br7MqUXg.js.map +1 -0
  38. package/dist/mysql-BrueWtO9.d.ts +113 -0
  39. package/dist/mysql-BrueWtO9.d.ts.map +1 -0
  40. package/dist/mysql-CCo--z6n.d.ts +113 -0
  41. package/dist/mysql-CCo--z6n.d.ts.map +1 -0
  42. package/dist/mysql-CQcbcZB8.d.ts +113 -0
  43. package/dist/mysql-CQcbcZB8.d.ts.map +1 -0
  44. package/dist/mysql-CbgCY89y.d.ts +113 -0
  45. package/dist/mysql-CbgCY89y.d.ts.map +1 -0
  46. package/dist/mysql-CqD1ZnNY.js +619 -0
  47. package/dist/mysql-CqD1ZnNY.js.map +1 -0
  48. package/dist/mysql-D3Db2q3_.js +619 -0
  49. package/dist/mysql-D3Db2q3_.js.map +1 -0
  50. package/dist/mysql-DBrhTmYm.js +619 -0
  51. package/dist/mysql-DBrhTmYm.js.map +1 -0
  52. package/dist/mysql-DX7YA7IS.d.ts +113 -0
  53. package/dist/mysql-DX7YA7IS.d.ts.map +1 -0
  54. package/dist/mysql-DZ0_Rsjc.js +614 -0
  55. package/dist/mysql-DZ0_Rsjc.js.map +1 -0
  56. package/dist/mysql-Di6iuKWT.d.ts +114 -0
  57. package/dist/mysql-Di6iuKWT.d.ts.map +1 -0
  58. package/dist/mysql-Dko1MJqQ.js +619 -0
  59. package/dist/mysql-Dko1MJqQ.js.map +1 -0
  60. package/dist/mysql-F831ycnw.d.ts +113 -0
  61. package/dist/mysql-F831ycnw.d.ts.map +1 -0
  62. package/dist/mysql-TLPG62tv.js +618 -0
  63. package/dist/mysql-TLPG62tv.js.map +1 -0
  64. package/dist/mysql-e-ii74yG.js +613 -0
  65. package/dist/mysql-e-ii74yG.js.map +1 -0
  66. package/dist/overlap-checker-BBkqRdcs.js +259 -0
  67. package/dist/overlap-checker-BBkqRdcs.js.map +1 -0
  68. package/dist/overlap-checker-DHUJe-Yy.js +259 -0
  69. package/dist/overlap-checker-DHUJe-Yy.js.map +1 -0
  70. package/dist/overlap-checker-DWeQLpSD.js +259 -0
  71. package/dist/overlap-checker-DWeQLpSD.js.map +1 -0
  72. package/dist/overlap-checker-Kz7B_jsp.js +259 -0
  73. package/dist/overlap-checker-Kz7B_jsp.js.map +1 -0
  74. package/dist/postgres-7hJuQX4Y.d.ts +117 -0
  75. package/dist/postgres-7hJuQX4Y.d.ts.map +1 -0
  76. package/dist/postgres-B4H78IkW.js +864 -0
  77. package/dist/postgres-B4H78IkW.js.map +1 -0
  78. package/dist/postgres-B4h8D5U2.d.ts +117 -0
  79. package/dist/postgres-B4h8D5U2.d.ts.map +1 -0
  80. package/dist/postgres-BXFPamkP.js +864 -0
  81. package/dist/postgres-BXFPamkP.js.map +1 -0
  82. package/dist/postgres-CkhK4DqZ.d.ts +118 -0
  83. package/dist/postgres-CkhK4DqZ.d.ts.map +1 -0
  84. package/dist/postgres-CoR3TUMd.js +865 -0
  85. package/dist/postgres-CoR3TUMd.js.map +1 -0
  86. package/dist/postgres-D-RsG12a.d.ts +117 -0
  87. package/dist/postgres-D-RsG12a.d.ts.map +1 -0
  88. package/dist/postgres-D5Z1S3J9.d.ts +117 -0
  89. package/dist/postgres-D5Z1S3J9.d.ts.map +1 -0
  90. package/dist/postgres-DHs89iWT.js +864 -0
  91. package/dist/postgres-DHs89iWT.js.map +1 -0
  92. package/dist/postgres-DvBIRnYA.d.ts +117 -0
  93. package/dist/postgres-DvBIRnYA.d.ts.map +1 -0
  94. package/dist/postgres-Eo-lpUiX.d.ts +117 -0
  95. package/dist/postgres-Eo-lpUiX.d.ts.map +1 -0
  96. package/dist/postgres-VLAGIFLR.d.ts +117 -0
  97. package/dist/postgres-VLAGIFLR.d.ts.map +1 -0
  98. package/dist/postgres-ZKEo6Mjg.js +868 -0
  99. package/dist/postgres-ZKEo6Mjg.js.map +1 -0
  100. package/dist/postgres-hrQmDPUp.d.ts +117 -0
  101. package/dist/postgres-hrQmDPUp.d.ts.map +1 -0
  102. package/dist/postgres-pXrP9Fx0.d.ts +117 -0
  103. package/dist/postgres-pXrP9Fx0.d.ts.map +1 -0
  104. package/dist/query-BuOs9w-U.js +730 -0
  105. package/dist/query-BuOs9w-U.js.map +1 -0
  106. package/dist/query-Xw2hi6TB.js +730 -0
  107. package/dist/query-Xw2hi6TB.js.map +1 -0
  108. package/dist/read-routing-BUcQAwnd.js +62 -0
  109. package/dist/read-routing-BUcQAwnd.js.map +1 -0
  110. package/dist/read-routing-BXflWzQI.js +61 -0
  111. package/dist/read-routing-BXflWzQI.js.map +1 -0
  112. package/dist/read-routing-CcsLp0ow.js +61 -0
  113. package/dist/read-routing-CcsLp0ow.js.map +1 -0
  114. package/dist/realtime_db-B70vqtRZ.js +272 -0
  115. package/dist/realtime_db-B70vqtRZ.js.map +1 -0
  116. package/dist/realtime_db-BMysrWym.js +312 -0
  117. package/dist/realtime_db-BMysrWym.js.map +1 -0
  118. package/dist/realtime_db-Bi7S938D.js +312 -0
  119. package/dist/realtime_db-Bi7S938D.js.map +1 -0
  120. package/dist/realtime_db-CVze3gM0.js +312 -0
  121. package/dist/realtime_db-CVze3gM0.js.map +1 -0
  122. package/dist/realtime_db-DMipkUmD.js +312 -0
  123. package/dist/realtime_db-DMipkUmD.js.map +1 -0
  124. package/dist/realtime_db-XWzuq2JS.js +272 -0
  125. package/dist/realtime_db-XWzuq2JS.js.map +1 -0
  126. package/dist/router-Kgrlci8X.js +337 -0
  127. package/dist/router-Kgrlci8X.js.map +1 -0
  128. package/dist/router-g8qSQb8m.js +314 -0
  129. package/dist/router-g8qSQb8m.js.map +1 -0
  130. package/dist/schema-DLue3K2s.js +134 -0
  131. package/dist/schema-DLue3K2s.js.map +1 -0
  132. package/dist/schema-DfowI0ip.js +134 -0
  133. package/dist/schema-DfowI0ip.js.map +1 -0
  134. package/dist/schema-fKldWzwc.js +134 -0
  135. package/dist/schema-fKldWzwc.js.map +1 -0
  136. package/dist/src/client/index.d.ts +1 -1
  137. package/dist/src/client/index.js +69 -29
  138. package/dist/src/client/index.js.map +1 -1
  139. package/dist/src/exports/mysql.d.ts +1 -1
  140. package/dist/src/exports/mysql.js +1 -1
  141. package/dist/src/exports/postgres.d.ts +1 -1
  142. package/dist/src/exports/postgres.js +1 -1
  143. package/dist/src/exports/procedure.d.ts +1 -1
  144. package/dist/src/exports/procedure.js +5 -6
  145. package/dist/src/exports/procedure.js.map +1 -1
  146. package/dist/src/exports/schema-sql.d.ts +18 -1
  147. package/dist/src/exports/schema-sql.d.ts.map +1 -1
  148. package/dist/src/exports/schema-sql.js +91 -15
  149. package/dist/src/exports/schema-sql.js.map +1 -1
  150. package/dist/src/exports/server.d.ts +16 -6
  151. package/dist/src/exports/server.d.ts.map +1 -1
  152. package/dist/src/exports/server.js +136 -59
  153. package/dist/src/exports/server.js.map +1 -1
  154. package/dist/src/exports/sub-manager-worker-entry.js +1 -1
  155. package/dist/src/exports/types.d.ts +2 -2
  156. package/dist/src/exports/types.js +4 -4
  157. package/dist/sub-worker-dispatch-CO9nVdSG.js +813 -0
  158. package/dist/sub-worker-dispatch-CO9nVdSG.js.map +1 -0
  159. package/dist/sub-worker-dispatch-CQBknEL7.js +813 -0
  160. package/dist/sub-worker-dispatch-CQBknEL7.js.map +1 -0
  161. package/dist/sub-worker-dispatch-CQHeit6D.js +813 -0
  162. package/dist/sub-worker-dispatch-CQHeit6D.js.map +1 -0
  163. package/dist/sub-worker-dispatch-CmEW10it.js +813 -0
  164. package/dist/sub-worker-dispatch-CmEW10it.js.map +1 -0
  165. package/dist/sub-worker-dispatch-CunxuOPT.js +823 -0
  166. package/dist/sub-worker-dispatch-CunxuOPT.js.map +1 -0
  167. package/dist/sub-worker-dispatch-CvvFm40r.js +817 -0
  168. package/dist/sub-worker-dispatch-CvvFm40r.js.map +1 -0
  169. package/dist/sub-worker-dispatch-CzwVHQVi.js +826 -0
  170. package/dist/sub-worker-dispatch-CzwVHQVi.js.map +1 -0
  171. package/dist/sub-worker-dispatch-D15UHo1g.js +813 -0
  172. package/dist/sub-worker-dispatch-D15UHo1g.js.map +1 -0
  173. package/dist/sub-worker-dispatch-D8DY56ry.js +817 -0
  174. package/dist/sub-worker-dispatch-D8DY56ry.js.map +1 -0
  175. package/dist/sub-worker-dispatch-DJgWxtSQ.js +823 -0
  176. package/dist/sub-worker-dispatch-DJgWxtSQ.js.map +1 -0
  177. package/dist/sub-worker-dispatch-Dplqeubd.js +813 -0
  178. package/dist/sub-worker-dispatch-Dplqeubd.js.map +1 -0
  179. package/dist/sub-worker-dispatch-MneZYjXl.js +823 -0
  180. package/dist/sub-worker-dispatch-MneZYjXl.js.map +1 -0
  181. package/dist/sub-worker-dispatch-dXjUmSMN.js +813 -0
  182. package/dist/sub-worker-dispatch-dXjUmSMN.js.map +1 -0
  183. package/dist/table-id-BJdmctEQ.js +91 -0
  184. package/dist/table-id-BJdmctEQ.js.map +1 -0
  185. package/dist/table-id-DyrJBKAQ.js +105 -0
  186. package/dist/table-id-DyrJBKAQ.js.map +1 -0
  187. package/dist/types_client_rpc-BGMwPJst.js +123 -0
  188. package/dist/types_client_rpc-BGMwPJst.js.map +1 -0
  189. package/dist/types_client_rpc-ByGwoRCL.js +132 -0
  190. package/dist/types_client_rpc-ByGwoRCL.js.map +1 -0
  191. package/dist/types_db-BsR02Sph.js +171 -0
  192. package/dist/types_db-BsR02Sph.js.map +1 -0
  193. package/dist/types_db-CgGlOMmr.js +187 -0
  194. package/dist/types_db-CgGlOMmr.js.map +1 -0
  195. package/dist/types_db-OUou3o2Z.js +172 -0
  196. package/dist/types_db-OUou3o2Z.js.map +1 -0
  197. package/dist/types_server-B3z8hi-Z.d.ts +523 -0
  198. package/dist/types_server-B3z8hi-Z.d.ts.map +1 -0
  199. package/dist/types_server-BXBvz4T8.d.ts +523 -0
  200. package/dist/types_server-BXBvz4T8.d.ts.map +1 -0
  201. package/dist/types_server-BhC19R2a.js +27 -0
  202. package/dist/types_server-BhC19R2a.js.map +1 -0
  203. package/dist/types_server-CClUPZn1.d.ts +521 -0
  204. package/dist/types_server-CClUPZn1.d.ts.map +1 -0
  205. package/dist/types_server-CG453PHb.d.ts +523 -0
  206. package/dist/types_server-CG453PHb.d.ts.map +1 -0
  207. package/dist/types_server-CnYTSPhM.d.ts +523 -0
  208. package/dist/types_server-CnYTSPhM.d.ts.map +1 -0
  209. package/dist/types_server-DHpGUHB_.d.ts +521 -0
  210. package/dist/types_server-DHpGUHB_.d.ts.map +1 -0
  211. package/dist/types_server-Ded1u3bL.d.ts +521 -0
  212. package/dist/types_server-Ded1u3bL.d.ts.map +1 -0
  213. package/dist/types_server-fons7nmo.d.ts +523 -0
  214. package/dist/types_server-fons7nmo.d.ts.map +1 -0
  215. package/dist/types_server-okvBG4v_.d.ts +521 -0
  216. package/dist/types_server-okvBG4v_.d.ts.map +1 -0
  217. package/dist/types_server-pD8DiI7s.d.ts +521 -0
  218. package/dist/types_server-pD8DiI7s.d.ts.map +1 -0
  219. package/package.json +1 -1
@@ -0,0 +1,2223 @@
1
+ import { r as ObjectStorage } from "./object-storage-354KU6Mj.js";
2
+ import z, { ZodRawShape, ZodType, z as z$1, z as z$2 } from "zod";
3
+ import { RetryPolicy } from "cockatiel";
4
+ import Redis$1 from "ioredis";
5
+ import { Redis as Redis$2 } from "@upstash/redis";
6
+
7
+ //#region src/db/types_db.d.ts
8
+ /** Monotonically increasing integer from global_commit_ts sequence in Postgres */
9
+ type CommitTs = bigint;
10
+ declare const BigIntSchema: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
11
+ declare const CompareOperatorSchema: z.ZodEnum<{
12
+ "=": "=";
13
+ "!=": "!=";
14
+ ">": ">";
15
+ ">=": ">=";
16
+ "<": "<";
17
+ "<=": "<=";
18
+ like: "like";
19
+ ilike: "ilike";
20
+ contains: "contains";
21
+ icontains: "icontains";
22
+ between: "between";
23
+ in: "in";
24
+ jsonContains: "jsonContains";
25
+ jsonContainedBy: "jsonContainedBy";
26
+ jsonHasKey: "jsonHasKey";
27
+ jsonArrayContains: "jsonArrayContains";
28
+ isNull: "isNull";
29
+ isNotNull: "isNotNull";
30
+ }>;
31
+ type CompareOperator = z.infer<typeof CompareOperatorSchema>;
32
+ type Predicate = LeafPredicate | {
33
+ kind: "and";
34
+ children: Predicate[];
35
+ } | {
36
+ kind: "or";
37
+ children: Predicate[];
38
+ };
39
+ declare const PredicateSchema: z.ZodType<Predicate>;
40
+ declare const LeafPredicateSchema: z.ZodObject<{
41
+ kind: z.ZodLiteral<"leaf">;
42
+ column: z.ZodString;
43
+ operator: z.ZodEnum<{
44
+ "=": "=";
45
+ "!=": "!=";
46
+ ">": ">";
47
+ ">=": ">=";
48
+ "<": "<";
49
+ "<=": "<=";
50
+ like: "like";
51
+ ilike: "ilike";
52
+ contains: "contains";
53
+ icontains: "icontains";
54
+ between: "between";
55
+ in: "in";
56
+ jsonContains: "jsonContains";
57
+ jsonContainedBy: "jsonContainedBy";
58
+ jsonHasKey: "jsonHasKey";
59
+ jsonArrayContains: "jsonArrayContains";
60
+ isNull: "isNull";
61
+ isNotNull: "isNotNull";
62
+ }>;
63
+ value: z.ZodUnknown;
64
+ value2: z.ZodOptional<z.ZodUnknown>;
65
+ raw: z.ZodOptional<z.ZodBoolean>;
66
+ path: z.ZodOptional<z.ZodString>;
67
+ mode: z.ZodOptional<z.ZodEnum<{
68
+ one: "one";
69
+ all: "all";
70
+ }>>;
71
+ }, z.core.$strip>;
72
+ type LeafPredicate = z.infer<typeof LeafPredicateSchema>;
73
+ declare const AndPredicateSchema: z.ZodObject<{
74
+ kind: z.ZodLiteral<"and">;
75
+ children: z.ZodArray<z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>>;
76
+ }, z.core.$strip>;
77
+ type AndPredicate = z.infer<typeof AndPredicateSchema>;
78
+ declare const OrPredicateSchema: z.ZodObject<{
79
+ kind: z.ZodLiteral<"or">;
80
+ children: z.ZodArray<z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>>;
81
+ }, z.core.$strip>;
82
+ type OrPredicate = z.infer<typeof OrPredicateSchema>;
83
+ /** Query specification - what was queried (used for cache key generation) */
84
+ type QuerySpec = ReadEntry;
85
+ declare function normalizeIdToBytes(id: string | number, fromHex?: boolean): Uint8Array;
86
+ declare function normalizeToBytes(value: Uint8Array | unknown): Uint8Array;
87
+ declare function bytesFromJson(value: Uint8Array | unknown): Uint8Array;
88
+ declare const PointReadSchema: z.ZodObject<{
89
+ kind: z.ZodLiteral<"point">;
90
+ table: z.ZodString;
91
+ id: z.ZodString;
92
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
93
+ }, z.core.$strip>;
94
+ type PointRead = z.infer<typeof PointReadSchema>;
95
+ declare const RawPointReadSchema: z.ZodObject<{
96
+ kind: z.ZodLiteral<"point">;
97
+ tableId: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
98
+ id: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
99
+ table: z.ZodString;
100
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
101
+ }, z.core.$strip>;
102
+ type RawPointRead = z.infer<typeof RawPointReadSchema>;
103
+ /**
104
+ * Query specification for a range read (get with filters).
105
+ * This is the query definition, not the result.
106
+ */
107
+ declare const RangeReadSchema: z.ZodObject<{
108
+ kind: z.ZodLiteral<"range">;
109
+ table: z.ZodString;
110
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
111
+ columns: z.ZodArray<z.ZodString>;
112
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
113
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
114
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
115
+ }, z.core.$strip>;
116
+ type RangeRead = z.infer<typeof RangeReadSchema>;
117
+ declare const RawRangeReadSchema: z.ZodObject<{
118
+ kind: z.ZodLiteral<"range">;
119
+ table: z.ZodString;
120
+ tableId: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
121
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
122
+ columns: z.ZodArray<z.ZodString>;
123
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
124
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
125
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
126
+ }, z.core.$strip>;
127
+ type RawRangeRead = z.infer<typeof RawRangeReadSchema>;
128
+ declare const ReadEntrySchema: z.ZodUnion<readonly [z.ZodObject<{
129
+ kind: z.ZodLiteral<"point">;
130
+ table: z.ZodString;
131
+ id: z.ZodString;
132
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ kind: z.ZodLiteral<"range">;
135
+ table: z.ZodString;
136
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
137
+ columns: z.ZodArray<z.ZodString>;
138
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
139
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
140
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
141
+ }, z.core.$strip>]>;
142
+ type ReadEntry = z.infer<typeof ReadEntrySchema>;
143
+ declare const RawReadEntrySchema: z.ZodUnion<readonly [z.ZodObject<{
144
+ kind: z.ZodLiteral<"point">;
145
+ tableId: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
146
+ id: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
147
+ table: z.ZodString;
148
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
149
+ }, z.core.$strip>, z.ZodObject<{
150
+ kind: z.ZodLiteral<"range">;
151
+ table: z.ZodString;
152
+ tableId: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
153
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
154
+ columns: z.ZodArray<z.ZodString>;
155
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
156
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
157
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
158
+ }, z.core.$strip>]>;
159
+ type RawReadEntry = z.infer<typeof RawReadEntrySchema>;
160
+ declare const WriteOpSchema: z.ZodEnum<{
161
+ insert: "insert";
162
+ update: "update";
163
+ delete: "delete";
164
+ }>;
165
+ type WriteOp = z.infer<typeof WriteOpSchema>;
166
+ declare const WriteEntrySchema: z.ZodObject<{
167
+ table: z.ZodString;
168
+ tableId: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
169
+ id: z.ZodString;
170
+ op: z.ZodEnum<{
171
+ insert: "insert";
172
+ update: "update";
173
+ delete: "delete";
174
+ }>;
175
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
176
+ prevData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
177
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
178
+ }, z.core.$strip>;
179
+ type WriteEntry = z.infer<typeof WriteEntrySchema>;
180
+ interface CommitLogEntry {
181
+ id: Uint8Array;
182
+ ts: bigint;
183
+ tableId: Uint8Array;
184
+ data: Uint8Array;
185
+ _parsedData?: Record<string, unknown> | null;
186
+ }
187
+ interface MutationResult<T> {
188
+ result: T;
189
+ writeSet: WriteEntry[];
190
+ commitTs: CommitTs;
191
+ }
192
+ interface LiveResult<T> {
193
+ ts: bigint;
194
+ data: T;
195
+ readSet: ReadEntry[];
196
+ }
197
+ declare const QueryCacheMetadataSchema: z.ZodObject<{
198
+ lastSnapshotTs: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
199
+ version: z.ZodString;
200
+ readSet: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
201
+ kind: z.ZodLiteral<"point">;
202
+ table: z.ZodString;
203
+ id: z.ZodString;
204
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
205
+ }, z.core.$strip>, z.ZodObject<{
206
+ kind: z.ZodLiteral<"range">;
207
+ table: z.ZodString;
208
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
209
+ columns: z.ZodArray<z.ZodString>;
210
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
211
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
212
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
213
+ }, z.core.$strip>]>>;
214
+ }, z.core.$strip>;
215
+ type QueryCacheMetadata = z.infer<typeof QueryCacheMetadataSchema>;
216
+ declare const QueryCacheEntrySchema: z.ZodObject<{
217
+ data: z.ZodUnknown;
218
+ version: z.ZodString;
219
+ }, z.core.$strip>;
220
+ type QueryCacheEntry = z.infer<typeof QueryCacheEntrySchema>;
221
+ declare const CachedPgMetadataSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>;
222
+ type CachedPgMetadata = z.infer<typeof CachedPgMetadataSchema>;
223
+ interface RetryConfig {
224
+ maxAttempts: number;
225
+ backoff: "none" | "linear" | "exponential";
226
+ delayMs?: number;
227
+ onConflict?: (attempt: number, error: OccConflictError) => void;
228
+ }
229
+ declare const NO_RETRY: RetryConfig;
230
+ declare const DEFAULT_RETRY: RetryConfig;
231
+ declare class OccConflictError extends Error {
232
+ readonly reason: string;
233
+ readonly conflictDetail?: unknown | undefined;
234
+ constructor(reason: string, conflictDetail?: unknown | undefined);
235
+ static isOccConflictError(err: unknown): boolean;
236
+ }
237
+ declare class OccAbortError extends Error {
238
+ constructor(message: string);
239
+ }
240
+ //#endregion
241
+ //#region src/server/sub-manager-types.d.ts
242
+ declare const RegisterSubscriptionParamsSchema: z.ZodObject<{
243
+ subId: z.ZodString;
244
+ cacheKey: z.ZodString;
245
+ queryName: z.ZodString;
246
+ args: z.ZodUnknown;
247
+ queryIdentity: z.ZodString;
248
+ instanceName: z.ZodString;
249
+ lastSnapshotTs: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
250
+ }, z.core.$strip>;
251
+ type RegisterSubscriptionParams = z.infer<typeof RegisterSubscriptionParamsSchema>;
252
+ declare const RegisterSubscriptionResultSchema: z.ZodObject<{
253
+ cacheKey: z.ZodString;
254
+ recompute: z.ZodBoolean;
255
+ readSet: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
256
+ kind: z.ZodLiteral<"point">;
257
+ table: z.ZodString;
258
+ id: z.ZodString;
259
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
260
+ }, z.core.$strip>, z.ZodObject<{
261
+ kind: z.ZodLiteral<"range">;
262
+ table: z.ZodString;
263
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
264
+ columns: z.ZodArray<z.ZodString>;
265
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
266
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
267
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
268
+ }, z.core.$strip>]>>;
269
+ version: z.ZodOptional<z.ZodString>;
270
+ }, z.core.$strip>;
271
+ type RegisterSubscriptionResult = z.infer<typeof RegisterSubscriptionResultSchema>;
272
+ declare const UpdateSubscriptionReadSetParamsSchema: z.ZodObject<{
273
+ cacheKey: z.ZodString;
274
+ subId: z.ZodString;
275
+ instanceName: z.ZodString;
276
+ lastSnapshotTs: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
277
+ readSet: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
278
+ kind: z.ZodLiteral<"point">;
279
+ table: z.ZodString;
280
+ id: z.ZodString;
281
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
282
+ }, z.core.$strip>, z.ZodObject<{
283
+ kind: z.ZodLiteral<"range">;
284
+ table: z.ZodString;
285
+ predicate: z.ZodType<Predicate, unknown, z.core.$ZodTypeInternals<Predicate, unknown>>;
286
+ columns: z.ZodArray<z.ZodString>;
287
+ orderBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
288
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
289
+ offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
290
+ }, z.core.$strip>]>>;
291
+ }, z.core.$strip>;
292
+ type UpdateSubscriptionReadSetParams = z.infer<typeof UpdateSubscriptionReadSetParamsSchema>;
293
+ /**
294
+ * `tracked: false` means the sub-manager has no record of this subId (e.g.
295
+ * a restart wiped state and the caller hasn't re-registered yet). The app
296
+ * server should treat this as a signal to register the sub before retrying.
297
+ */
298
+ declare const UpdateSubscriptionReadSetResultSchema: z.ZodObject<{
299
+ tracked: z.ZodBoolean;
300
+ }, z.core.$strip>;
301
+ type UpdateSubscriptionReadSetResult = z.infer<typeof UpdateSubscriptionReadSetResultSchema>;
302
+ declare const UnregisterSubscriptionParamsSchema: z.ZodObject<{
303
+ subId: z.ZodString;
304
+ instanceName: z.ZodString;
305
+ }, z.core.$strip>;
306
+ type UnregisterSubscriptionParams = z.infer<typeof UnregisterSubscriptionParamsSchema>;
307
+ declare const UnregisterSubscriptionsParamsSchema: z.ZodArray<z.ZodObject<{
308
+ subId: z.ZodString;
309
+ instanceName: z.ZodString;
310
+ }, z.core.$strip>>;
311
+ type UnregisterSubscriptionsParams = z.infer<typeof UnregisterSubscriptionsParamsSchema>;
312
+ declare const UnregisterSubscriptionResultSchema: z.ZodObject<{
313
+ ok: z.ZodBoolean;
314
+ }, z.core.$strip>;
315
+ type UnregisterSubscriptionResult = z.infer<typeof UnregisterSubscriptionResultSchema>;
316
+ declare const UnregisterSubscriptionsResultSchema: z.ZodArray<z.ZodObject<{
317
+ ok: z.ZodBoolean;
318
+ }, z.core.$strip>>;
319
+ type UnregisterSubscriptionsResult = z.infer<typeof UnregisterSubscriptionsResultSchema>;
320
+ declare const InvalidateWritesetParamsSchema: z.ZodObject<{
321
+ writeSet: z.ZodArray<z.ZodObject<{
322
+ table: z.ZodString;
323
+ tableId: z.ZodPipe<z.ZodAny, z.ZodTransform<Uint8Array<ArrayBufferLike>, any>>;
324
+ id: z.ZodString;
325
+ op: z.ZodEnum<{
326
+ insert: "insert";
327
+ update: "update";
328
+ delete: "delete";
329
+ }>;
330
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
331
+ prevData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
332
+ expectedCommitTs: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>>>;
333
+ }, z.core.$strip>>;
334
+ }, z.core.$strip>;
335
+ type InvalidateWritesetParams = z.infer<typeof InvalidateWritesetParamsSchema>;
336
+ declare const AffectedSubscriptionSchema: z.ZodObject<{
337
+ subId: z.ZodString;
338
+ queryName: z.ZodString;
339
+ args: z.ZodUnknown;
340
+ cacheKey: z.ZodString;
341
+ notifyInstances: z.ZodArray<z.ZodString>;
342
+ }, z.core.$strip>;
343
+ type AffectedSubscription = z.infer<typeof AffectedSubscriptionSchema>;
344
+ declare const InvalidateWritesetResultSchema: z.ZodObject<{
345
+ affected: z.ZodArray<z.ZodObject<{
346
+ subId: z.ZodString;
347
+ queryName: z.ZodString;
348
+ args: z.ZodUnknown;
349
+ cacheKey: z.ZodString;
350
+ notifyInstances: z.ZodArray<z.ZodString>;
351
+ }, z.core.$strip>>;
352
+ }, z.core.$strip>;
353
+ type InvalidateWritesetResult = z.infer<typeof InvalidateWritesetResultSchema>;
354
+ declare const RegistrationRecordSchema: z.ZodObject<{
355
+ queryName: z.ZodString;
356
+ args: z.ZodUnknown;
357
+ queryIdentity: z.ZodString;
358
+ cacheKey: z.ZodString;
359
+ }, z.core.$strip>;
360
+ type RegistrationRecord = z.infer<typeof RegistrationRecordSchema>;
361
+ //#endregion
362
+ //#region src/db/cache.d.ts
363
+ declare class CacheLayer {
364
+ redis: Redis$1 | Redis$2;
365
+ private readonly ttlSeconds;
366
+ /** Cached EVALSHA digests keyed by Lua source (see evalScript). */
367
+ private readonly scriptShaCache;
368
+ constructor(upstash: Redis$1 | Redis$2, ttlSeconds?: number);
369
+ /**
370
+ * Run a Lua script via EVALSHA using the script's SHA1 (computed locally — the
371
+ * same digest Redis keys scripts by, so no SCRIPT LOAD round-trip is needed on
372
+ * the hot path). On NOSCRIPT (the script isn't in Redis's cache yet, e.g. first
373
+ * use or after a Redis restart/failover) load it explicitly via SCRIPT LOAD and
374
+ * re-run via EVALSHA — so the script ends up cached server-side and subsequent
375
+ * EVALSHA calls hit. The runtime client is always ioredis (see initCacheLayer).
376
+ */
377
+ private evalScript;
378
+ /** One-shot recompute: atomically write data + metadata (CAS on version). */
379
+ setQueryCacheAndMetadataFor(cacheKey: string, data: unknown, metaData: QueryCacheMetadata, ttlSeconds?: number): Promise<void>;
380
+ /** Subscribe path: write the data blob only (CAS against the metadata's
381
+ * version). The metadata is written separately by the sub-worker; the
382
+ * `version` links the two so a divergent pair is detected on read. */
383
+ setQueryCacheFor(cacheKey: string, data: unknown, version: string, ttlSeconds?: number): Promise<void>;
384
+ getQueryCacheFor(cacheKey: string): Promise<QueryCacheEntry | null>;
385
+ /** Subscription recompute: replace the whole metadata (CAS on version). */
386
+ replaceQueryCacheMetadata(cacheKey: string, metaData: QueryCacheMetadata, ttlSeconds?: number): Promise<void>;
387
+ /** Still-fresh subscription: advance `lastSnapshotTs` only, preserving the
388
+ * data's `version` + `readSet` (no recompute). Monotonic and non-clobbering
389
+ * — see ADVANCE_META. `metaData` carries the new horizon plus the version +
390
+ * readSet the caller read, which the script keeps unless a newer computation
391
+ * has since landed. */
392
+ advanceQueryCacheMetadata(cacheKey: string, metaData: QueryCacheMetadata, ttlSeconds?: number): Promise<void>;
393
+ getQueryCacheMetaData(cacheKey: string): Promise<QueryCacheMetadata | null>;
394
+ persistRegistrationRecord(subId: string, record: RegistrationRecord): Promise<void>;
395
+ deleteRegistrationRecord(subId: string): Promise<void>;
396
+ deleteRegistrationsRecord(subIds: string[]): Promise<void>;
397
+ fetchRegistrationRecordsBatch(subIds: string[]): Promise<Map<string, RegistrationRecord | null>>;
398
+ getCachedTableColumnTypes(key: string): Promise<CachedPgMetadata | null>;
399
+ setCachedTableColumnsTypes(key: string, value: CachedPgMetadata): Promise<void>;
400
+ /**
401
+ * Race participant: try to claim `lock:recompute:<subId>:<commitTs>`
402
+ * with `SET NX EX`. The single Redis round-trip both arbitrates and
403
+ * sets a TTL fallback in case the winner crashes mid-recompute.
404
+ */
405
+ tryAcquireRecomputeLock(instanceId: string, subId: string, commitTs: string, ttl: number): Promise<boolean>;
406
+ private getRegistrationKey;
407
+ private getQueryCacheDataKey;
408
+ private getQeruyCacheMetaKey;
409
+ }
410
+ //#endregion
411
+ //#region src/db/db.d.ts
412
+ interface DbQueryResult<T = any> {
413
+ rows: T[];
414
+ rowCount?: number | null;
415
+ /**
416
+ * Auto-increment / LAST_INSERT_ID value from the driver, when applicable
417
+ * (MySQL `ResultSetHeader.insertId`). Used to read the advanced value back
418
+ * from `UPDATE ... SET id = LAST_INSERT_ID(id + 1)` without a second
419
+ * round-trip. Undefined for Postgres / SELECTs.
420
+ */
421
+ insertId?: number | bigint;
422
+ }
423
+ interface RawClient {
424
+ query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
425
+ }
426
+ interface PooledClient extends RawClient {
427
+ release(): void;
428
+ }
429
+ type DbType = "postgres" | "mysql";
430
+ interface PendingPointEntry {
431
+ entry: PointRead;
432
+ key: string;
433
+ }
434
+ interface PreparedQuery {
435
+ sql: string;
436
+ params: unknown[] | unknown[][];
437
+ operation: "insertSingle" | "insertBatch" | "updateSingle" | "updateBatch" | "deleteSingle" | "deleteBatch" | "pointReadValidation" | "commit_logs";
438
+ table: string;
439
+ entryId?: unknown;
440
+ expectedTs?: bigint;
441
+ entries?: WriteEntry[];
442
+ pendingsEntry?: PendingPointEntry[];
443
+ }
444
+ interface PreparedQueries {
445
+ commits: PreparedQuery[];
446
+ validateReadPoints?: PreparedQuery[];
447
+ hasRangeRead: boolean;
448
+ tableIds?: Uint8Array[];
449
+ rawReadSet?: RawReadEntry[];
450
+ }
451
+ /**
452
+ * Bound to a single dedicated connection that holds the core-init lock. Passed
453
+ * to the callback of {@link Database.withCoreInitLock} so version reads/writes
454
+ * and migration statements all run under the same lock.
455
+ */
456
+ interface CoreInitLockCtx {
457
+ exec(sql: string, params?: unknown[]): Promise<DbQueryResult>;
458
+ getVersion(): Promise<bigint>;
459
+ setVersion(version: bigint): Promise<void>;
460
+ }
461
+ interface Database {
462
+ readonly dbType: DbType;
463
+ readonly sqlBuilder: SqlBuilder;
464
+ columnTypes: Map<string, Map<string, string>>;
465
+ /**
466
+ * Current core schema version stored in `metadata.core_version`, or `0n`
467
+ * when unset. Read on a pooled connection for the lock-free fast path of
468
+ * {@link initCore}.
469
+ */
470
+ getCoreVersion(): Promise<bigint>;
471
+ /**
472
+ * Runtime bootstrap statements to apply when migrating core TO `toVersion`
473
+ * (i.e. the `toVersion - 1` → `toVersion` step): data seeds, backfills, or a
474
+ * schema change that must be applied directly at runtime. Dialect-specific;
475
+ * the core schema (tables, indexes, the `global_commit_ts` sequence/counter)
476
+ * lives in the generated schema instead — see `coreTablesSql`.
477
+ */
478
+ coreMigrationStatements(toVersion: bigint): string[];
479
+ /**
480
+ * Run `fn` while holding the cross-process core-init lock (PG
481
+ * `pg_advisory_xact_lock`, MySQL `GET_LOCK`) on a single dedicated
482
+ * connection, so concurrent servers can't race the core migration. All of
483
+ * `fn`'s work runs on that locked connection via {@link CoreInitLockCtx}.
484
+ */
485
+ withCoreInitLock(fn: (ctx: CoreInitLockCtx) => Promise<void>): Promise<void>;
486
+ bootstrapColumnTypes(opts: {
487
+ redis?: CacheLayer;
488
+ cacheKey: string;
489
+ tables?: string[];
490
+ }): Promise<void>;
491
+ query<T = any>(sql: string, params?: unknown[]): Promise<DbQueryResult<T>>;
492
+ getClient(): Promise<PooledClient>;
493
+ getTransactionClient(): Promise<TxDatabase>;
494
+ getLatestSnapshotTimestamp(): Promise<bigint>;
495
+ updateLatestSnapshotTimestamp(commitTs: bigint): Promise<void>;
496
+ /**
497
+ * The retention watermark: the boundary `ts` below which commit_logs have
498
+ * been pruned, so any cache entry whose `lastSnapshotTs` is below it can no
499
+ * longer be freshness-checked (its scan window would miss deleted rows) and
500
+ * must be recomputed. Persisted in the `metadata` table (survives restarts)
501
+ * as a cheap PK read — callers load it into an in-memory variable at startup
502
+ * and keep it fresh via pub/sub rather than reading it per query. Returns the
503
+ * -1n genesis when nothing has been pruned yet (matching the empty-DB snapshot
504
+ * ts), so every entry is scannable.
505
+ */
506
+ getMinSnapshotTimestamp(): Promise<bigint>;
507
+ /**
508
+ * Advance the retention watermark. Monotonic: only ever moves forward (a
509
+ * stale writer can never lower it). Called by the sub-manager right before it
510
+ * prunes commit_logs below `ts`.
511
+ */
512
+ updateMinSnapshotTimestamp(ts: bigint): Promise<void>;
513
+ getNextTimestamp(): Promise<bigint>;
514
+ prepareCommitWrites(readSet: ReadEntry[], writeSet: WriteEntry[], commitTs: LazyCommitTsParam): Promise<PreparedQueries>;
515
+ commitWrites(beginTs: bigint, queries: PreparedQueries, commitTs: bigint): Promise<{
516
+ success: boolean;
517
+ }>;
518
+ close(): Promise<void>;
519
+ /**
520
+ * Delete commit_logs older than `ts` (exclusive). Used by the periodic
521
+ * retention sweep in SubscriptionManager so the table doesn't grow
522
+ * unbounded.
523
+ */
524
+ pruneCommitLogsBefore(ts: bigint): Promise<bigint>;
525
+ /**
526
+ * Oldest `ts` still present in commit_logs (i.e. the retention watermark
527
+ * after the last prune), or `null` when the table is empty. A cache entry
528
+ * whose `lastSnapshotTs` is below it can no longer be freshness-checked via
529
+ * {@link getCommitLogsBetweenTs} (the logs it would need were pruned), so the
530
+ * one-shot/register cache paths recompute instead of trusting it.
531
+ */
532
+ getMinCommitLogTs(): Promise<bigint | null>;
533
+ /**
534
+ * Half-open range scan: ts >= beginTs AND ts < endTs. Used by the
535
+ * subscription-recovery path to replay logs in a specific time window.
536
+ */
537
+ getCommitLogsBetweenTs(beginTs: bigint, endTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
538
+ /**
539
+ * Existence-only freshness probe for point reads: does any commit in the
540
+ * half-open window `[beginTs, endTs)` touch one of the exact `(tableId, id)`
541
+ * pairs in `points`? Returns as soon as one match is found.
542
+ *
543
+ * Point-read overlap is a pure key match (`checkPointReadOverlap`), so it can
544
+ * be answered entirely in SQL with a `(table_id, id)` tuple `IN` against the
545
+ * `commit_logs_by_table_and_id (table_id, id, ts)` index — no row `data`
546
+ * blobs fetched, no JSON parsed. This is the precise-filtering path used by
547
+ * {@link CacheFreshness} for tables whose read set is point-reads-only; tables
548
+ * that also carry a range read still go through {@link getCommitLogsBetweenTs}
549
+ * because their predicates must be evaluated in-app. `points` empty → `false`.
550
+ */
551
+ hasCommitForPoints(beginTs: bigint, endTs: bigint, points: {
552
+ tableId: Uint8Array;
553
+ id: Uint8Array;
554
+ }[]): Promise<boolean>;
555
+ /**
556
+ * Conflict-check scan for OCC: ts >= sinceTs AND ts <> excludeTs. The
557
+ * exclude is our own commitTs so we don't conflict with ourselves; the
558
+ * lack of an upper bound is intentional, so a concurrent peer that
559
+ * happens to have a higher commitTs but committed before us is still
560
+ * visible. (MVCC keeps in-flight peers invisible until they commit.)
561
+ */
562
+ getCommitLogsSinceTs(sinceTs: bigint, excludeTs: bigint, tableIds: Uint8Array[]): Promise<CommitLogEntry[]>;
563
+ /**
564
+ * For each `update`/`delete` entry, attach `prevData` (consumed by the
565
+ * invalidator) and `expectedCommitTs` (the CAS fence).
566
+ *
567
+ * `expectedCommitTs` is preferentially copied from a prior point-read of
568
+ * the same row in `readSet` — that's the value the handler's logic
569
+ * actually depended on, so the CAS check enforces beginTs-level isolation
570
+ * for read-then-update patterns. If no prior read exists ("blind"
571
+ * write), we fall back to the value observed in this batch fetch (weak
572
+ * OCC, sufficient for writes that don't depend on prior state).
573
+ *
574
+ * `prevData` always comes from this batch fetch (SELECT * per table) so
575
+ * the invalidator has the full row regardless of which columns the
576
+ * handler's read selected.
577
+ *
578
+ * If the target row no longer exists at fetch time, `expectedCommitTs`
579
+ * is left undefined and the per-row CAS will match nothing — surfaced
580
+ * as OccConflictError.
581
+ */
582
+ attachPrevDataToWriteSet(writeSet: WriteEntry[], readSet: ReadEntry[]): Promise<void>;
583
+ }
584
+ interface TxDatabase extends Database {
585
+ begin(): Promise<void>;
586
+ commit(): Promise<void>;
587
+ rollback(): Promise<void>;
588
+ release(): void;
589
+ }
590
+ interface JsonOpOptions$1 {
591
+ /**
592
+ * When true, the bound `value` parameter is treated as already prepared
593
+ * for the underlying SQL (e.g. a literal JSON path string for
594
+ * jsonHasKey, a JSON-encoded literal for the contains family). When
595
+ * false/omitted, the value was prepared client-side from a JS value.
596
+ */
597
+ raw?: boolean;
598
+ /**
599
+ * 1-based positional index of an extra bound parameter holding a
600
+ * jsonpath that scopes the contains-family check to a sub-document of
601
+ * the target column. When omitted, the check runs against the whole
602
+ * column value.
603
+ */
604
+ pathIndex?: number;
605
+ /**
606
+ * jsonHasKey only: when set, multiple path parameters are bound starting
607
+ * at `paramIndex`, and the predicate evaluates whether any (`one`) or
608
+ * every (`all`) path exists in the column.
609
+ */
610
+ mode?: "one" | "all";
611
+ /** Number of bound path parameters in multi-path mode. */
612
+ pathCount?: number;
613
+ }
614
+ interface SqlBuilder {
615
+ placeholder(index: number): string;
616
+ like(col: string, paramIndex: number): string;
617
+ ilike(col: string, paramIndex: number): string;
618
+ icontains(col: string, paramIndex: number): string;
619
+ /** PG @> ; MySQL JSON_CONTAINS */
620
+ jsonContains(col: string, paramIndex: number, opts?: JsonOpOptions$1): string;
621
+ /** PG <@ ; MySQL JSON_CONTAINS(candidate, target) */
622
+ jsonContainedBy(col: string, paramIndex: number, opts?: JsonOpOptions$1): string;
623
+ /**
624
+ * Key/path existence. With `opts.raw === true`, the bound param is a JSON
625
+ * path expression (PG `jsonb_path_exists`, MySQL `JSON_CONTAINS_PATH`).
626
+ * Otherwise the bound param is a literal top-level key (PG `?`, MySQL
627
+ * `JSON_CONTAINS_PATH($."<key>")` with server-side quoting).
628
+ * With `opts.pathCount` set, emits the multi-path form keyed by `mode`.
629
+ */
630
+ jsonHasKey(col: string, paramIndex: number, opts?: JsonOpOptions$1): string;
631
+ /** Array membership: target array contains the given element. */
632
+ jsonArrayContains(col: string, paramIndex: number, opts?: JsonOpOptions$1): string;
633
+ }
634
+ declare class LazyCommitTsParam {
635
+ value: unknown;
636
+ constructor(value: unknown);
637
+ toPostgres(prepareValue: (value: any) => any): any;
638
+ toString(): any;
639
+ validate(): void;
640
+ }
641
+ //#endregion
642
+ //#region src/db/table-id.d.ts
643
+ /**
644
+ * Canonical table identifier: a fixed **16-byte** digest of the table name
645
+ * (UUID v3, which is MD5-based). A `tableId` is fully derived from the table
646
+ * name, so it is never stored redundantly — the query-cache `readSet` persists
647
+ * only `table` (the name) and reconstructs the bytes on read via
648
+ * {@link tableIdOf}. The physical `commit_logs.table_id` column (MySQL
649
+ * `BINARY(16)`, Postgres `BYTEA`) and its indexes hold these same bytes.
650
+ *
651
+ * A fixed 16 bytes (rather than the raw UTF-8 of the name) is required for
652
+ * MySQL: `BINARY(16)` would overflow on a table name longer than 16 bytes and
653
+ * zero-pad shorter ones (breaking byte-exact id matching). MD5 sidesteps both.
654
+ * Only used for equality (never decoded back to a name), so a non-cryptographic
655
+ * digest is fine. Browser-safe and synchronous (via the `uuid` package), which
656
+ * matters because this module is reachable from the client bundle.
657
+ */
658
+ declare function tableNameToId(tableName: string): Uint8Array;
659
+ //#endregion
660
+ //#region src/db/schema.d.ts
661
+ interface ColumnCodec<TData = unknown, TDriver = unknown> {
662
+ encode?: (value: TData) => TDriver;
663
+ decode?: (value: TDriver) => TData;
664
+ }
665
+ type SchemaCodecField<TSchema extends ZodRawShape, K extends PropertyKey> = K extends keyof TSchema ? TSchema[K] extends z$1.ZodTypeAny ? z$1.infer<TSchema[K]> : unknown : K extends keyof BaseSchema ? BaseSchema[K] extends z$1.ZodTypeAny ? z$1.infer<BaseSchema[K]> : unknown : unknown;
666
+ type SchemaCodecs<TSchema extends ZodRawShape> = Partial<{ [K in keyof (TSchema & BaseSchema)]: ColumnCodec<SchemaCodecField<TSchema, K>, any> }>;
667
+ interface SchemaColumnsOptions<TSchema extends ZodRawShape = ZodRawShape> {
668
+ codecs?: SchemaCodecs<TSchema>;
669
+ }
670
+ interface SchemaColumnMapping {
671
+ [key: string]: string;
672
+ }
673
+ interface DeclarativeIndex {
674
+ name: string;
675
+ columns: string[];
676
+ unique?: boolean;
677
+ type?: "btree" | "hash" | "gin" | "gist" | "spgist" | "brin";
678
+ where?: string;
679
+ using?: string;
680
+ options?: string;
681
+ tablespace?: string;
682
+ }
683
+ type IndexDefinition = string | DeclarativeIndex;
684
+ interface DefineSchemaConfig<TSchema extends ZodRawShape> {
685
+ name: string;
686
+ schema: TSchema;
687
+ options?: SchemaColumnsOptions<TSchema>;
688
+ columns?: SchemaColumnMapping;
689
+ indexes?: IndexDefinition[];
690
+ }
691
+ type CodecDataType<TCodec, TFallback> = [TCodec] extends [undefined] ? TFallback : TCodec extends {
692
+ decode: (...args: any[]) => infer TDecoded;
693
+ } ? TDecoded : TCodec extends ColumnCodec<infer TData, unknown> ? TData : TFallback;
694
+ type ZodOutput<TZod> = [TZod] extends [undefined] ? unknown : TZod extends z$1.ZodTypeAny ? z$1.infer<TZod> : unknown;
695
+ type ComputedDataType<TCodec, TZod> = CodecDataType<TCodec, ZodOutput<TZod>>;
696
+ type ComputedCodec<TData, TDriver> = ColumnCodec<TData, TDriver>;
697
+ type OverrideField<TObj, TKey extends PropertyKey, TValue> = Omit<TObj, TKey> & { [K in TKey]: TValue };
698
+ interface ComputedFieldConfig<TField extends string, TDecoded = unknown, TDriver = unknown, TZodType extends z$1.ZodTypeAny | undefined = undefined> {
699
+ field: TField;
700
+ sql: string;
701
+ alias?: string;
702
+ type?: TZodType;
703
+ codec?: {
704
+ decode: (value: TDriver) => TDecoded;
705
+ encode?: (value: TDecoded) => TDriver;
706
+ };
707
+ }
708
+ type ComputedField = {
709
+ field: string;
710
+ sql: string;
711
+ alias: string;
712
+ codec?: ColumnCodec<any, any>;
713
+ };
714
+ declare function defineComputedField<TField extends string, TDecoded = unknown, TDriver = unknown, TZodType extends z$1.ZodTypeAny | undefined = undefined>(config: ComputedFieldConfig<TField, TDecoded, TDriver, TZodType>): ComputedFieldConfig<TField, TDecoded, TDriver, TZodType>;
715
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
716
+ type ApplySchemaCodecs<TBase, TCodecs> = { [K in keyof TBase]: K extends keyof TCodecs ? CodecDataType<TCodecs[K], TBase[K]> : TBase[K] };
717
+ type ResolveSchemaType<TSchema extends ZodRawShape, TOptions extends SchemaColumnsOptions<TSchema>> = TOptions extends {
718
+ codecs: infer TCodecs;
719
+ } ? Prettify<ApplySchemaCodecs<z$1.infer<z$1.ZodObject<TSchema & BaseSchema>>, TCodecs>> : Prettify<z$1.infer<z$1.ZodObject<TSchema & BaseSchema>>>;
720
+ type IsOptionalField<T> = T extends z$1.ZodOptional<any> ? true : T extends z$1.ZodNullable<any> ? true : T extends z$1.ZodDefault<any> ? true : false;
721
+ type OptionalKeys<TZod extends ZodRawShape> = { [K in keyof TZod]: IsOptionalField<TZod[K]> extends true ? K : never }[keyof TZod];
722
+ type RequiredKeys<TZod extends ZodRawShape> = { [K in keyof TZod]: IsOptionalField<TZod[K]> extends true ? never : K }[keyof TZod];
723
+ type BaseSchema = {
724
+ id: z$1.ZodString;
725
+ commitTs: z$1.ZodCoercedBigInt;
726
+ };
727
+ declare const schemaRegistry: Map<string, SchemaDefinition<string, any, any>>;
728
+ declare let shouldTrackSchema: boolean;
729
+ declare function trackSchema(): void;
730
+ declare function defineSchema<TSchema extends ZodRawShape, TName extends string, TOptions extends SchemaColumnsOptions<TSchema> = SchemaColumnsOptions<TSchema>>(config: DefineSchemaConfig<TSchema> & {
731
+ name: TName;
732
+ options?: TOptions;
733
+ }): SchemaDefinition<TName, Prettify<TSchema & BaseSchema>, ResolveSchemaType<TSchema, TOptions>>;
734
+ interface StoredSchemaColumnsOptions {
735
+ codecs?: Record<string, ColumnCodec<any, any>>;
736
+ }
737
+ interface SchemaDefinition<TTable extends string, TZod extends ZodRawShape, TData = z$1.infer<z$1.ZodObject<TZod>>> {
738
+ tableId: Uint8Array;
739
+ table: TTable;
740
+ schema: z$1.ZodObject<TZod>;
741
+ columnsOptions: StoredSchemaColumnsOptions;
742
+ columns: Record<string, string>;
743
+ indexes: IndexDefinition[];
744
+ _dataType?: TData;
745
+ }
746
+ type InferSchema<T extends SchemaDefinition<string, ZodRawShape, any>> = T extends SchemaDefinition<string, ZodRawShape, infer TData> ? TData : never;
747
+ type InsertData<T extends SchemaDefinition<string, ZodRawShape, any>> = T extends SchemaDefinition<string, infer TZod, infer TData> ? { [K in RequiredKeys<TZod> as K extends "id" | "commitTs" ? never : K]: Extract<K, string> extends keyof TData ? TData[Extract<K, string>] : never } & { [K in OptionalKeys<TZod> as K extends "id" | "commitTs" ? never : K]?: Extract<K, string> extends keyof TData ? TData[Extract<K, string>] : never } : never;
748
+ interface Model {
749
+ table: string;
750
+ tableId: Uint8Array;
751
+ columns: Record<string, string>;
752
+ reverseColumns: Record<string, string>;
753
+ types: Record<string, string>;
754
+ codecs: Record<string, ColumnCodec<any, any>>;
755
+ }
756
+ type MaybePromise<T> = T | Promise<T>;
757
+ type ReturnLiveQuery<TLiveQueryFn extends (...args: any[]) => MaybePromise<LiveQueryHandle<any>>> = Awaited<ReturnType<TLiveQueryFn>> extends LiveQueryHandle<infer T> ? T : never;
758
+ type ReturnQuery<TQueryFn extends (...args: any[]) => any> = Awaited<ReturnType<TQueryFn>>;
759
+ type QueryArgs<TQueryFn extends (...args: any[]) => any> = Parameters<TQueryFn>[0];
760
+ type MutationArgs<TMutationFn extends (...args: any[]) => any> = Parameters<TMutationFn>[0];
761
+ type ActionArgs<TActionFn extends (...args: any[]) => any> = Parameters<TActionFn>[0];
762
+ //#endregion
763
+ //#region src/db/query.d.ts
764
+ type FieldValue<S extends SchemaDefinition<string, ZodRawShape>, K> = K extends keyof InferSchema<S> ? InferSchema<S>[K] : never;
765
+ type OrderableValue = number | bigint | string | Date;
766
+ type StringFieldKeys<S extends SchemaDefinition<string, ZodRawShape>> = { [K in keyof InferSchema<S>]: NonNullable<InferSchema<S>[K]> extends string ? K : never }[keyof InferSchema<S>];
767
+ type OrderableFieldKeys<S extends SchemaDefinition<string, ZodRawShape>> = { [K in keyof InferSchema<S>]: NonNullable<InferSchema<S>[K]> extends OrderableValue ? K : never }[keyof InferSchema<S>];
768
+ type JsonFieldKeys<S extends SchemaDefinition<string, ZodRawShape>> = { [K in keyof InferSchema<S>]: NonNullable<InferSchema<S>[K]> extends OrderableValue ? never : NonNullable<InferSchema<S>[K]> extends boolean ? never : NonNullable<InferSchema<S>[K]> extends (object | unknown[]) ? K : unknown extends NonNullable<InferSchema<S>[K]> ? K : never }[keyof InferSchema<S>];
769
+ interface JsonOpOptions {
770
+ /**
771
+ * Skip client-side preparation of the value (no JSON-stringify, no key
772
+ * escaping). The caller is responsible for the exact form the dialect
773
+ * expects: a JSON path string for jsonHasKey, a JSON-encoded string for
774
+ * the contains family.
775
+ */
776
+ raw?: true;
777
+ }
778
+ interface JsonContainsOptions extends JsonOpOptions {
779
+ /**
780
+ * Sub-path into the target JSON to scope the check to. `string` is a
781
+ * single literal top-level key; `string[]` is a nested literal-key path
782
+ * compiled to `$."a"."b"`. Mutually exclusive with `pathRaw`.
783
+ */
784
+ path?: string | string[];
785
+ /**
786
+ * Raw jsonpath expression used verbatim by the dialect (PG `jsonpath`,
787
+ * MySQL JSON path). Mutually exclusive with `path`.
788
+ */
789
+ pathRaw?: string;
790
+ }
791
+ interface JsonHasKeyMultiOptions extends JsonOpOptions {
792
+ /** Required for the multi-path overload — chooses any vs every. */
793
+ mode: "one" | "all";
794
+ }
795
+ declare class QueryBuilder<S extends SchemaDefinition<string, ZodRawShape>> {
796
+ protected ctx: TxContext;
797
+ protected model: Model;
798
+ constructor(ctx: TxContext, model: Model);
799
+ protected getColumnName(key: string): string;
800
+ select(): SelectQueryBuilder<S, keyof InferSchema<S>>;
801
+ select<K extends keyof InferSchema<S>>(...columns: K[]): SelectQueryBuilder<S, K>;
802
+ }
803
+ type IdAndCommitTs = {
804
+ id: string;
805
+ commitTs: bigint;
806
+ };
807
+ type SelectRow<S extends SchemaDefinition<string, ZodRawShape>, K extends keyof InferSchema<S>, C extends Record<string, unknown>> = Prettify<Pick<InferSchema<S>, Extract<K | "id" | "commitTs", keyof InferSchema<S>>> & C>;
808
+ type OrderDirection = "ASC" | "DESC";
809
+ interface OrderByOptions {
810
+ direction?: OrderDirection;
811
+ nulls?: "first" | "last";
812
+ collate?: string;
813
+ }
814
+ /**
815
+ * Cursor-based pagination using a timestamp column and a unique ID column.
816
+ *
817
+ * Generates a stable cursor predicate:
818
+ *
819
+ * DESC (default):
820
+ * ```sql
821
+ * WHERE (timeCol < ? OR (timeCol = ? AND idCol < ?))
822
+ * ORDER BY timeCol DESC, idCol DESC
823
+ * ```
824
+ *
825
+ * ASC:
826
+ * ```sql
827
+ * WHERE (timeCol > ? OR (timeCol = ? AND idCol > ?))
828
+ * ORDER BY timeCol ASC, idCol ASC
829
+ * ```
830
+ */
831
+ interface PaginationClause<S extends SchemaDefinition<string, ZodRawShape>, Time extends OrderableFieldKeys<S>, Id extends OrderableFieldKeys<S>> {
832
+ /** Timestamp column used for cursor pagination. */
833
+ timeCol: Time;
834
+ /**
835
+ * Unique tie-breaker column.
836
+ *
837
+ * @default "id"
838
+ */
839
+ idCol?: Id;
840
+ /**
841
+ * Pagination direction.
842
+ *
843
+ * - `"desc"` (default): Newest → oldest.
844
+ * - `"asc"`: Oldest → newest.
845
+ *
846
+ * @default "desc"
847
+ */
848
+ direction?: OrderDirection;
849
+ /**
850
+ * Maximum number of rows to return.
851
+ */
852
+ limit?: number;
853
+ /**
854
+ * Cursor returned from the previous page.
855
+ *
856
+ * Omit or set to `null` to fetch the first page.
857
+ */
858
+ cursor?: {
859
+ time: FieldValue<S, Time>;
860
+ id: FieldValue<S, Id>;
861
+ } | null;
862
+ }
863
+ declare class SelectQueryBuilder<S extends SchemaDefinition<string, ZodRawShape>, K extends keyof InferSchema<S> = never, C extends Record<string, unknown> = {}> {
864
+ private ctx;
865
+ private model;
866
+ private filters;
867
+ private paginationClause;
868
+ private orderByClause;
869
+ private limitVal;
870
+ private offsetVal;
871
+ private selectedProps;
872
+ private computedFields;
873
+ private commentStr;
874
+ constructor(ctx: TxContext, model: Model, filters?: ((fb: FilterBuilder<S>) => void)[], orderByClause?: string[] | null, limitVal?: number | null, offsetVal?: number | null, selectedProps?: (keyof InferSchema<S>)[], computedFields?: ComputedField[], commentStr?: string);
875
+ private getColumnName;
876
+ private getPropertyName;
877
+ private mapRowToSchema;
878
+ where(filterFn: (fb: FilterBuilder<S>) => void): SelectQueryBuilder<S, K, C>;
879
+ paginate<Time extends OrderableFieldKeys<S>, Id extends OrderableFieldKeys<S>>(clause: PaginationClause<S, Time, Id>): SelectQueryBuilder<S, K, C>;
880
+ orderBy(column: keyof InferSchema<S> | keyof C, direction?: OrderDirection): SelectQueryBuilder<S, K, C>;
881
+ orderBy(column: keyof InferSchema<S> | keyof C, options?: OrderByOptions): SelectQueryBuilder<S, K, C>;
882
+ private buildOrderBySql;
883
+ orderByRaw(sql: string): SelectQueryBuilder<S, K, C>;
884
+ limit(n: number): SelectQueryBuilder<S, K, C>;
885
+ offset(n: number): SelectQueryBuilder<S, K, C>;
886
+ computed<TField extends string, TZodType extends z$1.ZodTypeAny | undefined = undefined, TDecode extends (value: any) => any = (value: unknown) => unknown>(config: ComputedFieldConfig<TField, ReturnType<TDecode>, Parameters<TDecode>[0], TZodType> & {
887
+ codec: {
888
+ decode: TDecode;
889
+ encode?: (value: ReturnType<TDecode>) => Parameters<TDecode>[0];
890
+ };
891
+ }): SelectQueryBuilder<S, K | TField, OverrideField<C, TField, ComputedDataType<ComputedCodec<ReturnType<TDecode>, Parameters<TDecode>[0]>, TZodType>>>;
892
+ computed<TField extends string, TZodType extends z$1.ZodTypeAny | undefined = undefined>(config: ComputedFieldConfig<TField, unknown, unknown, TZodType> & {
893
+ codec?: undefined;
894
+ }): SelectQueryBuilder<S, K | TField, OverrideField<C, TField, ComputedDataType<undefined, TZodType>>>;
895
+ comment(input: string | Record<string, string>): SelectQueryBuilder<S, K, C>;
896
+ first(): Promise<SelectRow<S, K, C> | null>;
897
+ exists(): Promise<boolean>;
898
+ private static defaultCountType;
899
+ count(): Promise<number>;
900
+ count<T extends z$1.ZodType>(parser: T): Promise<z$1.output<T>>;
901
+ find(id: string): Promise<SelectRow<S, K, C> | null>;
902
+ get(): Promise<SelectRow<S, K, C>[]>;
903
+ private buildPredicate;
904
+ }
905
+ declare class FilterBuilder<S extends SchemaDefinition<string, ZodRawShape>> {
906
+ private columns;
907
+ private codecs;
908
+ predicates: Predicate[];
909
+ constructor(columns: Record<string, string>, codecs: Record<string, ColumnCodec<unknown, unknown>>);
910
+ private add;
911
+ private addJsonContains;
912
+ private getColumnName;
913
+ private encode;
914
+ private encodeJson;
915
+ eq<K extends keyof InferSchema<S>>(key: K, value: FieldValue<S, K>): FilterBuilder<S>;
916
+ neq<K extends keyof InferSchema<S>>(key: K, value: FieldValue<S, K>): FilterBuilder<S>;
917
+ gt<K extends OrderableFieldKeys<S>>(key: K, value: FieldValue<S, K>): FilterBuilder<S>;
918
+ gte<K extends OrderableFieldKeys<S>>(key: K, value: FieldValue<S, K>): FilterBuilder<S>;
919
+ lt<K extends OrderableFieldKeys<S>>(key: K, value: FieldValue<S, K>): FilterBuilder<S>;
920
+ lte<K extends OrderableFieldKeys<S>>(key: K, value: FieldValue<S, K>): FilterBuilder<S>;
921
+ like<K extends StringFieldKeys<S>>(key: K, pattern: string): FilterBuilder<S>;
922
+ ilike<K extends StringFieldKeys<S>>(key: K, pattern: string): FilterBuilder<S>;
923
+ contains<K extends StringFieldKeys<S>>(key: K, value: string): FilterBuilder<S>;
924
+ icontains<K extends StringFieldKeys<S>>(key: K, value: string): FilterBuilder<S>;
925
+ /**
926
+ * JSON containment. Targets a JSON/JSONB column and asserts the document
927
+ * contains the given candidate (object-key subset for objects,
928
+ * element-subset for arrays — see dialect-specific docs for edge cases).
929
+ * Pass `{ raw: true }` if `value` is already a JSON-encoded string.
930
+ * Pass `{ path: ... }` to scope the check to a sub-document of the
931
+ * target (jsonb_path_query_first on PG, JSON_CONTAINS path arg on MySQL).
932
+ */
933
+ jsonContains<K extends JsonFieldKeys<S>>(key: K, value: unknown, opts?: JsonContainsOptions): FilterBuilder<S>;
934
+ /** Inverse of {@link jsonContains}: column is contained in the given value. */
935
+ jsonContainedBy<K extends JsonFieldKeys<S>>(key: K, value: unknown, opts?: JsonContainsOptions): FilterBuilder<S>;
936
+ /**
937
+ * Key/path existence check on a JSON column.
938
+ *
939
+ * - String form (top-level key): `jsonHasKey("meta", "color")`. On PG
940
+ * also matches when the column is a string array and `value` is one of
941
+ * its elements (PG `?` semantics); MySQL stays strict to object keys.
942
+ * - Array form (nested path): `jsonHasKey("meta", ["a", "b"])` compiles
943
+ * to a path expression `$."a"."b"` on both dialects.
944
+ * - Raw form: `jsonHasKey("meta", "$.foo[*]", { raw: true })` passes the
945
+ * string through as a dialect path expression (PG `jsonb_path_exists`
946
+ * jsonpath, MySQL `JSON_CONTAINS_PATH`). Caller owns the syntax.
947
+ * - Multi-path form: `jsonHasKey("meta", [["a","b"], "color"], { mode: "all" })`
948
+ * compiles each entry to a jsonpath and emits PG OR/AND of
949
+ * `jsonb_path_exists` or MySQL `JSON_CONTAINS_PATH('all', ...)`.
950
+ */
951
+ jsonHasKey<K extends JsonFieldKeys<S>>(key: K, value: string): FilterBuilder<S>;
952
+ jsonHasKey<K extends JsonFieldKeys<S>>(key: K, value: string[]): FilterBuilder<S>;
953
+ jsonHasKey<K extends JsonFieldKeys<S>>(key: K, value: string, opts: {
954
+ raw: true;
955
+ }): FilterBuilder<S>;
956
+ jsonHasKey<K extends JsonFieldKeys<S>>(key: K, paths: (string | string[])[], opts: JsonHasKeyMultiOptions): FilterBuilder<S>;
957
+ jsonHasKey<K extends JsonFieldKeys<S>>(key: K, paths: string[], opts: JsonHasKeyMultiOptions & {
958
+ raw: true;
959
+ }): FilterBuilder<S>;
960
+ /**
961
+ * Array element containment: target column is a JSON array; the given
962
+ * `value` (any JSON-encodable type) must appear as one of its elements.
963
+ * Pass `{ raw: true }` if `value` is already a JSON-encoded string.
964
+ * Pass `{ path: ... }` to scope the check to a sub-array of the column.
965
+ */
966
+ jsonArrayContains<K extends JsonFieldKeys<S>>(key: K, value: unknown, opts?: JsonContainsOptions): FilterBuilder<S>;
967
+ between<K extends OrderableFieldKeys<S>>(key: K, lo: FieldValue<S, K>, hi: FieldValue<S, K>): FilterBuilder<S>;
968
+ /**
969
+ * Set membership: `key` equals any of `values` (SQL `IN`). Each value is
970
+ * codec-encoded like `eq`. An empty `values` matches no rows. Bound as one
971
+ * parameter per element, so keep the list within the driver's parameter
972
+ * limit (chunk very large sets at the call site).
973
+ */
974
+ in<K extends keyof InferSchema<S>>(key: K, values: readonly FieldValue<S, K>[]): FilterBuilder<S>;
975
+ isNull<K extends keyof InferSchema<S>>(key: K): FilterBuilder<S>;
976
+ notNull<K extends keyof InferSchema<S>>(key: K): FilterBuilder<S>;
977
+ /**
978
+ * Compose an OR clause. Each callback fills a fresh sub-FilterBuilder
979
+ * with predicates that are AND-ed together within that branch; the
980
+ * branches themselves are OR-ed. Example:
981
+ * f.or([
982
+ * b => b.eq("tag", "a"),
983
+ * b => b.eq("tag", "b").gt("qty", 3), // (tag=b AND qty>3)
984
+ * ])
985
+ * produces (tag=a) OR (tag=b AND qty>3).
986
+ */
987
+ or(branches: ((fb: FilterBuilder<S>) => void)[]): FilterBuilder<S>;
988
+ }
989
+ declare function buildPredicateSql(predicate: Predicate, params: unknown[], sql: SqlBuilder): string;
990
+ declare function matchesPredicate(row: Record<string, unknown>, predicate: Predicate): boolean;
991
+ declare function jsonContains(target: unknown, candidate: unknown): boolean;
992
+ declare function jsonPathExtract(val: unknown, path: string): unknown;
993
+ declare function jsonPathExists(val: unknown, path: string): boolean;
994
+ //#endregion
995
+ //#region src/db/context.d.ts
996
+ declare class TxContext {
997
+ readonly beginTs: bigint;
998
+ readonly db: Database;
999
+ protected readSet: ReadEntry[];
1000
+ protected writeSet: WriteEntry[];
1001
+ private models;
1002
+ protected getOrCreateModel(schema: SchemaDefinition<string, ZodRawShape>): Model;
1003
+ constructor(db: Database, beginTs: bigint);
1004
+ internalGetReadSet(): ReadEntry[];
1005
+ internalGetWriteSet(): WriteEntry[];
1006
+ /**
1007
+ * Merge a parent procedure's reads into this context's readSet. Used when a
1008
+ * `runMutation` sub-transaction inherits the reads of the procedure that
1009
+ * invoked it, so the sub-tx's OCC validation also fences on those rows.
1010
+ * Entries are shallow-cloned so the two readSets don't alias.
1011
+ */
1012
+ appendInternalReadSet(parentEntries: ReadEntry[]): void;
1013
+ protected findPendingWrite(table: string, id: string): WriteEntry | undefined;
1014
+ protected findPendingInsert(table: string, id: string): WriteEntry | undefined;
1015
+ protected encodeWithCodec(model: Model, property: string, value: unknown): unknown;
1016
+ }
1017
+ declare class DbReader extends TxContext {
1018
+ query<S extends SchemaDefinition<string, ZodRawShape>>(schema: S): QueryBuilder<S>;
1019
+ }
1020
+ declare class DbWriter extends DbReader {
1021
+ insert<S extends SchemaDefinition<string, ZodRawShape>, ID extends string>(schema: S, id: ID, data: InsertData<S>): Promise<void>;
1022
+ update<S extends SchemaDefinition<string, ZodRawShape>, ID extends string>(schema: S, id: ID, data: Partial<Omit<InferSchema<S>, "id" | "commitTs">>): Promise<void>;
1023
+ delete<S extends SchemaDefinition<string, ZodRawShape>, ID extends string>(schema: S, id: ID): Promise<void>;
1024
+ }
1025
+ //#endregion
1026
+ //#region src/db/query_definition.d.ts
1027
+ /**
1028
+ * A named, typed query definition produced by defineQuery().
1029
+ * Carries the query function at runtime and the name/params/result types
1030
+ * at compile time — making it the single source of truth for both the
1031
+ * server-side registry and the client-side RPC.
1032
+ */
1033
+ interface QueryDefinition<TName extends string, TParams, TResult> {
1034
+ readonly _type: "QueryDefinition";
1035
+ readonly name: TName;
1036
+ readonly fn: (ctx: DbReader, params: TParams) => Promise<TResult>;
1037
+ }
1038
+ type AnyQueryDef = QueryDefinition<string, any, any>;
1039
+ /** Extract the params type from a QueryDefinition. */
1040
+ type ParamsOf<D extends AnyQueryDef> = D extends QueryDefinition<any, infer P, any> ? P : never;
1041
+ /** Extract the result type from a QueryDefinition. */
1042
+ type ResultOf<D extends AnyQueryDef> = D extends QueryDefinition<any, any, infer R> ? R : never;
1043
+ /**
1044
+ * Convert a readonly tuple of QueryDefinitions into a Record keyed by their
1045
+ * name literals. This is what makes ClientRpc fully type-safe: each key in
1046
+ * the map carries its own TParams and TResult rather than collapsing to `any`.
1047
+ *
1048
+ * Example:
1049
+ * const defs = [projectBoardQuery, teamMembersQuery] as const;
1050
+ * type Map = DefsToMap<typeof defs>;
1051
+ * // → { projectBoard: typeof projectBoardQuery; teamMembers: typeof teamMembersQuery }
1052
+ */
1053
+ type DefsToMap<T extends readonly AnyQueryDef[]> = { [D in T[number] as D["name"]]: D };
1054
+ /** For test teardown only — clears the global map between suites. */
1055
+ declare function _resetGlobalDefs(): void;
1056
+ /**
1057
+ * Create a named, typed query definition.
1058
+ *
1059
+ * The definition is automatically registered in a module-level global so
1060
+ * the server can call registry.defineAll() instead of listing every query
1061
+ * explicitly. On the client, pass the definition to createClientRpc() to
1062
+ * get a fully typed subscribe() call.
1063
+ *
1064
+ * Usage:
1065
+ * export const projectBoardQuery = defineQuery(
1066
+ * "projectBoard",
1067
+ * async (ctx, params: { projectId: string }) => {
1068
+ * return ctx.query(Tasks)
1069
+ * .select()
1070
+ * .where(f => f.eq("projectId", params.projectId))
1071
+ * .get();
1072
+ * }
1073
+ * );
1074
+ */
1075
+ declare function defineQuery<TName extends string, TParams, TResult>(name: TName, fn: (ctx: DbReader, params: TParams) => Promise<TResult>): QueryDefinition<TName, TParams, TResult>;
1076
+ //#endregion
1077
+ //#region src/db/realtime_db.d.ts
1078
+ declare class SupaliveDb {
1079
+ readonly impl: Database;
1080
+ constructor(impl: Database);
1081
+ static create(config: {
1082
+ db: Database;
1083
+ }): SupaliveDb;
1084
+ protected onAfterCommit?: (writeSet: WriteEntry[], commitTs: CommitTs) => void;
1085
+ /**
1086
+ * Register a hook fired once after every successful `mutation()` commit
1087
+ * (never on an OCC conflict/rollback), with the committed writeSet and its
1088
+ * commitTs. The server uses this to drive subscription invalidation for ALL
1089
+ * mutation sources — client WS calls, actions, jobs, and the internal caller —
1090
+ * so a server-side write pushes live updates just like a client write does.
1091
+ * Non-server consumers (migration tooling, tests) leave it unset (no-op).
1092
+ */
1093
+ setOnAfterCommit(cb: (writeSet: WriteEntry[], commitTs: CommitTs) => void): void;
1094
+ query<T>(fn: (ctx: DbReader) => Promise<T>): Promise<T>;
1095
+ /**
1096
+ * Compute a query once at the latest snapshot, returning the result together
1097
+ * with the snapshot `ts` and the tracked `readSet`. This is a plain one-shot
1098
+ * evaluation — it registers NO live subscription; the `readSet`/`ts` are
1099
+ * returned purely so the caller (e.g. the one-shot query cache) can store
1100
+ * freshness metadata. Use this for cached one-shot query calls (WS `call`,
1101
+ * HTTP RPC). `liveQuery` is the same computation under the subscription path's
1102
+ * name and simply delegates here.
1103
+ */
1104
+ queryInternal<T>(fn: (ctx: DbReader) => Promise<T>): Promise<LiveResult<T>>;
1105
+ liveQuery<T>(fn: (ctx: DbReader) => Promise<T>): Promise<LiveResult<T>>;
1106
+ mutation<T>(fn: (ctx: DbWriter) => Promise<T>, retryPolicy?: RetryPolicy): Promise<MutationResult<T>>;
1107
+ }
1108
+ declare const sleep: (ms: number) => Promise<void>;
1109
+ //#endregion
1110
+ //#region src/jobs/scheduler.d.ts
1111
+ /** A recurring job to keep synced on the scheduler side. */
1112
+ interface ScheduledJobDef {
1113
+ /** Job procedure name (also the last path segment of its endpoint). */
1114
+ name: string;
1115
+ /** Cron expression, e.g. `"0 3 * * *"`. */
1116
+ cron: string;
1117
+ }
1118
+ /** Options for a precise, one-shot job run. */
1119
+ interface EnqueueOptions {
1120
+ /** Run after this many seconds from now. */
1121
+ delaySeconds?: number;
1122
+ /** Run at this absolute time. Overrides `delaySeconds`. */
1123
+ runAt?: Date;
1124
+ /**
1125
+ * Idempotency key. If two enqueues share the same id within the provider's
1126
+ * dedup window, only the first is delivered. Use it to make "schedule the
1127
+ * expiry of X" safe to call more than once.
1128
+ */
1129
+ dedupeId?: string;
1130
+ }
1131
+ /** Handle returned by {@link JobScheduler.enqueue}; pass its `id` to `cancel`. */
1132
+ interface ScheduleHandle {
1133
+ id: string;
1134
+ }
1135
+ /** The pieces of an inbound webhook the scheduler needs to authenticate it. */
1136
+ interface IncomingJobRequest {
1137
+ /** Job name parsed from the request path. */
1138
+ name: string;
1139
+ /** Raw (unparsed) request body — signatures are computed over these bytes. */
1140
+ rawBody: string;
1141
+ /** Request headers, keys lowercased. */
1142
+ headers: Record<string, string | undefined>;
1143
+ /** Full request URL the webhook was delivered to. */
1144
+ url: string;
1145
+ }
1146
+ /**
1147
+ * Pluggable scheduler. The server owns exactly one instance and uses it for
1148
+ * both directions:
1149
+ * • inbound — `verify` authenticates a webhook before the job runs.
1150
+ * • outbound — `syncSchedules` (recurring, at startup) and `enqueue`/`cancel`
1151
+ * (precise one-shots, at runtime) drive the provider.
1152
+ *
1153
+ * Both dev and production implementations POST to the same HTTP job endpoint,
1154
+ * so the server's dispatch path is exercised identically in every environment.
1155
+ */
1156
+ interface JobScheduler {
1157
+ /** Authenticate an inbound webhook. Return false (or throw) to reject. */
1158
+ verify(req: IncomingJobRequest): Promise<boolean>;
1159
+ /**
1160
+ * Make the provider's recurring schedules match `jobs` exactly (create,
1161
+ * update, and remove stale ones). Called once at server startup.
1162
+ * `endpointFor(name)` yields the absolute URL the provider should POST to.
1163
+ */
1164
+ syncSchedules(jobs: ScheduledJobDef[], endpointFor: (name: string) => string): Promise<void>;
1165
+ /** Enqueue a precise one-shot run of `name` with `body` at `endpoint`. */
1166
+ enqueue(name: string, body: unknown, endpoint: string, opts?: EnqueueOptions): Promise<ScheduleHandle>;
1167
+ /** Cancel a previously enqueued one-shot by its handle id. */
1168
+ cancel(handleId: string): Promise<void>;
1169
+ }
1170
+ interface DevSchedulerOptions {
1171
+ /**
1172
+ * How often, in ms, to fire each recurring job in dev. Dev intentionally
1173
+ * ignores exact cron timing (that is the production scheduler's job); it
1174
+ * just fires often enough to exercise the handler. Default 60_000.
1175
+ */
1176
+ recurringIntervalMs?: number;
1177
+ /**
1178
+ * Override the HTTP client (for tests). Defaults to the global `fetch`.
1179
+ */
1180
+ fetchImpl?: typeof fetch;
1181
+ }
1182
+ /**
1183
+ * In-process scheduler for local development and tests. Recurring jobs fire on
1184
+ * a fixed interval; one-shots fire on an exact `setTimeout` (so precise timing
1185
+ * is faithfully testable). Every fire POSTs to the real HTTP job endpoint, and
1186
+ * `verify` accepts everything — there is no signing in dev.
1187
+ */
1188
+ declare class DevScheduler implements JobScheduler {
1189
+ private readonly intervalMs;
1190
+ private readonly fetchImpl;
1191
+ private intervals;
1192
+ private timeouts;
1193
+ constructor(opts?: DevSchedulerOptions);
1194
+ verify(_req: IncomingJobRequest): Promise<boolean>;
1195
+ syncSchedules(jobs: ScheduledJobDef[], endpointFor: (name: string) => string): Promise<void>;
1196
+ enqueue(name: string, body: unknown, endpoint: string, opts?: EnqueueOptions): Promise<ScheduleHandle>;
1197
+ cancel(handleId: string): Promise<void>;
1198
+ /** Stop every dev timer (call on server shutdown / in test teardown). */
1199
+ stop(): void;
1200
+ private post;
1201
+ }
1202
+ interface QStashSchedulerOptions {
1203
+ /** QStash Base url (`QSTASH_BASE_URL`). */
1204
+ baseUrl: string;
1205
+ /** QStash REST token (`QSTASH_TOKEN`). */
1206
+ token: string;
1207
+ /** Current signing key for webhook verification (`QSTASH_CURRENT_SIGNING_KEY`). */
1208
+ currentSigningKey: string;
1209
+ /** Next signing key, for zero-downtime key rotation (`QSTASH_NEXT_SIGNING_KEY`). */
1210
+ nextSigningKey: string;
1211
+ devMode: boolean;
1212
+ }
1213
+ /**
1214
+ * Production scheduler backed by Upstash QStash. Externalizes the timer so a
1215
+ * horizontally-scaled deployment fires each cron tick exactly once (QStash
1216
+ * calls one HTTP endpoint), with at-least-once retries and signed webhooks.
1217
+ */
1218
+ declare class QStashScheduler implements JobScheduler {
1219
+ private readonly client;
1220
+ private readonly receiver;
1221
+ constructor(opts: QStashSchedulerOptions);
1222
+ verify(req: IncomingJobRequest): Promise<boolean>;
1223
+ syncSchedules(jobs: ScheduledJobDef[], endpointFor: (name: string) => string): Promise<void>;
1224
+ enqueue(name: string, body: unknown, endpoint: string, opts?: EnqueueOptions): Promise<ScheduleHandle>;
1225
+ cancel(handleId: string): Promise<void>;
1226
+ }
1227
+ /**
1228
+ * Thin app-facing handle for scheduling precise one-shots from inside
1229
+ * procedures. The server builds one (via `getJobClient()`) that already knows
1230
+ * how to turn a job name into its endpoint, so callers just say
1231
+ * `jobs.enqueue("expireSpendAuth", { id }, { runAt })`.
1232
+ */
1233
+ declare class JobClient {
1234
+ private readonly scheduler;
1235
+ private readonly endpointFor;
1236
+ constructor(scheduler: JobScheduler, endpointFor: (name: string) => string);
1237
+ enqueue(name: string, body: unknown, opts?: EnqueueOptions): Promise<ScheduleHandle>;
1238
+ cancel(handleId: string): Promise<void>;
1239
+ }
1240
+ //#endregion
1241
+ //#region src/router/procedure.d.ts
1242
+ /**
1243
+ * Patch all Zod schema types on the given `z` namespace with `.modelName(name)`.
1244
+ * Must be called with the same `z` instance the consumer uses so the prototypes
1245
+ * match. Runs once per unique `z` instance (tracked via a WeakSet).
1246
+ */
1247
+ declare function patchZod(zInstance: typeof z$2): void;
1248
+ /**
1249
+ * Query context passed to query handlers.
1250
+ * Contains database reader and user-defined server context.
1251
+ */
1252
+ interface QueryCtx<TContext = unknown> {
1253
+ /** Database reader for queries */
1254
+ db: DbReader;
1255
+ /** User-defined server context (auth, requestId, etc.) */
1256
+ serverCtx?: TContext;
1257
+ }
1258
+ /**
1259
+ * Mutation context passed to mutation handlers.
1260
+ * Contains database writer and user-defined server context.
1261
+ */
1262
+ interface MutationCtx<TContext = unknown> {
1263
+ /** Database writer for mutations (includes insert/update/delete) */
1264
+ db: DbWriter;
1265
+ /** User-defined server context (auth, requestId, etc.) */
1266
+ serverCtx?: TContext;
1267
+ }
1268
+ /**
1269
+ * Action context passed to action handlers.
1270
+ *
1271
+ * Actions are the "external I/O" tier: they hold the full {@link SupaliveDb}
1272
+ * (queries + mutations) and are the ONLY context that also carries side-effect
1273
+ * services — {@link ObjectStorage} for uploads/downloads and a {@link JobClient}
1274
+ * for scheduling precise one-shots. Queries/mutations stay pure (db only) so
1275
+ * they remain cacheable and transaction-scoped.
1276
+ */
1277
+ interface ActionCtx<TContext = unknown> {
1278
+ /** Full database interface for queries and mutations */
1279
+ db: SupaliveDb;
1280
+ /** Object storage, when the server was configured with one (see
1281
+ * `SupaliveServerConfig.storage`); `undefined` otherwise. The usual home
1282
+ * for upload/download presigning. */
1283
+ storage: ObjectStorage;
1284
+ /** Job scheduler client for enqueueing precise one-shots, when the server
1285
+ * was configured with a `scheduler`; `undefined` otherwise. Scheduling is
1286
+ * network I/O, so it belongs in actions, never inside a DB transaction. */
1287
+ scheduler: JobClient;
1288
+ /** User-defined server context (auth, requestId, etc.) */
1289
+ serverCtx?: TContext;
1290
+ }
1291
+ /**
1292
+ * Job context passed to job handlers. Structurally identical to
1293
+ * {@link ActionCtx}: a job is a server-only procedure that runs
1294
+ * non-transactionally against the full {@link SupaliveDb} and may perform
1295
+ * external work, but it is triggered by the scheduler over HTTP (a cron tick
1296
+ * or a precise one-shot) rather than by a connected client. `serverCtx` is
1297
+ * the system context built by the server's `jobContext` factory.
1298
+ */
1299
+ interface JobCtx<TContext = unknown> {
1300
+ /** Full database interface for queries and mutations */
1301
+ db: SupaliveDb;
1302
+ /** System server context built by the server for scheduler-triggered runs */
1303
+ serverCtx?: TContext;
1304
+ }
1305
+ /**
1306
+ * Context handed to `caller.<proc>.runQuery` / `.runMutation` when invoking one
1307
+ * procedure from inside another. Pass the caller handler's own `ctx` — its `db`
1308
+ * carries the parent's live transaction (a {@link DbReader}/{@link DbWriter}) or,
1309
+ * inside an action, the full {@link SupaliveDb}. The caller uses this to decide
1310
+ * whether the nested call joins the parent's snapshot (queries) or runs as an
1311
+ * independent sub-transaction (mutations).
1312
+ */
1313
+ interface ParentCtx<TContext = unknown> {
1314
+ db: DbReader | DbWriter | SupaliveDb;
1315
+ serverCtx?: TContext | undefined;
1316
+ }
1317
+ type QueryFn<TInput, TResult, TContext = unknown> = (ctx: QueryCtx<TContext>, input: TInput) => Promise<TResult>;
1318
+ type MutationFn<TInput, TResult, TContext = unknown> = (ctx: MutationCtx<TContext>, input: TInput) => Promise<TResult>;
1319
+ type ActionFn<TInput, TResult, TContext = unknown> = (ctx: ActionCtx<TContext>, input: TInput) => Promise<TResult>;
1320
+ type JobFn<TInput, TResult, TContext = unknown> = (ctx: JobCtx<TContext>, input: TInput) => Promise<TResult>;
1321
+ /**
1322
+ * Per-procedure override for the cache/subscription segmentation key.
1323
+ *
1324
+ * omitted | undefined → fall back to `config.getUserId(serverCtx)` (default)
1325
+ * false → no identity in hash; cache/sub shared across all users
1326
+ * string → a static identity literal (e.g. "public" or a tenant id)
1327
+ * function → compute from serverCtx + input (sync)
1328
+ *
1329
+ * When the result of a query is identical regardless of who calls it, set
1330
+ * this to a literal (or `false`) so a single cache entry serves everyone.
1331
+ *
1332
+ * The function form intentionally takes `serverCtx` (not the full `QueryCtx`)
1333
+ * because identity is resolved before any DB read is issued.
1334
+ */
1335
+ type QueryIdentitySpec<TInput, TContext> = false | string | ((serverCtx: TContext, input: TInput) => string | null | undefined);
1336
+ interface BaseProcedure<TInput, TResult, TType extends "query" | "mutation" | "action" | "job", TContext = unknown, TInternal extends boolean = boolean> {
1337
+ readonly _type: "procedure";
1338
+ readonly procedureType: TType;
1339
+ readonly inputSchema: ZodType<TInput>;
1340
+ readonly outputSchema?: ZodType<any>;
1341
+ readonly fn: QueryFn<TInput, TResult, TContext> | MutationFn<TInput, TResult, TContext> | ActionFn<TInput, TResult, TContext> | JobFn<TInput, TResult, TContext>;
1342
+ readonly internal: TInternal;
1343
+ }
1344
+ interface QueryProcedure<TInput, TResult, TContext = unknown, TInternal extends boolean = boolean> extends BaseProcedure<TInput, TResult, "query", TContext, TInternal> {
1345
+ readonly procedureType: "query";
1346
+ readonly fn: QueryFn<TInput, TResult, TContext>;
1347
+ readonly queryIdentity?: QueryIdentitySpec<TInput, TContext>;
1348
+ }
1349
+ interface MutationProcedure<TInput, TResult, TContext = unknown, TInternal extends boolean = boolean> extends BaseProcedure<TInput, TResult, "mutation", TContext, TInternal> {
1350
+ readonly procedureType: "mutation";
1351
+ readonly fn: MutationFn<TInput, TResult, TContext>;
1352
+ }
1353
+ interface ActionProcedure<TInput, TResult, TContext = unknown, TInternal extends boolean = boolean> extends BaseProcedure<TInput, TResult, "action", TContext, TInternal> {
1354
+ readonly procedureType: "action";
1355
+ readonly fn: ActionFn<TInput, TResult, TContext>;
1356
+ }
1357
+ /**
1358
+ * A scheduler-triggered, server-only procedure. Runs like an action (full
1359
+ * db, non-transactional, may do external work) but is dispatched by the
1360
+ * server's HTTP job endpoint on a cron tick or a precise one-shot rather
1361
+ * than over the client WebSocket. Always {@link internal}: true, so it is
1362
+ * never reachable via `call`/`subscribe`.
1363
+ */
1364
+ interface JobProcedure<TInput, TResult, TContext = unknown> extends BaseProcedure<TInput, TResult, "job", TContext, true> {
1365
+ readonly procedureType: "job";
1366
+ readonly fn: JobFn<TInput, TResult, TContext>;
1367
+ /**
1368
+ * Cron expression for a recurring job (e.g. `"0 3 * * *"`). Declared crons
1369
+ * are synced to the scheduler at server startup. Omit for a job that is
1370
+ * only ever invoked as a precise one-shot via the scheduler API.
1371
+ */
1372
+ readonly cron?: string;
1373
+ }
1374
+ type AnyProcedure<TContext = unknown> = QueryProcedure<any, any, TContext> | MutationProcedure<any, any, TContext> | ActionProcedure<any, any, TContext> | JobProcedure<any, any, TContext>;
1375
+ interface QueryConfig<TInput, TResult, TContext = unknown> {
1376
+ /** Zod schema for input validation */
1377
+ args: ZodType<TInput>;
1378
+ /** The query handler function */
1379
+ handler: QueryFn<TInput, TResult, TContext>;
1380
+ /** Mark as internal (server-only). Default: false */
1381
+ internal?: boolean;
1382
+ /**
1383
+ * Optional Zod schema describing return-type overrides for codegen.
1384
+ * Only the fields you specify are overridden; everything else is inferred
1385
+ * from the handler's TypeScript return type. Use `.modelName("Name")`
1386
+ * on a Zod object to rename the generated model class.
1387
+ */
1388
+ returns?: ZodType<any>;
1389
+ /**
1390
+ * Override the cache/subscription segmentation key for this procedure.
1391
+ * See {@link QueryIdentitySpec}. Omit to keep the default (per-user) behavior.
1392
+ */
1393
+ queryIdentity?: QueryIdentitySpec<TInput, TContext>;
1394
+ }
1395
+ interface MutationConfig<TInput, TResult, TContext = unknown> {
1396
+ /** Zod schema for input validation */
1397
+ args: ZodType<TInput>;
1398
+ /** The mutation handler function */
1399
+ handler: MutationFn<TInput, TResult, TContext>;
1400
+ /** Mark as internal (server-only). Default: false */
1401
+ internal?: boolean;
1402
+ /**
1403
+ * Optional Zod schema describing return-type overrides for codegen.
1404
+ * Only the fields you specify are overridden; everything else is inferred
1405
+ * from the handler's TypeScript return type.
1406
+ */
1407
+ returns?: ZodType<any>;
1408
+ }
1409
+ interface ActionConfig<TInput, TResult, TContext = unknown> {
1410
+ /** Zod schema for input validation */
1411
+ args: ZodType<TInput>;
1412
+ /** The action handler function */
1413
+ handler: ActionFn<TInput, TResult, TContext>;
1414
+ /** Mark as internal (server-only). Default: false */
1415
+ internal?: boolean;
1416
+ /**
1417
+ * Optional Zod schema describing return-type overrides for codegen.
1418
+ * Only the fields you specify are overridden; everything else is inferred
1419
+ * from the handler's TypeScript return type.
1420
+ */
1421
+ returns?: ZodType<any>;
1422
+ }
1423
+ interface JobConfig<TInput, TResult, TContext = unknown> {
1424
+ /** Zod schema for the job payload */
1425
+ args: ZodType<TInput>;
1426
+ /** The job handler function */
1427
+ handler: JobFn<TInput, TResult, TContext>;
1428
+ /**
1429
+ * Cron expression for a recurring schedule (e.g. `"0 3 * * *"`). Omit for a
1430
+ * job that is only invoked as a precise one-shot.
1431
+ */
1432
+ cron?: string;
1433
+ }
1434
+ /** Extract input type from a procedure */
1435
+ type InputOf<T> = T extends BaseProcedure<infer I, any, any, any> ? I : never;
1436
+ /** Extract output type from a procedure */
1437
+ type OutputOf<T> = T extends BaseProcedure<any, infer O, any, any> ? O : never;
1438
+ /** Extract procedure type (query/mutation) */
1439
+ type TypeOf<T> = T extends BaseProcedure<any, any, infer Type, any> ? Type : never;
1440
+ /** Extract server context type from a procedure */
1441
+ type ContextOf<T> = T extends BaseProcedure<any, any, any, infer C> ? C : never;
1442
+ /**
1443
+ * Create a query builder with a pre-defined context type.
1444
+ * This allows you to define the context type once and have it inferred
1445
+ * automatically in all your query handlers.
1446
+ *
1447
+ * @example
1448
+ * // Define your server context
1449
+ * interface ServerContext {
1450
+ * auth: { userId: string };
1451
+ * requestId: string;
1452
+ * }
1453
+ *
1454
+ * // Create a typed query builder
1455
+ * const query = createQueryBuilder<ServerContext>();
1456
+ *
1457
+ * // Use it - context type is automatically inferred!
1458
+ * const getUser = query({
1459
+ * args: z.object({ id: z.string() }),
1460
+ * handler: async (ctx, { id }) => {
1461
+ * // ctx.db for database queries
1462
+ * const user = await ctx.db.query(UsersSchema).find(id);
1463
+ * // ctx.context for server context
1464
+ * console.log(ctx.context.requestId);
1465
+ * return user;
1466
+ * }
1467
+ * });
1468
+ */
1469
+ declare function createQueryBuilder<TContext = unknown>(): <TInput, TResult, const TInternal extends boolean = false>(config: QueryConfig<TInput, TResult, TContext> & {
1470
+ internal?: TInternal;
1471
+ }) => QueryProcedure<TInput, TResult, TContext, TInternal>;
1472
+ /**
1473
+ * Create a mutation builder with a pre-defined context type.
1474
+ * This allows you to define the context type once and have it inferred
1475
+ * automatically in all your mutation handlers.
1476
+ *
1477
+ * @example
1478
+ * // Define your server context
1479
+ * interface ServerContext {
1480
+ * auth: { userId: string };
1481
+ * requestId: string;
1482
+ * }
1483
+ *
1484
+ * // Create a typed mutation builder
1485
+ * const mutation = createMutationBuilder<ServerContext>();
1486
+ *
1487
+ * // Use it - context type is automatically inferred!
1488
+ * const createUser = mutation({
1489
+ * args: z.object({ name: z.string() }),
1490
+ * handler: async (ctx, { name }) => {
1491
+ * // ctx.db for mutations
1492
+ * await ctx.db.insert(UsersSchema, id, { name });
1493
+ * // ctx.context for server context
1494
+ * console.log(ctx.context.requestId);
1495
+ * return { success: true };
1496
+ * }
1497
+ * });
1498
+ */
1499
+ declare function createMutationBuilder<TContext = unknown>(): <TInput, TResult, const TInternal extends boolean = false>(config: MutationConfig<TInput, TResult, TContext> & {
1500
+ internal?: TInternal;
1501
+ }) => MutationProcedure<TInput, TResult, TContext, TInternal>;
1502
+ /**
1503
+ * Create an action builder with a pre-defined context type.
1504
+ * Actions have access to the full SupaliveDb for both queries and mutations.
1505
+ *
1506
+ * @example
1507
+ * // Define your server context
1508
+ * interface ServerContext {
1509
+ * auth: { userId: string };
1510
+ * requestId: string;
1511
+ * }
1512
+ *
1513
+ * // Create a typed action builder
1514
+ * const action = createActionBuilder<ServerContext>();
1515
+ *
1516
+ * // Use it - context type is automatically inferred!
1517
+ * const processOrder = action({
1518
+ * args: z.object({ orderId: z.string() }),
1519
+ * handler: async (ctx, { orderId }) => {
1520
+ * // ctx.db for full database access
1521
+ * const order = await ctx.db.query(async (db) => {
1522
+ * return db.query(OrdersSchema).find(orderId);
1523
+ * });
1524
+ * await ctx.db.mutation(async (db) => {
1525
+ * await db.update(OrdersSchema, orderId, { status: "processed" });
1526
+ * });
1527
+ * // ctx.context for server context
1528
+ * console.log(ctx.context.requestId);
1529
+ * return { success: true };
1530
+ * }
1531
+ * });
1532
+ */
1533
+ declare function createActionBuilder<TContext = unknown>(): <TInput, TResult, const TInternal extends boolean = false>(config: ActionConfig<TInput, TResult, TContext> & {
1534
+ internal?: TInternal;
1535
+ }) => ActionProcedure<TInput, TResult, TContext, TInternal>;
1536
+ /**
1537
+ * Create a job builder with a pre-defined context type. A job is a
1538
+ * server-only procedure invoked by the scheduler over HTTP — either on its
1539
+ * declared `cron` schedule or as a precise one-shot enqueued via the
1540
+ * server's job API. Jobs run like actions (full db, non-transactional) and
1541
+ * are always internal, so they are never reachable from a client.
1542
+ *
1543
+ * @example
1544
+ * const job = createJobBuilder<ServerContext>();
1545
+ *
1546
+ * export const cleanupOtps = job({
1547
+ * cron: "0 * * * *", // hourly
1548
+ * args: z.object({}),
1549
+ * handler: async (ctx) => {
1550
+ * await ctx.db.mutation(async (db) => { ... });
1551
+ * return { ok: true };
1552
+ * },
1553
+ * });
1554
+ */
1555
+ declare function createJobBuilder<TContext = unknown>(): <TInput, TResult>(config: JobConfig<TInput, TResult, TContext>) => JobProcedure<TInput, TResult, TContext>;
1556
+ //#endregion
1557
+ //#region src/router/router.d.ts
1558
+ /**
1559
+ * A router maps procedure names (keys) to their definitions.
1560
+ * This is the type that's exported from your app and used by the client.
1561
+ */
1562
+ type Router<TProcedures extends Record<string, AnyProcedure<TContext>>, TContext = unknown> = {
1563
+ _type: "router";
1564
+ procedures: TProcedures;
1565
+ contextName: string;
1566
+ };
1567
+ /**
1568
+ * Inferred AppRouter type from router() call.
1569
+ * Captures the full procedure map for client type inference.
1570
+ */
1571
+ type AppRouter<TProcedures extends Record<string, AnyProcedure<TContext>> = Record<string, AnyProcedure>, TContext = unknown> = Router<TProcedures, TContext>;
1572
+ /** Get query procedures only from a router */
1573
+ type QueryProcedures<T extends Record<string, AnyProcedure>> = { [K in keyof T as T[K] extends {
1574
+ procedureType: "query";
1575
+ } ? K : never]: T[K] };
1576
+ /** Get mutation procedures only from a router */
1577
+ type MutationProcedures<T extends Record<string, AnyProcedure>> = { [K in keyof T as T[K] extends {
1578
+ procedureType: "mutation";
1579
+ } ? K : never]: T[K] };
1580
+ /** Get action procedures only from a router */
1581
+ type ActionProcedures<T extends Record<string, AnyProcedure>> = { [K in keyof T as T[K] extends {
1582
+ procedureType: "action";
1583
+ } ? K : never]: T[K] };
1584
+ /** Get job procedures only from a router */
1585
+ type JobProcedures<T extends Record<string, AnyProcedure>> = { [K in keyof T as T[K] extends {
1586
+ procedureType: "job";
1587
+ } ? K : never]: T[K] };
1588
+ /** Get public (non-internal) procedures - for client type safety */
1589
+ type PublicProcedures<T extends Record<string, AnyProcedure>> = Pick<T, { [K in keyof T]: T[K] extends {
1590
+ internal: true;
1591
+ } ? never : K }[keyof T]>;
1592
+ /** Extract procedure names from a router */
1593
+ type ProcedureNames<T extends Router<any>> = T extends Router<infer P> ? keyof P : never;
1594
+ type RouterConfig<T> = {
1595
+ procedures: T;
1596
+ contextName?: string;
1597
+ };
1598
+ /**
1599
+ * Create a router from procedure definitions.
1600
+ * Procedure names are inferred from the object keys.
1601
+ *
1602
+ * @example
1603
+ * const appRouter = router({
1604
+ * procedures: {
1605
+ * getUser,
1606
+ * createUser,
1607
+ * internalGetAll,
1608
+ * },
1609
+ * });
1610
+ *
1611
+ * export type AppRouter = typeof appRouter;
1612
+ */
1613
+ declare function router<TProcedures extends Record<string, AnyProcedure<any>>, TContext = unknown>(config: RouterConfig<TProcedures>): Router<TProcedures, TContext>;
1614
+ interface RegisteredProcedure<TContext = unknown> {
1615
+ name: string;
1616
+ type: "query" | "mutation" | "action" | "job";
1617
+ internal: boolean;
1618
+ inputSchema: AnyProcedure<TContext>["inputSchema"];
1619
+ fn: AnyProcedure<TContext>["fn"];
1620
+ /** Only present for `type === "query"`. See `QueryIdentitySpec`. */
1621
+ queryIdentity?: false | string | ((serverCtx: TContext | undefined, input: unknown) => string | null | undefined);
1622
+ /** Only present for `type === "job"`. Cron expression for recurring jobs. */
1623
+ cron?: string;
1624
+ }
1625
+ declare function getContextRegistry(inContext: string): ContextRegistry;
1626
+ declare class ContextRegistry {
1627
+ procedureRegistry: Map<string, RegisteredProcedure<any>>;
1628
+ internalProcedureNames: Set<string>;
1629
+ registerProcedure<TContext>(name: string, proc: AnyProcedure<TContext>): void;
1630
+ /** Get a registered procedure by name (runtime lookup) */
1631
+ getProcedure<TContext = unknown>(name: string): RegisteredProcedure<TContext> | undefined;
1632
+ /** Get all registered procedure names */
1633
+ getProcedureNames(): string[];
1634
+ /** Get all registered procedures */
1635
+ getAllProcedures(): Map<string, RegisteredProcedure>;
1636
+ /** Get all registered job procedures (server-only, scheduler-triggered). */
1637
+ getJobProcedures(): RegisteredProcedure[];
1638
+ /** Clear the registry (for testing only) */
1639
+ clearRegistry(): void;
1640
+ markInternalProcedure(name: string): void;
1641
+ isInternalProcedure(name: string): boolean;
1642
+ clearInternalProcedures(): void;
1643
+ }
1644
+ //#endregion
1645
+ //#region src/client/ws_client_manager.d.ts
1646
+ declare class RPCError extends Error {
1647
+ code?: string;
1648
+ constructor(message: string, code?: string);
1649
+ }
1650
+ interface HeartbeatOptions {
1651
+ /**
1652
+ * Close + reconnect when no server message arrives for this long. The
1653
+ * server emits `{type:"ping"}` every ~15s of channel idle, so anything
1654
+ * larger than ~30s leaves comfortable headroom. Default 60_000.
1655
+ */
1656
+ serverInactivityMs?: number;
1657
+ }
1658
+ interface SendThrottleOptions {
1659
+ /** Yield the event loop every N `call()` invocations. 0 disables. Default 100. */
1660
+ everyN?: number;
1661
+ /** Length of the yield in ms. Default 10. */
1662
+ delayMs?: number;
1663
+ }
1664
+ interface WSClientOptions {
1665
+ /** WebSocket URL (e.g. ws://localhost:3000/ws) */
1666
+ url: string;
1667
+ /** Auth token to send after connection */
1668
+ token?: () => Promise<string | undefined>;
1669
+ /** Optional: reconnection timeout in ms (default: 180000 = 3 minutes) */
1670
+ reconnectionTimeout?: number;
1671
+ /** Reconnection options */
1672
+ reconnect?: {
1673
+ /** Enable automatic reconnection (default: true) */enabled?: boolean; /** Max reconnection attempts (default: 5) */
1674
+ maxAttempts?: number; /** Delay between attempts in ms (default: 1000) */
1675
+ delay?: number; /** Exponential backoff multiplier (default: 1.5) */
1676
+ backoff?: number;
1677
+ };
1678
+ /** Server-inactivity watchdog. See {@link HeartbeatOptions.serverInactivityMs}. */
1679
+ heartbeat?: HeartbeatOptions;
1680
+ /**
1681
+ * Yields the event loop for `delayMs` ms after every `everyN`
1682
+ * `call()` invocations. Useful for keeping React renders / GC tasks
1683
+ * scheduled during long synchronous bursts of mutations/actions; the
1684
+ * heartbeat does not depend on this (the server drives it).
1685
+ * Default `{ everyN: 100, delayMs: 10 }`. Set `everyN: 0` to disable.
1686
+ */
1687
+ throttle?: SendThrottleOptions;
1688
+ /** Called when connection is established */
1689
+ onConnect?: () => void;
1690
+ /** Called when connection is lost */
1691
+ onDisconnect?: () => void;
1692
+ /** Called on connection error */
1693
+ onError?: (error: Error) => void;
1694
+ }
1695
+ /**
1696
+ * Public state of the client, surfaced to consumers (React provider, etc.).
1697
+ * - "connecting" — initial connect or reconnect handshake in flight
1698
+ * - "authenticating" — connected, waiting for auth result
1699
+ * - "ready" — connected and auth resolved (authenticated, anonymous, or
1700
+ * explicitly failed — i.e. ready to send calls)
1701
+ * - "disconnected" — currently offline (may auto-retry)
1702
+ */
1703
+ type ClientPublicState = "disconnected" | "connecting" | "authenticating" | "ready";
1704
+ declare class WsClientManager {
1705
+ private ws;
1706
+ private options;
1707
+ private lastSuccessfulConnectionTime;
1708
+ private reconnectionTimeout;
1709
+ private requestId;
1710
+ private pendingRequests;
1711
+ /**
1712
+ * Single source of truth for live subscriptions.
1713
+ *
1714
+ * Keying:
1715
+ * - In-flight subscribe (no subId yet): `_pending:<requestId>`.
1716
+ * - Established: the server-returned canonical `subId`.
1717
+ *
1718
+ * Routing `sub:update` / `sub:gone` is O(1) (`get(subId)`). Subscribe-time
1719
+ * dedup scans `values()` for a matching `localKey` (O(N)), which is cheap
1720
+ * since subscribes happen on component mounts, not in the hot path.
1721
+ */
1722
+ private subscriptions;
1723
+ private queuedCalls;
1724
+ private reconnectAttempts;
1725
+ private reconnectTimer;
1726
+ private connectionState;
1727
+ private authState;
1728
+ /**
1729
+ * Authenticated user id from `auth:success`. Distinct from `queryIdentity`
1730
+ * (server-side cache/sub segmentation key); this is just "who am I logged
1731
+ * in as" for app display purposes. Null while unauthenticated / anonymous.
1732
+ */
1733
+ private authUserId;
1734
+ private explicitlyClosed;
1735
+ private stateListeners;
1736
+ private lastPublicState;
1737
+ private serverInactivityMs;
1738
+ private lastServerMessageAt;
1739
+ private inactivityTimer;
1740
+ private pendingConnectResolve;
1741
+ private pendingConnectReject;
1742
+ private throttleEveryN;
1743
+ private throttleDelayMs;
1744
+ private throttleCounter;
1745
+ private throttling;
1746
+ private visibilityListener;
1747
+ private onlineListener;
1748
+ constructor(options: WSClientOptions);
1749
+ /**
1750
+ * Subscribe to client state transitions. Returns an unsubscribe fn.
1751
+ * The listener is called immediately with the current state.
1752
+ */
1753
+ onState(listener: (s: ClientPublicState) => void): () => void;
1754
+ /** Current public state. */
1755
+ getPublicState(): ClientPublicState;
1756
+ /**
1757
+ * Connect to the WebSocket server.
1758
+ * Returns a promise that resolves when connected and authenticated.
1759
+ */
1760
+ connect(): Promise<void>;
1761
+ /**
1762
+ * Disconnect from the server.
1763
+ */
1764
+ disconnect(): void;
1765
+ /**
1766
+ * Check if connected and authenticated.
1767
+ */
1768
+ isReady(): boolean;
1769
+ /**
1770
+ * Check if authenticated.
1771
+ */
1772
+ isAuthenticated(): boolean;
1773
+ /**
1774
+ * Check if anonymouse.
1775
+ */
1776
+ isAnonymouse(): boolean;
1777
+ /**
1778
+ * The authenticated user's id (from `auth:success`), or null when
1779
+ * unauthenticated / anonymous. Useful for "Logged in as …" display.
1780
+ *
1781
+ * Not to be confused with server-side `queryIdentity`, which is the
1782
+ * cache/subscription segmentation key (resolved entirely on the server).
1783
+ */
1784
+ getAuthUserId(): string | null;
1785
+ /**
1786
+ * Call a procedure (query, mutation, or action).
1787
+ *
1788
+ * If the client is not ready (disconnected or still authenticating), the
1789
+ * call is FIFO-queued and dispatched on the next ready state. The promise
1790
+ * still resolves with the eventual server response.
1791
+ *
1792
+ * Pass `onSend` to be notified when the call actually leaves the queue
1793
+ * (used by `useMutation` to flip `state` from "queued" → "loading").
1794
+ */
1795
+ call(procedure: string, input: unknown, options?: {
1796
+ onSend?: () => void;
1797
+ }): Promise<unknown>;
1798
+ /**
1799
+ * Throttle drain loop. Each iteration: sleep `throttleDelayMs`, then
1800
+ * dispatch up to `throttleEveryN` queued items. Exits as soon as the
1801
+ * queue drains inside a single batch (burst over, back to direct
1802
+ * dispatch on the next `call()`) or the connection goes away
1803
+ * (reconnect path will restart us via `flushQueuedCalls`).
1804
+ */
1805
+ private runThrottleLoop;
1806
+ /**
1807
+ * Issue the call against an established connection. Caller must ensure
1808
+ * `isReady()` before invoking.
1809
+ */
1810
+ private dispatchCall;
1811
+ /**
1812
+ * Flush queued calls in FIFO order. Called once `isReady()` becomes
1813
+ * true. With the throttle enabled, dispatch the first batch
1814
+ * synchronously then hand off to the drain loop so a large
1815
+ * post-reconnect flush respects backpressure instead of dumping 10k
1816
+ * frames in one tick.
1817
+ */
1818
+ private flushQueuedCalls;
1819
+ /**
1820
+ * Re-send `subscribe` for every existing subscription. The subId for each
1821
+ * may legitimately change (e.g. `queryIdentity` was a function of user
1822
+ * identity and the user changed during the disconnect), so we re-key the
1823
+ * unified `subscriptions` Map: snapshot every record, drop them from the
1824
+ * Map, then reinsert under a fresh `_pending:<reqId>` key. Each pending
1825
+ * request's `resolve` rekeys the parked record under the new server-issued
1826
+ * subId so subsequent `sub:update` frames route to the existing
1827
+ * `onUpdate` callback (which the React handle is still holding).
1828
+ */
1829
+ private resubscribeAll;
1830
+ /**
1831
+ * Subscribe to a live query.
1832
+ *
1833
+ * The client does not compute the subId locally — it sends the
1834
+ * (procedure, input) pair and receives the canonical subId on the
1835
+ * subscribe response. This lets the server's per-procedure
1836
+ * `queryIdentity` override be authoritative without forcing the client
1837
+ * to mirror any of the resolution logic.
1838
+ *
1839
+ * Returns the server-assigned subId and an unsubscribe function.
1840
+ */
1841
+ subscribe(procedure: string, input: unknown, serializedInput: string, onUpdate: (data: unknown) => void, onGone?: (reason: string | undefined) => void): Promise<{
1842
+ subId: string;
1843
+ unsubscribe: () => void;
1844
+ }>;
1845
+ private findSubByLocalKey;
1846
+ /** Resolve every joiner waiting on this Subscription with the canonical subId. */
1847
+ private resolveJoiners;
1848
+ /** Reject every joiner waiting on this Subscription with the given error. */
1849
+ private rejectJoiners;
1850
+ private unsubscribeByLocalKey;
1851
+ private handleMessage;
1852
+ /**
1853
+ * Called once the client transitions to a "ready" state on a fresh
1854
+ * connection. Replays live-query subscriptions and flushes any queued
1855
+ * calls in FIFO order.
1856
+ */
1857
+ private afterReady;
1858
+ private handleResponse;
1859
+ private handleSubscriptionUpdate;
1860
+ /**
1861
+ * Handles a `sub:gone` message: the server no longer tracks this
1862
+ * subscription (e.g. it was fully unregistered while we were disconnected
1863
+ * from the sub-manager). Notify the handle and drop the local entry so a
1864
+ * re-subscribe is required to receive further updates.
1865
+ */
1866
+ private handleSubscriptionGone;
1867
+ private handleClose;
1868
+ private handleError;
1869
+ private startInactivityWatchdog;
1870
+ private stopInactivityWatchdog;
1871
+ /**
1872
+ * Close the current WebSocket and schedule a reconnect via `handleClose`.
1873
+ *
1874
+ * Atomically swaps the old socket's event handlers to no-ops BEFORE
1875
+ * `close()` so a frame in flight at the moment of close cannot fire
1876
+ * `handleMessage` into a half-cleaned state — that was the source of
1877
+ * the "browser says socket is alive but client says disconnected" race.
1878
+ */
1879
+ private closeAndReconnect;
1880
+ private installEnvironmentListeners;
1881
+ private removeEnvironmentListeners;
1882
+ private scheduleReconnect;
1883
+ private computePublicState;
1884
+ private emitState;
1885
+ private ensureConnected;
1886
+ private send;
1887
+ private cleanup;
1888
+ private generateRequestId;
1889
+ }
1890
+ //#endregion
1891
+ //#region src/db/types_client_rpc.d.ts
1892
+ interface ErrorMessage {
1893
+ type: "error";
1894
+ id?: string;
1895
+ error: string;
1896
+ code?: string;
1897
+ }
1898
+ declare const AuthMessageSchema: z.ZodObject<{
1899
+ type: z.ZodLiteral<"auth">;
1900
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1901
+ }, z.core.$strip>;
1902
+ declare const CallMessageSchema: z.ZodObject<{
1903
+ type: z.ZodLiteral<"call">;
1904
+ id: z.ZodString;
1905
+ procedure: z.ZodString;
1906
+ input: z.ZodUnknown;
1907
+ }, z.core.$strip>;
1908
+ declare const SubscribeMessageSchema: z.ZodObject<{
1909
+ type: z.ZodLiteral<"subscribe">;
1910
+ id: z.ZodString;
1911
+ procedure: z.ZodString;
1912
+ input: z.ZodUnknown;
1913
+ }, z.core.$strip>;
1914
+ declare const UnsubscribeMessageSchema: z.ZodObject<{
1915
+ type: z.ZodLiteral<"unsubscribe">;
1916
+ subId: z.ZodString;
1917
+ }, z.core.$strip>;
1918
+ declare const ClientMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
1919
+ type: z.ZodLiteral<"auth">;
1920
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1921
+ }, z.core.$strip>, z.ZodObject<{
1922
+ type: z.ZodLiteral<"call">;
1923
+ id: z.ZodString;
1924
+ procedure: z.ZodString;
1925
+ input: z.ZodUnknown;
1926
+ }, z.core.$strip>, z.ZodObject<{
1927
+ type: z.ZodLiteral<"subscribe">;
1928
+ id: z.ZodString;
1929
+ procedure: z.ZodString;
1930
+ input: z.ZodUnknown;
1931
+ }, z.core.$strip>, z.ZodObject<{
1932
+ type: z.ZodLiteral<"unsubscribe">;
1933
+ subId: z.ZodString;
1934
+ }, z.core.$strip>]>;
1935
+ type AuthMessage = z.infer<typeof AuthMessageSchema>;
1936
+ type CallMessage = z.infer<typeof CallMessageSchema>;
1937
+ type SubscribeMessage = z.infer<typeof SubscribeMessageSchema>;
1938
+ type UnsubscribeMessage = z.infer<typeof UnsubscribeMessageSchema>;
1939
+ type ClientMessage = z.infer<typeof ClientMessageSchema>;
1940
+ declare const ConnectedMessageSchema: z.ZodObject<{
1941
+ type: z.ZodLiteral<"connected">;
1942
+ sessionId: z.ZodString;
1943
+ }, z.core.$strip>;
1944
+ declare const AuthSuccessMessageSchema: z.ZodObject<{
1945
+ type: z.ZodLiteral<"auth:success">;
1946
+ userId: z.ZodString;
1947
+ extra: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
1948
+ }, z.core.$strip>;
1949
+ declare const AuthFailedMessageSchema: z.ZodObject<{
1950
+ type: z.ZodLiteral<"auth:failed">;
1951
+ message: z.ZodString;
1952
+ extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1953
+ }, z.core.$strip>;
1954
+ declare const ResponseMessageSchema: z.ZodObject<{
1955
+ type: z.ZodLiteral<"response">;
1956
+ id: z.ZodString;
1957
+ success: z.ZodBoolean;
1958
+ data: z.ZodOptional<z.ZodUnknown>;
1959
+ error: z.ZodOptional<z.ZodString>;
1960
+ code: z.ZodOptional<z.ZodString>;
1961
+ subId: z.ZodOptional<z.ZodString>;
1962
+ }, z.core.$strip>;
1963
+ declare const SubscriptionUpdateMessageSchema: z.ZodObject<{
1964
+ type: z.ZodLiteral<"sub:update">;
1965
+ subId: z.ZodString;
1966
+ data: z.ZodUnknown;
1967
+ dataHash: z.ZodOptional<z.ZodString>;
1968
+ }, z.core.$strip>;
1969
+ /**
1970
+ * Notifies a client that a subscription is no longer tracked on the server
1971
+ * and will not receive further updates. Sent when, during a sub-manager
1972
+ * recovery cycle, the registration record could not be found (e.g. another
1973
+ * app-server instance fully unregistered the sub while we were disconnected).
1974
+ * The client may choose to re-subscribe or surface the state to the user.
1975
+ */
1976
+ declare const SubscriptionGoneMessageSchema: z.ZodObject<{
1977
+ type: z.ZodLiteral<"sub:gone">;
1978
+ subId: z.ZodString;
1979
+ reason: z.ZodOptional<z.ZodString>;
1980
+ }, z.core.$strip>;
1981
+ /**
1982
+ * Server-driven liveness signal. Sent when the channel has been idle for
1983
+ * the configured app-ping interval (default 15s) and again after every
1984
+ * outbound message. Pure no-op for the client: receiving any message
1985
+ * (including this one) resets the client's inactivity watchdog. The client
1986
+ * does NOT reply.
1987
+ */
1988
+ declare const ServerPingMessageSchema: z.ZodObject<{
1989
+ type: z.ZodLiteral<"ping">;
1990
+ }, z.core.$strip>;
1991
+ declare const ServerMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
1992
+ type: z.ZodLiteral<"connected">;
1993
+ sessionId: z.ZodString;
1994
+ }, z.core.$strip>, z.ZodObject<{
1995
+ type: z.ZodLiteral<"auth:success">;
1996
+ userId: z.ZodString;
1997
+ extra: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
1998
+ }, z.core.$strip>, z.ZodObject<{
1999
+ type: z.ZodLiteral<"auth:failed">;
2000
+ message: z.ZodString;
2001
+ extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2002
+ }, z.core.$strip>, z.ZodObject<{
2003
+ type: z.ZodLiteral<"response">;
2004
+ id: z.ZodString;
2005
+ success: z.ZodBoolean;
2006
+ data: z.ZodOptional<z.ZodUnknown>;
2007
+ error: z.ZodOptional<z.ZodString>;
2008
+ code: z.ZodOptional<z.ZodString>;
2009
+ subId: z.ZodOptional<z.ZodString>;
2010
+ }, z.core.$strip>, z.ZodObject<{
2011
+ type: z.ZodLiteral<"sub:update">;
2012
+ subId: z.ZodString;
2013
+ data: z.ZodUnknown;
2014
+ dataHash: z.ZodOptional<z.ZodString>;
2015
+ }, z.core.$strip>, z.ZodObject<{
2016
+ type: z.ZodLiteral<"sub:gone">;
2017
+ subId: z.ZodString;
2018
+ reason: z.ZodOptional<z.ZodString>;
2019
+ }, z.core.$strip>, z.ZodObject<{
2020
+ type: z.ZodLiteral<"ping">;
2021
+ }, z.core.$strip>]>;
2022
+ type ConnectedMessage = z.infer<typeof ConnectedMessageSchema>;
2023
+ type AuthSuccessMessage = z.infer<typeof AuthSuccessMessageSchema>;
2024
+ type AuthFailedMessage = z.infer<typeof AuthFailedMessageSchema>;
2025
+ type ResponseMessage = z.infer<typeof ResponseMessageSchema>;
2026
+ type SubscriptionUpdateMessage = z.infer<typeof SubscriptionUpdateMessageSchema>;
2027
+ type SubscriptionGoneMessage = z.infer<typeof SubscriptionGoneMessageSchema>;
2028
+ type ServerPingMessage = z.infer<typeof ServerPingMessageSchema>;
2029
+ type ServerMessage = z.infer<typeof ServerMessageSchema>;
2030
+ declare class AuthenticationError extends Error {
2031
+ extra: Record<string, unknown>;
2032
+ constructor(message: string, extra?: Record<string, unknown>);
2033
+ }
2034
+ /**
2035
+ * Helper type to check if a procedure is internal.
2036
+ */
2037
+ type IsInternal<T> = T extends {
2038
+ internal: infer I;
2039
+ } ? (I extends true ? true : false) : false;
2040
+ interface Context {
2041
+ requestId: string;
2042
+ /** Authenticated user info */
2043
+ user: {
2044
+ userId: string;
2045
+ };
2046
+ }
2047
+ //#endregion
2048
+ //#region src/client/client.d.ts
2049
+ interface ClientOptions {
2050
+ /** WebSocket URL (e.g. ws://localhost:3000/ws) */
2051
+ url: string;
2052
+ /** Auth Info callback */
2053
+ token?: () => Promise<string>;
2054
+ /** Optional: reconnection timeout in ms (default: 180000 = 3 minutes) */
2055
+ reconnectionTimeout?: number;
2056
+ /** Reconnection options */
2057
+ reconnect?: WSClientOptions["reconnect"];
2058
+ /**
2059
+ * Inactivity watchdog. The client never sends a ping itself; the server
2060
+ * emits `{type:"ping"}` while idle and we close+reconnect if no inbound
2061
+ * message arrives within `serverInactivityMs` (default 60s).
2062
+ */
2063
+ heartbeat?: WSClientOptions["heartbeat"];
2064
+ /**
2065
+ * Yields the event loop for `delayMs` after every `everyN` `call()`
2066
+ * invocations. Useful for keeping React renders / GC tasks scheduled
2067
+ * during long synchronous bursts; not load-bearing for the heartbeat.
2068
+ * Default `{ everyN: 100, delayMs: 10 }`. Set `everyN: 0` to disable.
2069
+ */
2070
+ throttle?: WSClientOptions["throttle"];
2071
+ onConnect?: () => void;
2072
+ onDisConnect?: () => void;
2073
+ }
2074
+ /**
2075
+ * Public state of a live query subscription, exposed via `getState()` and
2076
+ * `onState()` on the handle so React (or any UI) can render a consistent
2077
+ * snapshot via `useSyncExternalStore`.
2078
+ *
2079
+ * - "connecting" — initial subscribe in flight
2080
+ * - "success" — subscribed, last server data is in `data`
2081
+ * - "stale" — was successful, transport dropped; keeping last `data`
2082
+ * until the resubscribe completes
2083
+ * - "loading" — `refetch()` triggered an explicit re-subscribe
2084
+ * - "error" — subscribe failed or server sent `sub:gone`
2085
+ */
2086
+ type LiveQueryStatus = "connecting" | "success" | "stale" | "loading" | "error";
2087
+ interface LiveQueryState<T> {
2088
+ data: T | undefined;
2089
+ status: LiveQueryStatus;
2090
+ error: Error | null;
2091
+ }
2092
+ interface LiveQueryHandle<T> {
2093
+ /** Get current cached data (legacy convenience getter). */
2094
+ get(): T | undefined;
2095
+ /** Snapshot of `{ data, status, error }`. Stable between updates. */
2096
+ getState(): LiveQueryState<T>;
2097
+ /**
2098
+ * Listen for state changes (data, status or error). Returns an
2099
+ * unsubscribe function that removes only this listener — the underlying
2100
+ * server subscription stays alive as long as any listener is attached.
2101
+ *
2102
+ * Suitable for `useSyncExternalStore`.
2103
+ */
2104
+ onState(listener: () => void): () => void;
2105
+ /** Listen for data-only changes. Returns listener-removal fn. */
2106
+ onData(callback: (data: T) => void): () => void;
2107
+ /** Force a re-subscribe round-trip. */
2108
+ refetch(): void;
2109
+ /** Unsubscribe from the server (drops listeners too). */
2110
+ unsubscribe(): void;
2111
+ }
2112
+ /**
2113
+ * Create a fully typed RPC client with WebSocket transport.
2114
+ */
2115
+ declare function createClient<AppRouter extends Router<Record<string, AnyProcedure<TContext>>, TContext>, TContext = unknown, TProcedures extends Record<string, AnyProcedure<TContext>> = AppRouter["procedures"]>(options: ClientOptions): ClientFromProcedures<TProcedures, TContext> & WSClientMethods;
2116
+ /**
2117
+ * WebSocket client methods.
2118
+ */
2119
+ interface WSClientMethods {
2120
+ /** Connect to the WebSocket server */
2121
+ connect(): Promise<void>;
2122
+ /** Disconnect from the server */
2123
+ disconnect(): void;
2124
+ /** Check if connected and authenticated */
2125
+ isReady(): boolean;
2126
+ /** Check if authenticated */
2127
+ isAuthenticated(): boolean;
2128
+ /** Check if anonymouse */
2129
+ isAnonymouse(): boolean;
2130
+ /**
2131
+ * The authenticated user id reported by the server on `auth:success`, or
2132
+ * null when anonymous/unauthenticated. This is the auth-tier identity,
2133
+ * NOT the server-side `queryIdentity` (which is the cache/subscription
2134
+ * segmentation key and is not exposed to the client).
2135
+ */
2136
+ getAuthUserId(): string | null;
2137
+ /** Subscribe to client connection state transitions. Returns unsubscribe fn. */
2138
+ onState(listener: (s: ClientPublicState) => void): () => void;
2139
+ /** Snapshot of the current public state. */
2140
+ getPublicState(): ClientPublicState;
2141
+ }
2142
+ /**
2143
+ * Client type from procedures.
2144
+ * Filters internal procedures and creates appropriate methods.
2145
+ * Query procedures get an additional liveQuery() method for real-time subscriptions.
2146
+ */
2147
+ type ClientFromProcedures<TProcedures extends Record<string, AnyProcedure<TContext>>, TContext = unknown> = { [K in keyof TProcedures as IsInternal<TProcedures[K]> extends true ? never : K]: TProcedures[K] extends {
2148
+ procedureType: "query";
2149
+ } ? {
2150
+ query: (input: InputOf<TProcedures[K]>) => Promise<OutputOf<TProcedures[K]>>;
2151
+ liveQuery: (input: InputOf<TProcedures[K]>) => LiveQueryHandle<OutputOf<TProcedures[K]>>;
2152
+ } : TProcedures[K] extends {
2153
+ procedureType: "mutation";
2154
+ } ? {
2155
+ mutate: (input: InputOf<TProcedures[K]>, opts?: CallOptions) => Promise<OutputOf<TProcedures[K]>>;
2156
+ } : TProcedures[K] extends {
2157
+ procedureType: "action";
2158
+ } ? {
2159
+ action: (input: InputOf<TProcedures[K]>, opts?: CallOptions) => Promise<OutputOf<TProcedures[K]>>;
2160
+ } : never };
2161
+ /**
2162
+ * Optional call options forwarded to the transport layer.
2163
+ */
2164
+ interface CallOptions {
2165
+ /**
2166
+ * Fired the first time the request leaves the queue and is actually
2167
+ * sent on the wire. If the call was already sent immediately (client
2168
+ * was ready at call time), this is invoked synchronously.
2169
+ *
2170
+ * Used by `useMutation` to flip `state` from "queued" → "loading".
2171
+ */
2172
+ onSend?: () => void;
2173
+ }
2174
+ //#endregion
2175
+ //#region src/client/caller_client.d.ts
2176
+ interface CallerOptions<TContext = unknown> {
2177
+ isInternal?: boolean;
2178
+ inContext: string;
2179
+ }
2180
+ /**
2181
+ * Create a server-side caller that bypasses HTTP/WebSocket.
2182
+ *
2183
+ * For in-memory calls, input validation is skipped (data is already a JS object).
2184
+ * Query procedures also get a liveQuery() method for server-side use.
2185
+ */
2186
+ declare function createCaller<AppRouter extends Router<Record<string, AnyProcedure<TContext>>, TContext>, TContext = unknown, TProcedures extends Record<string, AnyProcedure<TContext>> = AppRouter["procedures"]>(options: CallerOptions<any>): CallerFromProcedures<TProcedures, TContext>;
2187
+ /**
2188
+ * Caller type from procedures (includes internal procedures).
2189
+ * Query procedures also have liveQuery() for server-side use.
2190
+ */
2191
+ type CallerFromProcedures<TProcedures extends Record<string, AnyProcedure<TContext>>, TContext = unknown> = { [K in keyof TProcedures]: TProcedures[K] extends {
2192
+ procedureType: "query";
2193
+ } ? {
2194
+ query: (input: InputOf<TProcedures[K]>, serverCtx: TContext) => Promise<OutputOf<TProcedures[K]>>;
2195
+ liveQuery: (input: InputOf<TProcedures[K]>, serverCtx: TContext) => Promise<LiveResult<OutputOf<TProcedures[K]>>>;
2196
+ runQuery: (input: InputOf<TProcedures[K]>, ctx: ParentCtx<TContext>) => Promise<OutputOf<TProcedures[K]>>;
2197
+ } : TProcedures[K] extends {
2198
+ procedureType: "mutation";
2199
+ } ? {
2200
+ mutate: (input: InputOf<TProcedures[K]>, serverCtx: TContext) => Promise<OutputOf<TProcedures[K]>>;
2201
+ runMutation: (input: InputOf<TProcedures[K]>, ctx: ParentCtx<TContext>) => Promise<OutputOf<TProcedures[K]>>;
2202
+ } : TProcedures[K] extends {
2203
+ procedureType: "action";
2204
+ } ? {
2205
+ action: (input: InputOf<TProcedures[K]>, serverCtx: TContext) => Promise<OutputOf<TProcedures[K]>>;
2206
+ } : TProcedures[K] extends {
2207
+ procedureType: "job";
2208
+ } ? {
2209
+ run: (input: InputOf<TProcedures[K]>, serverCtx: TContext) => Promise<OutputOf<TProcedures[K]>>;
2210
+ } : never } & {
2211
+ init: (config: {
2212
+ db: SupaliveDb;
2213
+ storage: ObjectStorage;
2214
+ scheduler: JobClient;
2215
+ }) => Promise<void>;
2216
+ };
2217
+ /**
2218
+ * Caller type from router.
2219
+ */
2220
+ type CallerFromRouter<TRouter extends Router<any, any>> = CallerFromProcedures<TRouter["procedures"]>;
2221
+ //#endregion
2222
+ export { ProcedureNames as $, AffectedSubscription as $n, WriteEntry as $r, TxContext as $t, ResponseMessageSchema as A, ReturnQuery as An, OccConflictError as Ar, patchZod as At, SubscriptionUpdateMessageSchema as B, trackSchema as Bn, QueryCacheMetadataSchema as Br, ScheduleHandle as Bt, ClientMessageSchema as C, InsertData as Cn, DEFAULT_RETRY as Cr, QueryFn as Ct, ErrorMessage as D, Prettify as Dn, MutationResult as Dr, createJobBuilder as Dt, Context as E, OverrideField as En, LiveResult as Er, createActionBuilder as Et, SubscribeMessage as F, StoredSchemaColumnsOptions as Fn, Predicate as Fr, IncomingJobRequest as Ft, RPCError as G, DbType as Gn, RawPointReadSchema as Gr, DefsToMap as Gt, UnsubscribeMessageSchema as H, CoreInitLockCtx as Hn, RangeRead as Hr, SupaliveDb as Ht, SubscribeMessageSchema as I, defineComputedField as In, PredicateSchema as Ir, JobClient as It, ActionProcedures as J, PreparedQueries as Jn, RawReadEntry as Jr, ResultOf as Jt, WSClientOptions as K, LazyCommitTsParam as Kn, RawRangeRead as Kr, ParamsOf as Kt, SubscriptionGoneMessage as L, defineSchema as Ln, QueryCacheEntry as Lr, JobScheduler as Lt, ServerMessageSchema as M, SchemaColumnMapping as Mn, OrPredicateSchema as Mr, DevScheduler as Mt, ServerPingMessage as N, SchemaColumnsOptions as Nn, PointRead as Nr, DevSchedulerOptions as Nt, IsInternal as O, QueryArgs as On, NO_RETRY as Or, createMutationBuilder as Ot, ServerPingMessageSchema as P, SchemaDefinition as Pn, PointReadSchema as Pr, EnqueueOptions as Pt, MutationProcedures as Q, CacheLayer as Qn, RetryConfig as Qr, DbWriter as Qt, SubscriptionGoneMessageSchema as R, schemaRegistry as Rn, QueryCacheEntrySchema as Rr, QStashScheduler as Rt, ClientMessage as S, InferSchema as Sn, CompareOperatorSchema as Sr, QueryCtx as St, ConnectedMessageSchema as T, MutationArgs as Tn, LeafPredicateSchema as Tr, TypeOf as Tt, ClientPublicState as U, Database as Un, RangeReadSchema as Ur, sleep as Ut, UnsubscribeMessage as V, tableNameToId as Vn, QuerySpec as Vr, ScheduledJobDef as Vt, HeartbeatOptions as W, DbQueryResult as Wn, RawPointRead as Wr, AnyQueryDef as Wt, ContextRegistry as X, SqlBuilder as Xn, ReadEntry as Xr, defineQuery as Xt, AppRouter as Y, RawClient as Yn, RawReadEntrySchema as Yr, _resetGlobalDefs as Yt, JobProcedures as Z, TxDatabase as Zn, ReadEntrySchema as Zr, DbReader as Zt, AuthSuccessMessage as _, ComputedField as _n, CachedPgMetadata as _r, MutationCtx as _t, CallOptions as a, normalizeToBytes as ai, OrderDirection as an, RegisterSubscriptionResult as ar, router as at, CallMessage as b, DefineSchemaConfig as bn, CommitTs as br, OutputOf as bt, LiveQueryHandle as c, buildPredicateSql as cn, UnregisterSubscriptionResult as cr, ActionFn as ct, WSClientMethods as d, jsonPathExtract as dn, UpdateSubscriptionReadSetParams as dr, ContextOf as dt, WriteEntrySchema as ei, IdAndCommitTs as en, InvalidateWritesetParams as er, PublicProcedures as et, createClient as f, matchesPredicate as fn, UpdateSubscriptionReadSetParamsSchema as fr, JobConfig as ft, AuthMessageSchema as g, ComputedDataType as gn, BigIntSchema as gr, MutationConfig as gt, AuthMessage as h, ComputedCodec as hn, AndPredicateSchema as hr, JobProcedure as ht, createCaller as i, normalizeIdToBytes as ii, OrderByOptions as in, RegisterSubscriptionParamsSchema as ir, getContextRegistry as it, ServerMessage as j, SchemaCodecs as jn, OrPredicate as jr, z$2 as jt, ResponseMessage as k, ReturnLiveQuery as kn, OccAbortError as kr, createQueryBuilder as kt, LiveQueryState as l, jsonContains as ln, UnregisterSubscriptionsParams as lr, ActionProcedure as lt, AuthFailedMessageSchema as m, ColumnCodec as mn, AndPredicate as mr, JobFn as mt, CallerFromRouter as n, WriteOpSchema as ni, JsonHasKeyMultiOptions as nn, InvalidateWritesetResult as nr, RegisteredProcedure as nt, ClientFromProcedures as o, PaginationClause as on, UnregisterSubscriptionParams as or, ActionConfig as ot, AuthFailedMessage as p, ActionArgs as pn, UpdateSubscriptionReadSetResult as pr, JobCtx as pt, WsClientManager as q, PooledClient as qn, RawRangeReadSchema as qr, QueryDefinition as qt, CallerOptions as r, bytesFromJson as ri, JsonOpOptions as rn, RegisterSubscriptionParams as rr, Router as rt, ClientOptions as s, QueryBuilder as sn, UnregisterSubscriptionParamsSchema as sr, ActionCtx as st, CallerFromProcedures as t, WriteOp as ti, JsonContainsOptions as tn, InvalidateWritesetParamsSchema as tr, QueryProcedures as tt, LiveQueryStatus as u, jsonPathExists as un, UnregisterSubscriptionsResult as ur, AnyProcedure as ut, AuthSuccessMessageSchema as v, ComputedFieldConfig as vn, CachedPgMetadataSchema as vr, MutationFn as vt, ConnectedMessage as w, Model as wn, LeafPredicate as wr, QueryProcedure as wt, CallMessageSchema as x, IndexDefinition as xn, CompareOperator as xr, QueryConfig as xt, AuthenticationError as y, DeclarativeIndex as yn, CommitLogEntry as yr, MutationProcedure as yt, SubscriptionUpdateMessage as z, shouldTrackSchema as zn, QueryCacheMetadata as zr, QStashSchedulerOptions as zt };
2223
+ //# sourceMappingURL=index-j3YTMNlF.d.ts.map