ponder-with-flashblocks 0.16.3

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 (614) hide show
  1. package/CHANGELOG.md +3427 -0
  2. package/README.md +186 -0
  3. package/dist/esm/bin/commands/codegen.js +46 -0
  4. package/dist/esm/bin/commands/codegen.js.map +1 -0
  5. package/dist/esm/bin/commands/createViews.js +196 -0
  6. package/dist/esm/bin/commands/createViews.js.map +1 -0
  7. package/dist/esm/bin/commands/dev.js +430 -0
  8. package/dist/esm/bin/commands/dev.js.map +1 -0
  9. package/dist/esm/bin/commands/list.js +148 -0
  10. package/dist/esm/bin/commands/list.js.map +1 -0
  11. package/dist/esm/bin/commands/prune.js +223 -0
  12. package/dist/esm/bin/commands/prune.js.map +1 -0
  13. package/dist/esm/bin/commands/serve.js +198 -0
  14. package/dist/esm/bin/commands/serve.js.map +1 -0
  15. package/dist/esm/bin/commands/start.js +253 -0
  16. package/dist/esm/bin/commands/start.js.map +1 -0
  17. package/dist/esm/bin/isolatedController.js +200 -0
  18. package/dist/esm/bin/isolatedController.js.map +1 -0
  19. package/dist/esm/bin/isolatedWorker.js +146 -0
  20. package/dist/esm/bin/isolatedWorker.js.map +1 -0
  21. package/dist/esm/bin/ponder.js +137 -0
  22. package/dist/esm/bin/ponder.js.map +1 -0
  23. package/dist/esm/bin/utils/codegen.js +25 -0
  24. package/dist/esm/bin/utils/codegen.js.map +1 -0
  25. package/dist/esm/bin/utils/exit.js +100 -0
  26. package/dist/esm/bin/utils/exit.js.map +1 -0
  27. package/dist/esm/build/config.js +746 -0
  28. package/dist/esm/build/config.js.map +1 -0
  29. package/dist/esm/build/factory.js +76 -0
  30. package/dist/esm/build/factory.js.map +1 -0
  31. package/dist/esm/build/index.js +567 -0
  32. package/dist/esm/build/index.js.map +1 -0
  33. package/dist/esm/build/plugin.js +53 -0
  34. package/dist/esm/build/plugin.js.map +1 -0
  35. package/dist/esm/build/pre.js +83 -0
  36. package/dist/esm/build/pre.js.map +1 -0
  37. package/dist/esm/build/schema.js +202 -0
  38. package/dist/esm/build/schema.js.map +1 -0
  39. package/dist/esm/build/stacktrace.js +137 -0
  40. package/dist/esm/build/stacktrace.js.map +1 -0
  41. package/dist/esm/client/index.js +441 -0
  42. package/dist/esm/client/index.js.map +1 -0
  43. package/dist/esm/config/address.js +2 -0
  44. package/dist/esm/config/address.js.map +1 -0
  45. package/dist/esm/config/eventFilter.js +2 -0
  46. package/dist/esm/config/eventFilter.js.map +1 -0
  47. package/dist/esm/config/index.js +2 -0
  48. package/dist/esm/config/index.js.map +1 -0
  49. package/dist/esm/config/utilityTypes.js +2 -0
  50. package/dist/esm/config/utilityTypes.js.map +1 -0
  51. package/dist/esm/database/actions.js +445 -0
  52. package/dist/esm/database/actions.js.map +1 -0
  53. package/dist/esm/database/index.js +604 -0
  54. package/dist/esm/database/index.js.map +1 -0
  55. package/dist/esm/database/queryBuilder.js +314 -0
  56. package/dist/esm/database/queryBuilder.js.map +1 -0
  57. package/dist/esm/drizzle/bigint.js +38 -0
  58. package/dist/esm/drizzle/bigint.js.map +1 -0
  59. package/dist/esm/drizzle/bytes.js +47 -0
  60. package/dist/esm/drizzle/bytes.js.map +1 -0
  61. package/dist/esm/drizzle/hex.js +40 -0
  62. package/dist/esm/drizzle/hex.js.map +1 -0
  63. package/dist/esm/drizzle/index.js +28 -0
  64. package/dist/esm/drizzle/index.js.map +1 -0
  65. package/dist/esm/drizzle/json.js +123 -0
  66. package/dist/esm/drizzle/json.js.map +1 -0
  67. package/dist/esm/drizzle/kit/index.js +927 -0
  68. package/dist/esm/drizzle/kit/index.js.map +1 -0
  69. package/dist/esm/drizzle/onchain.js +184 -0
  70. package/dist/esm/drizzle/onchain.js.map +1 -0
  71. package/dist/esm/drizzle/text.js +61 -0
  72. package/dist/esm/drizzle/text.js.map +1 -0
  73. package/dist/esm/graphql/graphiql.html.js +59 -0
  74. package/dist/esm/graphql/graphiql.html.js.map +1 -0
  75. package/dist/esm/graphql/index.js +934 -0
  76. package/dist/esm/graphql/index.js.map +1 -0
  77. package/dist/esm/graphql/json.js +42 -0
  78. package/dist/esm/graphql/json.js.map +1 -0
  79. package/dist/esm/graphql/middleware.js +83 -0
  80. package/dist/esm/graphql/middleware.js.map +1 -0
  81. package/dist/esm/index.js +9 -0
  82. package/dist/esm/index.js.map +1 -0
  83. package/dist/esm/indexing/addStackTrace.js +54 -0
  84. package/dist/esm/indexing/addStackTrace.js.map +1 -0
  85. package/dist/esm/indexing/client.js +675 -0
  86. package/dist/esm/indexing/client.js.map +1 -0
  87. package/dist/esm/indexing/index.js +663 -0
  88. package/dist/esm/indexing/index.js.map +1 -0
  89. package/dist/esm/indexing/profile.js +584 -0
  90. package/dist/esm/indexing/profile.js.map +1 -0
  91. package/dist/esm/indexing-store/cache.js +666 -0
  92. package/dist/esm/indexing-store/cache.js.map +1 -0
  93. package/dist/esm/indexing-store/index.js +461 -0
  94. package/dist/esm/indexing-store/index.js.map +1 -0
  95. package/dist/esm/indexing-store/profile.js +428 -0
  96. package/dist/esm/indexing-store/profile.js.map +1 -0
  97. package/dist/esm/indexing-store/utils.js +111 -0
  98. package/dist/esm/indexing-store/utils.js.map +1 -0
  99. package/dist/esm/internal/common.js +2 -0
  100. package/dist/esm/internal/common.js.map +1 -0
  101. package/dist/esm/internal/errors.js +300 -0
  102. package/dist/esm/internal/errors.js.map +1 -0
  103. package/dist/esm/internal/logger.js +178 -0
  104. package/dist/esm/internal/logger.js.map +1 -0
  105. package/dist/esm/internal/metrics.js +1049 -0
  106. package/dist/esm/internal/metrics.js.map +1 -0
  107. package/dist/esm/internal/options.js +73 -0
  108. package/dist/esm/internal/options.js.map +1 -0
  109. package/dist/esm/internal/shutdown.js +24 -0
  110. package/dist/esm/internal/shutdown.js.map +1 -0
  111. package/dist/esm/internal/telemetry.js +200 -0
  112. package/dist/esm/internal/telemetry.js.map +1 -0
  113. package/dist/esm/internal/types.js +2 -0
  114. package/dist/esm/internal/types.js.map +1 -0
  115. package/dist/esm/rpc/actions.js +988 -0
  116. package/dist/esm/rpc/actions.js.map +1 -0
  117. package/dist/esm/rpc/http.js +130 -0
  118. package/dist/esm/rpc/http.js.map +1 -0
  119. package/dist/esm/rpc/index.js +751 -0
  120. package/dist/esm/rpc/index.js.map +1 -0
  121. package/dist/esm/runtime/events.js +664 -0
  122. package/dist/esm/runtime/events.js.map +1 -0
  123. package/dist/esm/runtime/filter.js +443 -0
  124. package/dist/esm/runtime/filter.js.map +1 -0
  125. package/dist/esm/runtime/fragments.js +478 -0
  126. package/dist/esm/runtime/fragments.js.map +1 -0
  127. package/dist/esm/runtime/historical.js +950 -0
  128. package/dist/esm/runtime/historical.js.map +1 -0
  129. package/dist/esm/runtime/index.js +316 -0
  130. package/dist/esm/runtime/index.js.map +1 -0
  131. package/dist/esm/runtime/isolated.js +463 -0
  132. package/dist/esm/runtime/isolated.js.map +1 -0
  133. package/dist/esm/runtime/multichain.js +510 -0
  134. package/dist/esm/runtime/multichain.js.map +1 -0
  135. package/dist/esm/runtime/omnichain.js +545 -0
  136. package/dist/esm/runtime/omnichain.js.map +1 -0
  137. package/dist/esm/runtime/realtime.js +724 -0
  138. package/dist/esm/runtime/realtime.js.map +1 -0
  139. package/dist/esm/server/error.js +56 -0
  140. package/dist/esm/server/error.js.map +1 -0
  141. package/dist/esm/server/index.js +121 -0
  142. package/dist/esm/server/index.js.map +1 -0
  143. package/dist/esm/sync-historical/index.js +711 -0
  144. package/dist/esm/sync-historical/index.js.map +1 -0
  145. package/dist/esm/sync-realtime/bloom.js +76 -0
  146. package/dist/esm/sync-realtime/bloom.js.map +1 -0
  147. package/dist/esm/sync-realtime/index.js +928 -0
  148. package/dist/esm/sync-realtime/index.js.map +1 -0
  149. package/dist/esm/sync-store/encode.js +105 -0
  150. package/dist/esm/sync-store/encode.js.map +1 -0
  151. package/dist/esm/sync-store/index.js +885 -0
  152. package/dist/esm/sync-store/index.js.map +1 -0
  153. package/dist/esm/sync-store/migrations.js +1595 -0
  154. package/dist/esm/sync-store/migrations.js.map +1 -0
  155. package/dist/esm/sync-store/schema.js +181 -0
  156. package/dist/esm/sync-store/schema.js.map +1 -0
  157. package/dist/esm/types/db.js +2 -0
  158. package/dist/esm/types/db.js.map +1 -0
  159. package/dist/esm/types/eth.js +2 -0
  160. package/dist/esm/types/eth.js.map +1 -0
  161. package/dist/esm/types/utils.js +2 -0
  162. package/dist/esm/types/utils.js.map +1 -0
  163. package/dist/esm/types/virtual.js +2 -0
  164. package/dist/esm/types/virtual.js.map +1 -0
  165. package/dist/esm/ui/app.js +157 -0
  166. package/dist/esm/ui/app.js.map +1 -0
  167. package/dist/esm/ui/index.js +29 -0
  168. package/dist/esm/ui/index.js.map +1 -0
  169. package/dist/esm/ui/patch.js +140 -0
  170. package/dist/esm/ui/patch.js.map +1 -0
  171. package/dist/esm/utils/abi.js +55 -0
  172. package/dist/esm/utils/abi.js.map +1 -0
  173. package/dist/esm/utils/bigint.js +37 -0
  174. package/dist/esm/utils/bigint.js.map +1 -0
  175. package/dist/esm/utils/chains.js +21 -0
  176. package/dist/esm/utils/chains.js.map +1 -0
  177. package/dist/esm/utils/checkpoint.js +139 -0
  178. package/dist/esm/utils/checkpoint.js.map +1 -0
  179. package/dist/esm/utils/chunk.js +8 -0
  180. package/dist/esm/utils/chunk.js.map +1 -0
  181. package/dist/esm/utils/copy.js +129 -0
  182. package/dist/esm/utils/copy.js.map +1 -0
  183. package/dist/esm/utils/date.js +27 -0
  184. package/dist/esm/utils/date.js.map +1 -0
  185. package/dist/esm/utils/debug.js +2 -0
  186. package/dist/esm/utils/debug.js.map +1 -0
  187. package/dist/esm/utils/decodeAbiParameters.js +290 -0
  188. package/dist/esm/utils/decodeAbiParameters.js.map +1 -0
  189. package/dist/esm/utils/decodeEventLog.js +75 -0
  190. package/dist/esm/utils/decodeEventLog.js.map +1 -0
  191. package/dist/esm/utils/dedupe.js +29 -0
  192. package/dist/esm/utils/dedupe.js.map +1 -0
  193. package/dist/esm/utils/duplicates.js +19 -0
  194. package/dist/esm/utils/duplicates.js.map +1 -0
  195. package/dist/esm/utils/estimate.js +6 -0
  196. package/dist/esm/utils/estimate.js.map +1 -0
  197. package/dist/esm/utils/finality.js +38 -0
  198. package/dist/esm/utils/finality.js.map +1 -0
  199. package/dist/esm/utils/format.js +20 -0
  200. package/dist/esm/utils/format.js.map +1 -0
  201. package/dist/esm/utils/generators.js +121 -0
  202. package/dist/esm/utils/generators.js.map +1 -0
  203. package/dist/esm/utils/hash.js +11 -0
  204. package/dist/esm/utils/hash.js.map +1 -0
  205. package/dist/esm/utils/interval.js +171 -0
  206. package/dist/esm/utils/interval.js.map +1 -0
  207. package/dist/esm/utils/lowercase.js +7 -0
  208. package/dist/esm/utils/lowercase.js.map +1 -0
  209. package/dist/esm/utils/mutex.js +26 -0
  210. package/dist/esm/utils/mutex.js.map +1 -0
  211. package/dist/esm/utils/never.js +4 -0
  212. package/dist/esm/utils/never.js.map +1 -0
  213. package/dist/esm/utils/offset.js +101 -0
  214. package/dist/esm/utils/offset.js.map +1 -0
  215. package/dist/esm/utils/order.js +18 -0
  216. package/dist/esm/utils/order.js.map +1 -0
  217. package/dist/esm/utils/partition.js +46 -0
  218. package/dist/esm/utils/partition.js.map +1 -0
  219. package/dist/esm/utils/pg.js +175 -0
  220. package/dist/esm/utils/pg.js.map +1 -0
  221. package/dist/esm/utils/pglite.js +80 -0
  222. package/dist/esm/utils/pglite.js.map +1 -0
  223. package/dist/esm/utils/port.js +30 -0
  224. package/dist/esm/utils/port.js.map +1 -0
  225. package/dist/esm/utils/print.js +23 -0
  226. package/dist/esm/utils/print.js.map +1 -0
  227. package/dist/esm/utils/promiseAllSettledWithThrow.js +19 -0
  228. package/dist/esm/utils/promiseAllSettledWithThrow.js.map +1 -0
  229. package/dist/esm/utils/promiseWithResolvers.js +13 -0
  230. package/dist/esm/utils/promiseWithResolvers.js.map +1 -0
  231. package/dist/esm/utils/queue.js +150 -0
  232. package/dist/esm/utils/queue.js.map +1 -0
  233. package/dist/esm/utils/range.js +8 -0
  234. package/dist/esm/utils/range.js.map +1 -0
  235. package/dist/esm/utils/result.js +10 -0
  236. package/dist/esm/utils/result.js.map +1 -0
  237. package/dist/esm/utils/sql-parse.js +1326 -0
  238. package/dist/esm/utils/sql-parse.js.map +1 -0
  239. package/dist/esm/utils/timer.js +9 -0
  240. package/dist/esm/utils/timer.js.map +1 -0
  241. package/dist/esm/utils/truncate.js +15 -0
  242. package/dist/esm/utils/truncate.js.map +1 -0
  243. package/dist/esm/utils/wait.js +10 -0
  244. package/dist/esm/utils/wait.js.map +1 -0
  245. package/dist/esm/utils/zipper.js +67 -0
  246. package/dist/esm/utils/zipper.js.map +1 -0
  247. package/dist/types/bin/commands/codegen.d.ts +5 -0
  248. package/dist/types/bin/commands/codegen.d.ts.map +1 -0
  249. package/dist/types/bin/commands/createViews.d.ts +8 -0
  250. package/dist/types/bin/commands/createViews.d.ts.map +1 -0
  251. package/dist/types/bin/commands/dev.d.ts +5 -0
  252. package/dist/types/bin/commands/dev.d.ts.map +1 -0
  253. package/dist/types/bin/commands/list.d.ts +5 -0
  254. package/dist/types/bin/commands/list.d.ts.map +1 -0
  255. package/dist/types/bin/commands/prune.d.ts +5 -0
  256. package/dist/types/bin/commands/prune.d.ts.map +1 -0
  257. package/dist/types/bin/commands/serve.d.ts +5 -0
  258. package/dist/types/bin/commands/serve.d.ts.map +1 -0
  259. package/dist/types/bin/commands/start.d.ts +19 -0
  260. package/dist/types/bin/commands/start.d.ts.map +1 -0
  261. package/dist/types/bin/isolatedController.d.ts +13 -0
  262. package/dist/types/bin/isolatedController.d.ts.map +1 -0
  263. package/dist/types/bin/isolatedWorker.d.ts +9 -0
  264. package/dist/types/bin/isolatedWorker.d.ts.map +1 -0
  265. package/dist/types/bin/ponder.d.ts +37 -0
  266. package/dist/types/bin/ponder.d.ts.map +1 -0
  267. package/dist/types/bin/utils/codegen.d.ts +6 -0
  268. package/dist/types/bin/utils/codegen.d.ts.map +1 -0
  269. package/dist/types/bin/utils/exit.d.ts +10 -0
  270. package/dist/types/bin/utils/exit.d.ts.map +1 -0
  271. package/dist/types/build/config.d.ts +97 -0
  272. package/dist/types/build/config.d.ts.map +1 -0
  273. package/dist/types/build/factory.d.ts +13 -0
  274. package/dist/types/build/factory.d.ts.map +1 -0
  275. package/dist/types/build/index.d.ts +84 -0
  276. package/dist/types/build/index.d.ts.map +1 -0
  277. package/dist/types/build/plugin.d.ts +4 -0
  278. package/dist/types/build/plugin.d.ts.map +1 -0
  279. package/dist/types/build/pre.d.ts +29 -0
  280. package/dist/types/build/pre.d.ts.map +1 -0
  281. package/dist/types/build/schema.d.ts +20 -0
  282. package/dist/types/build/schema.d.ts.map +1 -0
  283. package/dist/types/build/stacktrace.d.ts +13 -0
  284. package/dist/types/build/stacktrace.d.ts.map +1 -0
  285. package/dist/types/client/index.d.ts +27 -0
  286. package/dist/types/client/index.d.ts.map +1 -0
  287. package/dist/types/config/address.d.ts +24 -0
  288. package/dist/types/config/address.d.ts.map +1 -0
  289. package/dist/types/config/eventFilter.d.ts +18 -0
  290. package/dist/types/config/eventFilter.d.ts.map +1 -0
  291. package/dist/types/config/index.d.ts +150 -0
  292. package/dist/types/config/index.d.ts.map +1 -0
  293. package/dist/types/config/utilityTypes.d.ts +43 -0
  294. package/dist/types/config/utilityTypes.d.ts.map +1 -0
  295. package/dist/types/database/actions.d.ts +99 -0
  296. package/dist/types/database/actions.d.ts.map +1 -0
  297. package/dist/types/database/index.d.ts +493 -0
  298. package/dist/types/database/index.d.ts.map +1 -0
  299. package/dist/types/database/queryBuilder.d.ts +65 -0
  300. package/dist/types/database/queryBuilder.d.ts.map +1 -0
  301. package/dist/types/drizzle/bigint.d.ts +25 -0
  302. package/dist/types/drizzle/bigint.d.ts.map +1 -0
  303. package/dist/types/drizzle/bytes.d.ts +31 -0
  304. package/dist/types/drizzle/bytes.d.ts.map +1 -0
  305. package/dist/types/drizzle/hex.d.ts +25 -0
  306. package/dist/types/drizzle/hex.d.ts.map +1 -0
  307. package/dist/types/drizzle/index.d.ts +6 -0
  308. package/dist/types/drizzle/index.d.ts.map +1 -0
  309. package/dist/types/drizzle/json.d.ts +51 -0
  310. package/dist/types/drizzle/json.d.ts.map +1 -0
  311. package/dist/types/drizzle/kit/index.d.ts +187 -0
  312. package/dist/types/drizzle/kit/index.d.ts.map +1 -0
  313. package/dist/types/drizzle/onchain.d.ts +298 -0
  314. package/dist/types/drizzle/onchain.d.ts.map +1 -0
  315. package/dist/types/drizzle/text.d.ts +29 -0
  316. package/dist/types/drizzle/text.d.ts.map +1 -0
  317. package/dist/types/graphql/graphiql.html.d.ts +2 -0
  318. package/dist/types/graphql/graphiql.html.d.ts.map +1 -0
  319. package/dist/types/graphql/index.d.ts +12 -0
  320. package/dist/types/graphql/index.d.ts.map +1 -0
  321. package/dist/types/graphql/json.d.ts +3 -0
  322. package/dist/types/graphql/json.d.ts.map +1 -0
  323. package/dist/types/graphql/middleware.d.ts +29 -0
  324. package/dist/types/graphql/middleware.d.ts.map +1 -0
  325. package/dist/types/index.d.ts +23 -0
  326. package/dist/types/index.d.ts.map +1 -0
  327. package/dist/types/indexing/addStackTrace.d.ts +3 -0
  328. package/dist/types/indexing/addStackTrace.d.ts.map +1 -0
  329. package/dist/types/indexing/client.d.ts +154 -0
  330. package/dist/types/indexing/client.d.ts.map +1 -0
  331. package/dist/types/indexing/index.d.ts +72 -0
  332. package/dist/types/indexing/index.d.ts.map +1 -0
  333. package/dist/types/indexing/profile.d.ts +16 -0
  334. package/dist/types/indexing/profile.d.ts.map +1 -0
  335. package/dist/types/indexing-store/cache.d.ts +115 -0
  336. package/dist/types/indexing-store/cache.d.ts.map +1 -0
  337. package/dist/types/indexing-store/index.d.ts +24 -0
  338. package/dist/types/indexing-store/index.d.ts.map +1 -0
  339. package/dist/types/indexing-store/profile.d.ts +7 -0
  340. package/dist/types/indexing-store/profile.d.ts.map +1 -0
  341. package/dist/types/indexing-store/utils.d.ts +19 -0
  342. package/dist/types/indexing-store/utils.d.ts.map +1 -0
  343. package/dist/types/internal/common.d.ts +15 -0
  344. package/dist/types/internal/common.d.ts.map +1 -0
  345. package/dist/types/internal/errors.d.ts +101 -0
  346. package/dist/types/internal/errors.d.ts.map +1 -0
  347. package/dist/types/internal/logger.d.ts +37 -0
  348. package/dist/types/internal/logger.d.ts.map +1 -0
  349. package/dist/types/internal/metrics.d.ts +120 -0
  350. package/dist/types/internal/metrics.d.ts.map +1 -0
  351. package/dist/types/internal/options.d.ts +62 -0
  352. package/dist/types/internal/options.d.ts.map +1 -0
  353. package/dist/types/internal/shutdown.d.ts +8 -0
  354. package/dist/types/internal/shutdown.d.ts.map +1 -0
  355. package/dist/types/internal/telemetry.d.ts +43 -0
  356. package/dist/types/internal/telemetry.d.ts.map +1 -0
  357. package/dist/types/internal/types.d.ts +434 -0
  358. package/dist/types/internal/types.d.ts.map +1 -0
  359. package/dist/types/rpc/actions.d.ts +360 -0
  360. package/dist/types/rpc/actions.d.ts.map +1 -0
  361. package/dist/types/rpc/http.d.ts +17 -0
  362. package/dist/types/rpc/http.d.ts.map +1 -0
  363. package/dist/types/rpc/index.d.ts +43 -0
  364. package/dist/types/rpc/index.d.ts.map +1 -0
  365. package/dist/types/runtime/events.d.ts +40 -0
  366. package/dist/types/runtime/events.d.ts.map +1 -0
  367. package/dist/types/runtime/filter.d.ts +87 -0
  368. package/dist/types/runtime/filter.d.ts.map +1 -0
  369. package/dist/types/runtime/fragments.d.ts +30 -0
  370. package/dist/types/runtime/fragments.d.ts.map +1 -0
  371. package/dist/types/runtime/historical.d.ts +123 -0
  372. package/dist/types/runtime/historical.d.ts.map +1 -0
  373. package/dist/types/runtime/index.d.ts +89 -0
  374. package/dist/types/runtime/index.d.ts.map +1 -0
  375. package/dist/types/runtime/isolated.d.ts +14 -0
  376. package/dist/types/runtime/isolated.d.ts.map +1 -0
  377. package/dist/types/runtime/multichain.d.ts +13 -0
  378. package/dist/types/runtime/multichain.d.ts.map +1 -0
  379. package/dist/types/runtime/omnichain.d.ts +23 -0
  380. package/dist/types/runtime/omnichain.d.ts.map +1 -0
  381. package/dist/types/runtime/realtime.d.ts +93 -0
  382. package/dist/types/runtime/realtime.d.ts.map +1 -0
  383. package/dist/types/server/error.d.ts +5 -0
  384. package/dist/types/server/error.d.ts.map +1 -0
  385. package/dist/types/server/index.d.ts +13 -0
  386. package/dist/types/server/index.d.ts.map +1 -0
  387. package/dist/types/sync-historical/index.d.ts +36 -0
  388. package/dist/types/sync-historical/index.d.ts.map +1 -0
  389. package/dist/types/sync-realtime/bloom.d.ts +18 -0
  390. package/dist/types/sync-realtime/bloom.d.ts.map +1 -0
  391. package/dist/types/sync-realtime/index.d.ts +47 -0
  392. package/dist/types/sync-realtime/index.d.ts.map +1 -0
  393. package/dist/types/sync-store/encode.d.ts +25 -0
  394. package/dist/types/sync-store/encode.d.ts.map +1 -0
  395. package/dist/types/sync-store/index.d.ts +135 -0
  396. package/dist/types/sync-store/index.d.ts.map +1 -0
  397. package/dist/types/sync-store/migrations.d.ts +8 -0
  398. package/dist/types/sync-store/migrations.d.ts.map +1 -0
  399. package/dist/types/sync-store/schema.d.ts +1828 -0
  400. package/dist/types/sync-store/schema.d.ts.map +1 -0
  401. package/dist/types/types/db.d.ts +213 -0
  402. package/dist/types/types/db.d.ts.map +1 -0
  403. package/dist/types/types/eth.d.ts +196 -0
  404. package/dist/types/types/eth.d.ts.map +1 -0
  405. package/dist/types/types/utils.d.ts +38 -0
  406. package/dist/types/types/utils.d.ts.map +1 -0
  407. package/dist/types/types/virtual.d.ts +99 -0
  408. package/dist/types/types/virtual.d.ts.map +1 -0
  409. package/dist/types/ui/app.d.ts +22 -0
  410. package/dist/types/ui/app.d.ts.map +1 -0
  411. package/dist/types/ui/index.d.ts +5 -0
  412. package/dist/types/ui/index.d.ts.map +1 -0
  413. package/dist/types/ui/patch.d.ts +7 -0
  414. package/dist/types/ui/patch.d.ts.map +1 -0
  415. package/dist/types/utils/abi.d.ts +23 -0
  416. package/dist/types/utils/abi.d.ts.map +1 -0
  417. package/dist/types/utils/bigint.d.ts +15 -0
  418. package/dist/types/utils/bigint.d.ts.map +1 -0
  419. package/dist/types/utils/chains.d.ts +42 -0
  420. package/dist/types/utils/chains.d.ts.map +1 -0
  421. package/dist/types/utils/checkpoint.d.ts +52 -0
  422. package/dist/types/utils/checkpoint.d.ts.map +1 -0
  423. package/dist/types/utils/chunk.d.ts +2 -0
  424. package/dist/types/utils/chunk.d.ts.map +1 -0
  425. package/dist/types/utils/copy.d.ts +16 -0
  426. package/dist/types/utils/copy.d.ts.map +1 -0
  427. package/dist/types/utils/date.d.ts +7 -0
  428. package/dist/types/utils/date.d.ts.map +1 -0
  429. package/dist/types/utils/debug.d.ts +105 -0
  430. package/dist/types/utils/debug.d.ts.map +1 -0
  431. package/dist/types/utils/decodeAbiParameters.d.ts +28 -0
  432. package/dist/types/utils/decodeAbiParameters.d.ts.map +1 -0
  433. package/dist/types/utils/decodeEventLog.d.ts +12 -0
  434. package/dist/types/utils/decodeEventLog.d.ts.map +1 -0
  435. package/dist/types/utils/dedupe.d.ts +20 -0
  436. package/dist/types/utils/dedupe.d.ts.map +1 -0
  437. package/dist/types/utils/duplicates.d.ts +7 -0
  438. package/dist/types/utils/duplicates.d.ts.map +1 -0
  439. package/dist/types/utils/estimate.d.ts +11 -0
  440. package/dist/types/utils/estimate.d.ts.map +1 -0
  441. package/dist/types/utils/finality.d.ts +12 -0
  442. package/dist/types/utils/finality.d.ts.map +1 -0
  443. package/dist/types/utils/format.d.ts +3 -0
  444. package/dist/types/utils/format.d.ts.map +1 -0
  445. package/dist/types/utils/generators.d.ts +42 -0
  446. package/dist/types/utils/generators.d.ts.map +1 -0
  447. package/dist/types/utils/hash.d.ts +11 -0
  448. package/dist/types/utils/hash.d.ts.map +1 -0
  449. package/dist/types/utils/interval.d.ts +53 -0
  450. package/dist/types/utils/interval.d.ts.map +1 -0
  451. package/dist/types/utils/lowercase.d.ts +5 -0
  452. package/dist/types/utils/lowercase.d.ts.map +1 -0
  453. package/dist/types/utils/mutex.d.ts +5 -0
  454. package/dist/types/utils/mutex.d.ts.map +1 -0
  455. package/dist/types/utils/never.d.ts +2 -0
  456. package/dist/types/utils/never.d.ts.map +1 -0
  457. package/dist/types/utils/offset.d.ts +8 -0
  458. package/dist/types/utils/offset.d.ts.map +1 -0
  459. package/dist/types/utils/order.d.ts +2 -0
  460. package/dist/types/utils/order.d.ts.map +1 -0
  461. package/dist/types/utils/partition.d.ts +22 -0
  462. package/dist/types/utils/partition.d.ts.map +1 -0
  463. package/dist/types/utils/pg.d.ts +8 -0
  464. package/dist/types/utils/pg.d.ts.map +1 -0
  465. package/dist/types/utils/pglite.d.ts +25 -0
  466. package/dist/types/utils/pglite.d.ts.map +1 -0
  467. package/dist/types/utils/port.d.ts +5 -0
  468. package/dist/types/utils/port.d.ts.map +1 -0
  469. package/dist/types/utils/print.d.ts +2 -0
  470. package/dist/types/utils/print.d.ts.map +1 -0
  471. package/dist/types/utils/promiseAllSettledWithThrow.d.ts +8 -0
  472. package/dist/types/utils/promiseAllSettledWithThrow.d.ts.map +1 -0
  473. package/dist/types/utils/promiseWithResolvers.d.ts +10 -0
  474. package/dist/types/utils/promiseWithResolvers.d.ts.map +1 -0
  475. package/dist/types/utils/queue.d.ts +33 -0
  476. package/dist/types/utils/queue.d.ts.map +1 -0
  477. package/dist/types/utils/range.d.ts +8 -0
  478. package/dist/types/utils/range.d.ts.map +1 -0
  479. package/dist/types/utils/result.d.ts +17 -0
  480. package/dist/types/utils/result.d.ts.map +1 -0
  481. package/dist/types/utils/sql-parse.d.ts +21 -0
  482. package/dist/types/utils/sql-parse.d.ts.map +1 -0
  483. package/dist/types/utils/timer.d.ts +6 -0
  484. package/dist/types/utils/timer.d.ts.map +1 -0
  485. package/dist/types/utils/truncate.d.ts +9 -0
  486. package/dist/types/utils/truncate.d.ts.map +1 -0
  487. package/dist/types/utils/wait.d.ts +6 -0
  488. package/dist/types/utils/wait.d.ts.map +1 -0
  489. package/dist/types/utils/zipper.d.ts +36 -0
  490. package/dist/types/utils/zipper.d.ts.map +1 -0
  491. package/package.json +114 -0
  492. package/src/bin/commands/codegen.ts +56 -0
  493. package/src/bin/commands/createViews.ts +318 -0
  494. package/src/bin/commands/dev.ts +490 -0
  495. package/src/bin/commands/list.ts +208 -0
  496. package/src/bin/commands/prune.ts +322 -0
  497. package/src/bin/commands/serve.ts +236 -0
  498. package/src/bin/commands/start.ts +319 -0
  499. package/src/bin/isolatedController.ts +300 -0
  500. package/src/bin/isolatedWorker.ts +192 -0
  501. package/src/bin/ponder.ts +208 -0
  502. package/src/bin/utils/codegen.ts +32 -0
  503. package/src/bin/utils/exit.ts +112 -0
  504. package/src/build/config.ts +1142 -0
  505. package/src/build/factory.ts +122 -0
  506. package/src/build/index.ts +790 -0
  507. package/src/build/plugin.ts +58 -0
  508. package/src/build/pre.ts +114 -0
  509. package/src/build/schema.ts +358 -0
  510. package/src/build/stacktrace.ts +137 -0
  511. package/src/client/index.ts +551 -0
  512. package/src/config/address.ts +32 -0
  513. package/src/config/eventFilter.ts +33 -0
  514. package/src/config/index.ts +246 -0
  515. package/src/config/utilityTypes.ts +152 -0
  516. package/src/database/actions.ts +873 -0
  517. package/src/database/index.ts +1029 -0
  518. package/src/database/queryBuilder.ts +537 -0
  519. package/src/drizzle/bigint.ts +57 -0
  520. package/src/drizzle/bytes.ts +68 -0
  521. package/src/drizzle/hex.ts +58 -0
  522. package/src/drizzle/index.ts +40 -0
  523. package/src/drizzle/json.ts +159 -0
  524. package/src/drizzle/kit/index.ts +1348 -0
  525. package/src/drizzle/onchain.ts +476 -0
  526. package/src/drizzle/text.ts +77 -0
  527. package/src/graphql/graphiql.html.ts +59 -0
  528. package/src/graphql/index.ts +1351 -0
  529. package/src/graphql/json.ts +62 -0
  530. package/src/graphql/middleware.ts +115 -0
  531. package/src/index.ts +139 -0
  532. package/src/indexing/addStackTrace.ts +69 -0
  533. package/src/indexing/client.ts +1184 -0
  534. package/src/indexing/index.ts +976 -0
  535. package/src/indexing/profile.ts +771 -0
  536. package/src/indexing-store/cache.ts +1057 -0
  537. package/src/indexing-store/index.ts +628 -0
  538. package/src/indexing-store/profile.ts +557 -0
  539. package/src/indexing-store/utils.ts +162 -0
  540. package/src/internal/common.ts +15 -0
  541. package/src/internal/errors.ts +228 -0
  542. package/src/internal/logger.ts +252 -0
  543. package/src/internal/metrics.ts +1030 -0
  544. package/src/internal/options.ts +130 -0
  545. package/src/internal/shutdown.ts +32 -0
  546. package/src/internal/telemetry.ts +303 -0
  547. package/src/internal/types.ts +597 -0
  548. package/src/rpc/actions.ts +1344 -0
  549. package/src/rpc/http.ts +164 -0
  550. package/src/rpc/index.ts +961 -0
  551. package/src/runtime/events.ts +875 -0
  552. package/src/runtime/filter.ts +664 -0
  553. package/src/runtime/fragments.ts +674 -0
  554. package/src/runtime/historical.ts +1509 -0
  555. package/src/runtime/index.ts +569 -0
  556. package/src/runtime/isolated.ts +778 -0
  557. package/src/runtime/multichain.ts +860 -0
  558. package/src/runtime/omnichain.ts +920 -0
  559. package/src/runtime/realtime.ts +1166 -0
  560. package/src/server/error.ts +68 -0
  561. package/src/server/index.ts +173 -0
  562. package/src/sync-historical/index.ts +1072 -0
  563. package/src/sync-realtime/bloom.ts +102 -0
  564. package/src/sync-realtime/index.ts +1312 -0
  565. package/src/sync-store/encode.ts +153 -0
  566. package/src/sync-store/index.ts +1633 -0
  567. package/src/sync-store/migrations.ts +1801 -0
  568. package/src/sync-store/schema.ts +248 -0
  569. package/src/types/db.ts +292 -0
  570. package/src/types/eth.ts +216 -0
  571. package/src/types/utils.ts +47 -0
  572. package/src/types/virtual.ts +244 -0
  573. package/src/types.d.ts +38 -0
  574. package/src/ui/app.ts +207 -0
  575. package/src/ui/index.ts +37 -0
  576. package/src/ui/patch.ts +204 -0
  577. package/src/utils/abi.ts +103 -0
  578. package/src/utils/bigint.ts +41 -0
  579. package/src/utils/chains.ts +22 -0
  580. package/src/utils/checkpoint.ts +203 -0
  581. package/src/utils/chunk.ts +7 -0
  582. package/src/utils/copy.ts +151 -0
  583. package/src/utils/date.ts +26 -0
  584. package/src/utils/debug.ts +110 -0
  585. package/src/utils/decodeAbiParameters.ts +428 -0
  586. package/src/utils/decodeEventLog.ts +100 -0
  587. package/src/utils/dedupe.ts +32 -0
  588. package/src/utils/duplicates.ts +19 -0
  589. package/src/utils/estimate.ts +27 -0
  590. package/src/utils/finality.ts +40 -0
  591. package/src/utils/format.ts +22 -0
  592. package/src/utils/generators.ts +157 -0
  593. package/src/utils/hash.ts +22 -0
  594. package/src/utils/interval.ts +212 -0
  595. package/src/utils/lowercase.ts +6 -0
  596. package/src/utils/mutex.ts +33 -0
  597. package/src/utils/never.ts +3 -0
  598. package/src/utils/offset.ts +133 -0
  599. package/src/utils/order.ts +16 -0
  600. package/src/utils/partition.ts +53 -0
  601. package/src/utils/pg.ts +230 -0
  602. package/src/utils/pglite.ts +97 -0
  603. package/src/utils/port.ts +34 -0
  604. package/src/utils/print.ts +31 -0
  605. package/src/utils/promiseAllSettledWithThrow.ts +27 -0
  606. package/src/utils/promiseWithResolvers.ts +20 -0
  607. package/src/utils/queue.ts +258 -0
  608. package/src/utils/range.ts +8 -0
  609. package/src/utils/result.ts +26 -0
  610. package/src/utils/sql-parse.ts +1477 -0
  611. package/src/utils/timer.ts +8 -0
  612. package/src/utils/truncate.ts +15 -0
  613. package/src/utils/wait.ts +8 -0
  614. package/src/utils/zipper.ts +80 -0
@@ -0,0 +1,1326 @@
1
+ const getNodeType = (node) => Object.keys(node)[0];
2
+ const ALLOW_CACHE = new Map();
3
+ const RELATIONS_CACHE = new Map();
4
+ export const parseSQLQuery = async (sql) => {
5
+ // @ts-ignore
6
+ const Parser = await import(/* webpackIgnore: true */ "pg-query-emscripten");
7
+ if (sql.length > 5000) {
8
+ throw new Error("Invalid query");
9
+ }
10
+ const { parse } = await Parser.default();
11
+ const parseResult = parse(sql);
12
+ if (parseResult.error !== null) {
13
+ throw new Error(parseResult.error);
14
+ }
15
+ if (parseResult.parse_tree.stmts.length === 0) {
16
+ throw new Error("Invalid query");
17
+ }
18
+ if (parseResult.parse_tree.stmts.length > 1) {
19
+ throw new Error("Multiple statements not supported");
20
+ }
21
+ const stmt = parseResult.parse_tree.stmts[0];
22
+ if (stmt.stmt === undefined) {
23
+ throw new Error("Invalid query");
24
+ }
25
+ return stmt.stmt;
26
+ };
27
+ /**
28
+ * Validate a SQL query.
29
+ *
30
+ * @param sql - SQL query
31
+ */
32
+ export const validateAllowableSQLQuery = async (sql) => {
33
+ const crypto = await import(/* webpackIgnore: true */ "node:crypto");
34
+ const hash = crypto
35
+ .createHash("sha256")
36
+ .update(sql)
37
+ .digest("hex")
38
+ .slice(0, 10);
39
+ if (ALLOW_CACHE.has(hash)) {
40
+ const result = ALLOW_CACHE.get(hash);
41
+ ALLOW_CACHE.delete(hash);
42
+ ALLOW_CACHE.set(hash, result);
43
+ if (result)
44
+ return;
45
+ throw new Error("Invalid query");
46
+ }
47
+ let root;
48
+ try {
49
+ root = await parseSQLQuery(sql);
50
+ }
51
+ catch (error) {
52
+ ALLOW_CACHE.set(hash, false);
53
+ throw error;
54
+ }
55
+ const validate = (node) => {
56
+ if (ALLOW_LIST.has(getNodeType(node)) === false) {
57
+ throw new Error(`${getNodeType(node)} not supported`);
58
+ }
59
+ // @ts-ignore
60
+ ALLOW_LIST.get(getNodeType(node)).validate?.(node[getNodeType(node)]);
61
+ for (const child of ALLOW_LIST.get(getNodeType(node)).children(
62
+ // @ts-ignore
63
+ node[getNodeType(node)])) {
64
+ validate(child);
65
+ }
66
+ };
67
+ try {
68
+ validate(root);
69
+ }
70
+ catch (error) {
71
+ ALLOW_CACHE.set(hash, false);
72
+ throw error;
73
+ }
74
+ ALLOW_CACHE.set(hash, true);
75
+ if (ALLOW_CACHE.size > 1000000) {
76
+ const firstKey = ALLOW_CACHE.keys().next().value;
77
+ if (firstKey)
78
+ ALLOW_CACHE.delete(firstKey);
79
+ }
80
+ };
81
+ /**
82
+ * Return `true` if the SQL query is readonly, else `false`.
83
+ *
84
+ * @param sql - SQL query
85
+ */
86
+ export const isReadonlySQLQuery = async (sql) => {
87
+ let root;
88
+ try {
89
+ root = await parseSQLQuery(sql);
90
+ }
91
+ catch {
92
+ return false;
93
+ }
94
+ const validate = (node) => {
95
+ if (ALLOW_LIST.has(getNodeType(node)) === false) {
96
+ throw new Error(`${getNodeType(node)} not supported`);
97
+ }
98
+ for (const child of ALLOW_LIST.get(getNodeType(node)).children(
99
+ // @ts-ignore
100
+ node[getNodeType(node)])) {
101
+ validate(child);
102
+ }
103
+ };
104
+ try {
105
+ validate(root);
106
+ return true;
107
+ }
108
+ catch {
109
+ return false;
110
+ }
111
+ };
112
+ /**
113
+ * Find all referenced relations in a SQL query.
114
+ *
115
+ * @param sql - SQL query
116
+ */
117
+ export const getSQLQueryRelations = async (sql) => {
118
+ const crypto = await import(/* webpackIgnore: true */ "node:crypto");
119
+ if (sql.length > 5000) {
120
+ throw new Error("Invalid query");
121
+ }
122
+ const hash = crypto
123
+ .createHash("sha256")
124
+ .update(sql)
125
+ .digest("hex")
126
+ .slice(0, 10);
127
+ if (RELATIONS_CACHE.has(hash)) {
128
+ const result = RELATIONS_CACHE.get(hash);
129
+ RELATIONS_CACHE.delete(hash);
130
+ RELATIONS_CACHE.set(hash, result);
131
+ return result;
132
+ }
133
+ const root = await parseSQLQuery(sql);
134
+ const find = (node) => {
135
+ if (FIND_LIST.has(getNodeType(node)) === false) {
136
+ throw new Error(`${getNodeType(node)} not supported`);
137
+ }
138
+ if (getNodeType(node) === "RangeVar") {
139
+ const relation = node.RangeVar.relname;
140
+ if (relation)
141
+ relations.add(relation);
142
+ }
143
+ for (const child of FIND_LIST.get(getNodeType(node)).children(
144
+ // @ts-ignore
145
+ node[getNodeType(node)])) {
146
+ find(child);
147
+ }
148
+ };
149
+ const relations = new Set();
150
+ find(root);
151
+ RELATIONS_CACHE.set(hash, relations);
152
+ if (RELATIONS_CACHE.size > 1000000) {
153
+ const firstKey = RELATIONS_CACHE.keys().next().value;
154
+ if (firstKey)
155
+ RELATIONS_CACHE.delete(firstKey);
156
+ }
157
+ return relations;
158
+ };
159
+ // https://github.com/launchql/pgsql-parser/blob/f1df82ed4358e47c682e007bc5aa306b58f25514/packages/types/src/types.ts#L38
160
+ const INTEGER_VALIDATOR = {
161
+ node: "Integer",
162
+ children: () => [],
163
+ };
164
+ const FLOAT_VALIDATOR = {
165
+ node: "Float",
166
+ children: () => [],
167
+ };
168
+ const BOOLEAN_VALIDATOR = {
169
+ node: "Boolean",
170
+ children: () => [],
171
+ };
172
+ const STRING_VALIDATOR = {
173
+ node: "String",
174
+ children: () => [],
175
+ };
176
+ const BIT_STRING_VALIDATOR = {
177
+ node: "BitString",
178
+ children: () => [],
179
+ };
180
+ const LIST_VALIDATOR = {
181
+ node: "List",
182
+ children: (node) => [...(node.items ?? [])],
183
+ };
184
+ const OID_LIST_VALIDATOR = {
185
+ node: "OidList",
186
+ children: (node) => [...(node.items ?? [])],
187
+ };
188
+ const INT_LIST_VALIDATOR = {
189
+ node: "IntList",
190
+ children: (node) => [...(node.items ?? [])],
191
+ };
192
+ const A_CONST_VALIDATOR = {
193
+ node: "A_Const",
194
+ children: () => [],
195
+ };
196
+ const ALIAS_VALIDATOR = {
197
+ node: "Alias",
198
+ children: (node) => [...(node.colnames ?? [])],
199
+ };
200
+ const RANGE_VAR_VALIDATOR = {
201
+ node: "RangeVar",
202
+ children: (node) => [...(node.alias ? [{ Alias: node.alias }] : [])],
203
+ validate: (node) => {
204
+ if (node.schemaname) {
205
+ throw new Error("Schema name not supported");
206
+ }
207
+ if (node.relname && SYSTEM_TABLES.has(node.relname)) {
208
+ throw new Error("System tables not supported");
209
+ }
210
+ },
211
+ };
212
+ const VAR_VALIDATOR = {
213
+ node: "Var",
214
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
215
+ };
216
+ const PARAM_VALIDATOR = {
217
+ node: "Param",
218
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
219
+ };
220
+ const AGGREF_VALIDATOR = {
221
+ node: "Aggref",
222
+ children: (node) => [
223
+ ...(node.aggargtypes ?? []),
224
+ ...(node.aggdirectargs ?? []),
225
+ ...(node.args ?? []),
226
+ ...(node.aggorder ?? []),
227
+ ...(node.aggdistinct ?? []),
228
+ ...(node.aggfilter ? [node.aggfilter] : []),
229
+ ],
230
+ };
231
+ const GROUPING_FUNC_VALIDATOR = {
232
+ node: "GroupingFunc",
233
+ children: (node) => [...(node.args ?? []), ...(node.refs ?? [])],
234
+ };
235
+ const WINDOW_FUNC_VALIDATOR = {
236
+ node: "WindowFunc",
237
+ children: (node) => [
238
+ ...(node.args ?? []),
239
+ ...(node.aggfilter ? [node.aggfilter] : []),
240
+ ],
241
+ };
242
+ const NAMED_ARG_EXPR_VALIDATOR = {
243
+ node: "NamedArgExpr",
244
+ children: (node) => [
245
+ ...(node.xpr ? [node.xpr] : []),
246
+ ...(node.arg ? [node.arg] : []),
247
+ ],
248
+ };
249
+ const OP_EXPR_VALIDATOR = {
250
+ node: "OpExpr",
251
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
252
+ };
253
+ const DISTINCT_EXPR_VALIDATOR = {
254
+ node: "DistinctExpr",
255
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
256
+ };
257
+ const NULL_IF_EXPR_VALIDATOR = {
258
+ node: "NullIfExpr",
259
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
260
+ };
261
+ const SCALAR_ARRAY_OP_EXPR_VALIDATOR = {
262
+ node: "ScalarArrayOpExpr",
263
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
264
+ };
265
+ const BOOL_EXPR_VALIDATOR = {
266
+ node: "BoolExpr",
267
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
268
+ };
269
+ const FIELD_SELECT_VALIDATOR = {
270
+ node: "FieldSelect",
271
+ children: (node) => [
272
+ ...(node.xpr ? [node.xpr] : []),
273
+ ...(node.arg ? [node.arg] : []),
274
+ ],
275
+ };
276
+ const RELABEL_TYPE_VALIDATOR = {
277
+ node: "RelabelType",
278
+ children: (node) => [
279
+ ...(node.xpr ? [node.xpr] : []),
280
+ ...(node.arg ? [node.arg] : []),
281
+ ],
282
+ };
283
+ const ARRAY_COERCE_EXPR_VALIDATOR = {
284
+ node: "ArrayCoerceExpr",
285
+ children: (node) => [
286
+ ...(node.xpr ? [node.xpr] : []),
287
+ ...(node.arg ? [node.arg] : []),
288
+ ...(node.elemexpr ? [node.elemexpr] : []),
289
+ ],
290
+ };
291
+ const CONVERT_ROWTYPE_EXPR_VALIDATOR = {
292
+ node: "ConvertRowtypeExpr",
293
+ children: (node) => [
294
+ ...(node.xpr ? [node.xpr] : []),
295
+ ...(node.arg ? [node.arg] : []),
296
+ ],
297
+ };
298
+ const COLLATE_EXPR_VALIDATOR = {
299
+ node: "CollateExpr",
300
+ children: (node) => [
301
+ ...(node.xpr ? [node.xpr] : []),
302
+ ...(node.arg ? [node.arg] : []),
303
+ ],
304
+ };
305
+ const CASE_EXPR_VALIDATOR = {
306
+ node: "CaseExpr",
307
+ children: (node) => [
308
+ ...(node.xpr ? [node.xpr] : []),
309
+ ...(node.arg ? [node.arg] : []),
310
+ ...(node.args ?? []),
311
+ ...(node.defresult ? [node.defresult] : []),
312
+ ],
313
+ };
314
+ const CASE_WHEN_VALIDATOR = {
315
+ node: "CaseWhen",
316
+ children: (node) => [
317
+ ...(node.xpr ? [node.xpr] : []),
318
+ ...(node.expr ? [node.expr] : []),
319
+ ...(node.result ? [node.result] : []),
320
+ ],
321
+ };
322
+ const CASE_TEST_EXPR_VALIDATOR = {
323
+ node: "CaseTestExpr",
324
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
325
+ };
326
+ const ARRAY_EXPR_VALIDATOR = {
327
+ node: "ArrayExpr",
328
+ children: (node) => [
329
+ ...(node.xpr ? [node.xpr] : []),
330
+ ...(node.elements ?? []),
331
+ ],
332
+ };
333
+ const ROW_EXPR_VALIDATOR = {
334
+ node: "RowExpr",
335
+ children: (node) => [
336
+ ...(node.xpr ? [node.xpr] : []),
337
+ ...(node.args ?? []),
338
+ ...(node.colnames ?? []),
339
+ ],
340
+ };
341
+ const ROW_COMPARE_EXPR_VALIDATOR = {
342
+ node: "RowCompareExpr",
343
+ children: (node) => [
344
+ ...(node.xpr ? [node.xpr] : []),
345
+ ...(node.opnos ?? []),
346
+ ...(node.opfamilies ?? []),
347
+ ...(node.inputcollids ?? []),
348
+ ...(node.largs ?? []),
349
+ ...(node.rargs ?? []),
350
+ ],
351
+ };
352
+ const COALESC_EXPR_VALIDATOR = {
353
+ node: "CoalesceExpr",
354
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
355
+ };
356
+ const MIN_MAX_EXPR_VALIDATOR = {
357
+ node: "MinMaxExpr",
358
+ children: (node) => [...(node.xpr ? [node.xpr] : []), ...(node.args ?? [])],
359
+ };
360
+ const SQL_VALUE_FUNCTION_VALIDATOR = {
361
+ node: "SQLValueFunction",
362
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
363
+ };
364
+ const JSON_FORMAT_VALIDATOR = {
365
+ node: "JsonFormat",
366
+ children: () => [],
367
+ };
368
+ const JSON_RETURNING_VALIDATOR = {
369
+ node: "JsonReturning",
370
+ children: (node) => [...(node.format ? [{ JsonFormat: node.format }] : [])],
371
+ };
372
+ const JSON_VALUE_EXPR_VALIDATOR = {
373
+ node: "JsonValueExpr",
374
+ children: (node) => [
375
+ ...(node.raw_expr ? [node.raw_expr] : []),
376
+ ...(node.formatted_expr ? [node.formatted_expr] : []),
377
+ ...(node.format ? [{ JsonFormat: node.format }] : []),
378
+ ],
379
+ };
380
+ const JSON_CONSTRUCTOR_EXPR_VALIDATOR = {
381
+ node: "JsonConstructorExpr",
382
+ children: (node) => [
383
+ ...(node.xpr ? [node.xpr] : []),
384
+ ...(node.args ?? []),
385
+ ...(node.func ? [node.func] : []),
386
+ ...(node.coercion ? [node.coercion] : []),
387
+ ...(node.returning ? [{ JsonReturning: node.returning }] : []),
388
+ ],
389
+ };
390
+ const JSON_IS_PREDICATE_VALIDATOR = {
391
+ node: "JsonIsPredicate",
392
+ children: (node) => [
393
+ ...(node.expr ? [node.expr] : []),
394
+ ...(node.format ? [{ JsonFormat: node.format }] : []),
395
+ ],
396
+ };
397
+ const NULL_TEST_VALIDATOR = {
398
+ node: "NullTest",
399
+ children: (node) => [
400
+ ...(node.xpr ? [node.xpr] : []),
401
+ ...(node.arg ? [node.arg] : []),
402
+ ],
403
+ };
404
+ const BOOLEAN_TEST_VALIDATOR = {
405
+ node: "BooleanTest",
406
+ children: (node) => [
407
+ ...(node.xpr ? [node.xpr] : []),
408
+ ...(node.arg ? [node.arg] : []),
409
+ ],
410
+ };
411
+ const COERCE_TO_DOMAIN_VALIDATOR = {
412
+ node: "CoerceToDomain",
413
+ children: (node) => [
414
+ ...(node.xpr ? [node.xpr] : []),
415
+ ...(node.arg ? [node.arg] : []),
416
+ ],
417
+ };
418
+ const COERCE_TO_DOMAIN_VALUE_VALIDATOR = {
419
+ node: "CoerceToDomainValue",
420
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
421
+ };
422
+ const CURRENT_OF_EXPR_VALIDATOR = {
423
+ node: "CurrentOfExpr",
424
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
425
+ };
426
+ const NEXT_VALUE_EXPR_VALIDATOR = {
427
+ node: "NextValueExpr",
428
+ children: (node) => [...(node.xpr ? [node.xpr] : [])],
429
+ };
430
+ const INFERENCE_ELEM_VALIDATOR = {
431
+ node: "InferenceElem",
432
+ children: (node) => [
433
+ ...(node.xpr ? [node.xpr] : []),
434
+ ...(node.expr ? [node.expr] : []),
435
+ ],
436
+ };
437
+ const TARGET_ENTRY_VALIDATOR = {
438
+ node: "TargetEntry",
439
+ children: (node) => [
440
+ ...(node.xpr ? [node.xpr] : []),
441
+ ...(node.expr ? [node.expr] : []),
442
+ ],
443
+ };
444
+ const RANGE_TBL_REF_VALIDATOR = {
445
+ node: "RangeTblRef",
446
+ children: () => [],
447
+ };
448
+ const JOIN_EXPR_VALIDATOR = {
449
+ node: "JoinExpr",
450
+ children: (node) => [
451
+ ...(node.larg ? [node.larg] : []),
452
+ ...(node.rarg ? [node.rarg] : []),
453
+ ...(node.usingClause ?? []),
454
+ ...(node.join_using_alias ? [{ Alias: node.join_using_alias }] : []),
455
+ ...(node.quals ? [node.quals] : []),
456
+ ...(node.alias ? [{ Alias: node.alias }] : []),
457
+ ],
458
+ };
459
+ const FROM_EXPR_VALIDATOR = {
460
+ node: "FromExpr",
461
+ children: (node) => [
462
+ ...(node.fromlist ?? []),
463
+ ...(node.quals ? [node.quals] : []),
464
+ ],
465
+ };
466
+ const ON_CONFLICT_EXPR_VALIDATOR = {
467
+ node: "OnConflictExpr",
468
+ children: (node) => [
469
+ ...(node.arbiterElems ?? []),
470
+ ...(node.arbiterWhere ? [node.arbiterWhere] : []),
471
+ ...(node.onConflictSet ?? []),
472
+ ...(node.onConflictWhere ? [node.onConflictWhere] : []),
473
+ ...(node.exclRelTlist ?? []),
474
+ ],
475
+ };
476
+ const TYPE_NAME_VALIDATOR = {
477
+ node: "TypeName",
478
+ children: (node) => [
479
+ ...(node.names ?? []),
480
+ ...(node.typmods ?? []),
481
+ ...(node.arrayBounds ?? []),
482
+ ],
483
+ };
484
+ const COLUMN_REF_VALIDATOR = {
485
+ node: "ColumnRef",
486
+ children: (node) => [...(node.fields ?? [])],
487
+ };
488
+ const PARAM_REF_VALIDATOR = {
489
+ node: "ParamRef",
490
+ children: () => [],
491
+ };
492
+ const A_EXPR_VALIDATOR = {
493
+ node: "A_Expr",
494
+ children: (node) => [
495
+ ...(node.name ?? []),
496
+ ...(node.lexpr ? [node.lexpr] : []),
497
+ ...(node.rexpr ? [node.rexpr] : []),
498
+ ],
499
+ };
500
+ const TYPE_CAST_VALIDATOR = {
501
+ node: "TypeCast",
502
+ children: (node) => [
503
+ ...(node.arg ? [node.arg] : []),
504
+ ...(node.typeName ? [{ TypeName: node.typeName }] : []),
505
+ ],
506
+ };
507
+ const COLLATE_CLAUSE_VALIDATOR = {
508
+ node: "CollateClause",
509
+ children: (node) => [
510
+ ...(node.arg ? [node.arg] : []),
511
+ ...(node.collname ?? []),
512
+ ],
513
+ };
514
+ const ALLOWED_FUNCTIONS = new Set([
515
+ "count",
516
+ "sum",
517
+ "avg",
518
+ "min",
519
+ "max",
520
+ "lower",
521
+ "upper",
522
+ "length",
523
+ "trim",
524
+ "replace",
525
+ "substring",
526
+ "cast",
527
+ "concat",
528
+ "now",
529
+ "current_timestamp",
530
+ "current_date",
531
+ "current_time",
532
+ "coalesce",
533
+ "json_agg",
534
+ "json_object",
535
+ "json_array",
536
+ "json_object_agg",
537
+ "json_array_agg",
538
+ "json_build_array",
539
+ "row_number",
540
+ "rank",
541
+ "dense_rank",
542
+ "percent_rank",
543
+ "cume_dist",
544
+ "ntile",
545
+ "lag",
546
+ "lead",
547
+ "first_value",
548
+ "last_value",
549
+ "nth_value",
550
+ "abs",
551
+ "cbrt",
552
+ "ceil",
553
+ "ceiling",
554
+ "degrees",
555
+ "div",
556
+ "exp",
557
+ "floor",
558
+ "ln",
559
+ "log",
560
+ "mod",
561
+ "pi",
562
+ "power",
563
+ "radians",
564
+ "random",
565
+ "round",
566
+ "sign",
567
+ "sqrt",
568
+ "width_bucket",
569
+ "acos",
570
+ "asin",
571
+ "atan",
572
+ "atan2",
573
+ "cos",
574
+ "cot",
575
+ "sin",
576
+ "tan",
577
+ ]);
578
+ const FUNC_CALL_VALIDATOR = {
579
+ node: "FuncCall",
580
+ children: (node) => [
581
+ ...(node.funcname ?? []),
582
+ ...(node.args ?? []),
583
+ ...(node.agg_order ?? []),
584
+ ...(node.agg_filter ? [node.agg_filter] : []),
585
+ ...(node.over ? [{ WindowDef: node.over }] : []),
586
+ ],
587
+ validate: (node) => {
588
+ if (node.funcname?.every((name) => getNodeType(name) === "String" &&
589
+ // @ts-ignore
590
+ ALLOWED_FUNCTIONS.has(name.String.sval))) {
591
+ return;
592
+ }
593
+ throw new Error("Function call not supported");
594
+ },
595
+ };
596
+ const A_STAR_VALIDATOR = {
597
+ node: "A_Star",
598
+ children: () => [],
599
+ };
600
+ const A_INDICES_VALIDATOR = {
601
+ node: "A_Indices",
602
+ children: (node) => [
603
+ ...(node.lidx ? [node.lidx] : []),
604
+ ...(node.uidx ? [node.uidx] : []),
605
+ ],
606
+ };
607
+ const A_INDIRECTION_VALIDATOR = {
608
+ node: "A_Indirection",
609
+ children: (node) => [
610
+ ...(node.arg ? [node.arg] : []),
611
+ ...(node.indirection ?? []),
612
+ ],
613
+ };
614
+ const A_ARRAY_EXPR_VALIDATOR = {
615
+ node: "A_ArrayExpr",
616
+ children: (node) => [...(node.elements ?? [])],
617
+ };
618
+ const RES_TARGET_VALIDATOR = {
619
+ node: "ResTarget",
620
+ children: (node) => [
621
+ ...(node.indirection ?? []),
622
+ ...(node.val ? [node.val] : []),
623
+ ],
624
+ };
625
+ const MULTI_ASSIGN_REF_VALIDATOR = {
626
+ node: "MultiAssignRef",
627
+ children: (node) => [...(node.source ? [node.source] : [])],
628
+ };
629
+ const SORT_BY_VALIDATOR = {
630
+ node: "SortBy",
631
+ children: (node) => [
632
+ ...(node.node ? [node.node] : []),
633
+ ...(node.useOp ?? []),
634
+ ],
635
+ };
636
+ const WINDOW_DEF_VALIDATOR = {
637
+ node: "WindowDef",
638
+ children: (node) => [
639
+ ...(node.partitionClause ?? []),
640
+ ...(node.orderClause ?? []),
641
+ ...(node.startOffset ? [node.startOffset] : []),
642
+ ...(node.endOffset ? [node.endOffset] : []),
643
+ ],
644
+ };
645
+ const RANGE_SUBSELECT_VALIDATOR = {
646
+ node: "RangeSubselect",
647
+ children: (node) => [
648
+ ...(node.subquery ? [node.subquery] : []),
649
+ ...(node.alias ? [{ Alias: node.alias }] : []),
650
+ ],
651
+ };
652
+ const SORT_GROUP_CLAUSE_VALIDATOR = {
653
+ node: "SortGroupClause",
654
+ children: () => [],
655
+ };
656
+ const GROUPING_SET_VALIDATOR = {
657
+ node: "GroupingSet",
658
+ children: (node) => [...(node.content ?? [])],
659
+ };
660
+ const WITH_CLAUSE_VALIDATOR = {
661
+ node: "WithClause",
662
+ children: (node) => [...(node.ctes ?? [])],
663
+ validate: (node) => {
664
+ if (node.recursive) {
665
+ throw new Error("Recursive CTEs not supported");
666
+ }
667
+ },
668
+ };
669
+ const COMMON_TABLE_EXPR_VALIDATOR = {
670
+ node: "CommonTableExpr",
671
+ children: (node) => [
672
+ ...(node.aliascolnames ?? []),
673
+ ...(node.ctequery ? [node.ctequery] : []),
674
+ ...(node.search_clause ? [{ CTESearchClause: node.search_clause }] : []),
675
+ ...(node.cycle_clause ? [{ CTECycleClause: node.cycle_clause }] : []),
676
+ ...(node.ctecolnames ?? []),
677
+ ...(node.ctecoltypes ?? []),
678
+ ...(node.ctecoltypmods ?? []),
679
+ ...(node.ctecolcollations ?? []),
680
+ ],
681
+ validate: (node) => {
682
+ if (node.ctematerialized === "CTEMaterializeAlways" || node.cterecursive) {
683
+ throw new Error("Invalid CTE");
684
+ }
685
+ },
686
+ };
687
+ const JSON_OUTPUT_VALIDATOR = {
688
+ node: "JsonOutput",
689
+ children: (node) => [
690
+ ...(node.returning ? [{ JsonReturning: node.returning }] : []),
691
+ ],
692
+ };
693
+ const JSON_KEY_VALUE_VALIDATOR = {
694
+ node: "JsonKeyValue",
695
+ children: (node) => [
696
+ ...(node.key ? [node.key] : []),
697
+ ...(node.value ? [{ JsonValueExpr: node.value }] : []),
698
+ ],
699
+ };
700
+ const JSON_OBJECT_CONSTRUCTOR_VALIDATOR = {
701
+ node: "JsonObjectConstructor",
702
+ children: (node) => [
703
+ ...(node.exprs ?? []),
704
+ ...(node.output ? [{ JsonOutput: node.output }] : []),
705
+ ],
706
+ };
707
+ const JSON_ARRAY_CONSTRUCTOR_VALIDATOR = {
708
+ node: "JsonArrayConstructor",
709
+ children: (node) => [
710
+ ...(node.exprs ?? []),
711
+ ...(node.output ? [{ JsonOutput: node.output }] : []),
712
+ ],
713
+ };
714
+ const JSON_ARRAY_QUERY_CONSTRUCTOR_VALIDATOR = {
715
+ node: "JsonArrayQueryConstructor",
716
+ children: (node) => [
717
+ ...(node.query ? [node.query] : []),
718
+ ...(node.output ? [{ JsonOutput: node.output }] : []),
719
+ ...(node.format ? [{ JsonFormat: node.format }] : []),
720
+ ],
721
+ };
722
+ const JSON_AGG_CONSTRUCTOR_VALIDATOR = {
723
+ node: "JsonAggConstructor",
724
+ children: (node) => [
725
+ ...(node.output ? [{ JsonOutput: node.output }] : []),
726
+ ...(node.agg_filter ? [node.agg_filter] : []),
727
+ ...(node.agg_order ?? []),
728
+ ...(node.over ? [{ WindowDef: node.over }] : []),
729
+ ],
730
+ };
731
+ const JSON_OBJECT_AGG_VALIDATOR = {
732
+ node: "JsonObjectAgg",
733
+ children: (node) => [
734
+ ...(node.constructor ? [{ JsonAggConstructor: node.constructor }] : []),
735
+ ...(node.arg ? [{ JsonKeyValue: node.arg }] : []),
736
+ ],
737
+ };
738
+ const JSON_ARRAY_AGG_VALIDATOR = {
739
+ node: "JsonArrayAgg",
740
+ children: (node) => [
741
+ ...(node.constructor ? [{ JsonAggConstructor: node.constructor }] : []),
742
+ ...(node.arg ? [{ JsonValueExpr: node.arg }] : []),
743
+ ],
744
+ };
745
+ const SELECT_STMT_VALIDATOR = {
746
+ node: "SelectStmt",
747
+ children: (node) => [
748
+ ...(node.distinctClause ?? []),
749
+ ...(node.intoClause ? [{ IntoClause: node.intoClause }] : []),
750
+ ...(node.targetList ?? []),
751
+ ...(node.fromClause ?? []),
752
+ ...(node.whereClause ? [node.whereClause] : []),
753
+ ...(node.groupClause ?? []),
754
+ ...(node.havingClause ? [node.havingClause] : []),
755
+ ...(node.windowClause ?? []),
756
+ ...(node.valuesLists ?? []),
757
+ ...(node.sortClause ?? []),
758
+ ...(node.limitOffset ? [node.limitOffset] : []),
759
+ ...(node.limitCount ? [node.limitCount] : []),
760
+ ...(node.lockingClause ?? []),
761
+ ...(node.withClause ? [{ WithClause: node.withClause }] : []),
762
+ ...(node.larg ? [{ SelectStmt: node.larg }] : []),
763
+ ...(node.rarg ? [{ SelectStmt: node.rarg }] : []),
764
+ ],
765
+ validate: (node) => {
766
+ if (node.lockingClause) {
767
+ throw new Error("Invalid query");
768
+ }
769
+ },
770
+ };
771
+ const COMMENT_STMT_VALIDATOR = {
772
+ node: "CommentStmt",
773
+ children: (node) => [...(node.object ? [node.object] : [])],
774
+ };
775
+ /** Validation rules for allowed Postgres SQL AST nodes. */
776
+ const ALLOW_LIST = new Map([
777
+ INTEGER_VALIDATOR,
778
+ FLOAT_VALIDATOR,
779
+ BOOLEAN_VALIDATOR,
780
+ STRING_VALIDATOR,
781
+ BIT_STRING_VALIDATOR,
782
+ LIST_VALIDATOR,
783
+ OID_LIST_VALIDATOR,
784
+ INT_LIST_VALIDATOR,
785
+ A_CONST_VALIDATOR,
786
+ ALIAS_VALIDATOR,
787
+ RANGE_VAR_VALIDATOR,
788
+ VAR_VALIDATOR,
789
+ PARAM_VALIDATOR,
790
+ AGGREF_VALIDATOR,
791
+ GROUPING_FUNC_VALIDATOR,
792
+ WINDOW_FUNC_VALIDATOR,
793
+ NAMED_ARG_EXPR_VALIDATOR,
794
+ OP_EXPR_VALIDATOR,
795
+ DISTINCT_EXPR_VALIDATOR,
796
+ NULL_IF_EXPR_VALIDATOR,
797
+ SCALAR_ARRAY_OP_EXPR_VALIDATOR,
798
+ BOOL_EXPR_VALIDATOR,
799
+ FIELD_SELECT_VALIDATOR,
800
+ RELABEL_TYPE_VALIDATOR,
801
+ ARRAY_COERCE_EXPR_VALIDATOR,
802
+ CONVERT_ROWTYPE_EXPR_VALIDATOR,
803
+ COLLATE_EXPR_VALIDATOR,
804
+ CASE_EXPR_VALIDATOR,
805
+ CASE_WHEN_VALIDATOR,
806
+ CASE_TEST_EXPR_VALIDATOR,
807
+ ARRAY_EXPR_VALIDATOR,
808
+ ROW_EXPR_VALIDATOR,
809
+ ROW_COMPARE_EXPR_VALIDATOR,
810
+ COALESC_EXPR_VALIDATOR,
811
+ MIN_MAX_EXPR_VALIDATOR,
812
+ SQL_VALUE_FUNCTION_VALIDATOR,
813
+ JSON_FORMAT_VALIDATOR,
814
+ JSON_RETURNING_VALIDATOR,
815
+ JSON_VALUE_EXPR_VALIDATOR,
816
+ JSON_CONSTRUCTOR_EXPR_VALIDATOR,
817
+ JSON_IS_PREDICATE_VALIDATOR,
818
+ NULL_TEST_VALIDATOR,
819
+ BOOLEAN_TEST_VALIDATOR,
820
+ COERCE_TO_DOMAIN_VALIDATOR,
821
+ COERCE_TO_DOMAIN_VALUE_VALIDATOR,
822
+ CURRENT_OF_EXPR_VALIDATOR,
823
+ NEXT_VALUE_EXPR_VALIDATOR,
824
+ INFERENCE_ELEM_VALIDATOR,
825
+ TARGET_ENTRY_VALIDATOR,
826
+ RANGE_TBL_REF_VALIDATOR,
827
+ JOIN_EXPR_VALIDATOR,
828
+ FROM_EXPR_VALIDATOR,
829
+ ON_CONFLICT_EXPR_VALIDATOR,
830
+ TYPE_NAME_VALIDATOR,
831
+ COLUMN_REF_VALIDATOR,
832
+ PARAM_REF_VALIDATOR,
833
+ A_EXPR_VALIDATOR,
834
+ TYPE_CAST_VALIDATOR,
835
+ COLLATE_CLAUSE_VALIDATOR,
836
+ FUNC_CALL_VALIDATOR,
837
+ A_STAR_VALIDATOR,
838
+ A_INDICES_VALIDATOR,
839
+ A_INDIRECTION_VALIDATOR,
840
+ A_ARRAY_EXPR_VALIDATOR,
841
+ RES_TARGET_VALIDATOR,
842
+ MULTI_ASSIGN_REF_VALIDATOR,
843
+ SORT_BY_VALIDATOR,
844
+ WINDOW_DEF_VALIDATOR,
845
+ RANGE_SUBSELECT_VALIDATOR,
846
+ SORT_GROUP_CLAUSE_VALIDATOR,
847
+ GROUPING_SET_VALIDATOR,
848
+ WITH_CLAUSE_VALIDATOR,
849
+ COMMON_TABLE_EXPR_VALIDATOR,
850
+ JSON_OUTPUT_VALIDATOR,
851
+ JSON_KEY_VALUE_VALIDATOR,
852
+ JSON_OBJECT_CONSTRUCTOR_VALIDATOR,
853
+ JSON_ARRAY_CONSTRUCTOR_VALIDATOR,
854
+ JSON_ARRAY_QUERY_CONSTRUCTOR_VALIDATOR,
855
+ JSON_AGG_CONSTRUCTOR_VALIDATOR,
856
+ JSON_OBJECT_AGG_VALIDATOR,
857
+ JSON_ARRAY_AGG_VALIDATOR,
858
+ SELECT_STMT_VALIDATOR,
859
+ COMMENT_STMT_VALIDATOR,
860
+ ].map((node) => [node.node, node]));
861
+ const UPDATE_STMT_VALIDATOR = {
862
+ node: "UpdateStmt",
863
+ children: (node) => [
864
+ ...(node.relation ? [{ RangeVar: node.relation }] : []),
865
+ ...(node.targetList ?? []),
866
+ ...(node.whereClause ? [node.whereClause] : []),
867
+ ...(node.fromClause ?? []),
868
+ ...(node.returningList ?? []),
869
+ ...(node.withClause ? [{ WithClause: node.withClause }] : []),
870
+ ],
871
+ };
872
+ const DELETE_STMT_VALIDATOR = {
873
+ node: "DeleteStmt",
874
+ children: (node) => [
875
+ ...(node.relation ? [{ RangeVar: node.relation }] : []),
876
+ ...(node.usingClause ?? []),
877
+ ...(node.whereClause ? [node.whereClause] : []),
878
+ ...(node.returningList ?? []),
879
+ ...(node.withClause ? [{ WithClause: node.withClause }] : []),
880
+ ],
881
+ };
882
+ const FIND_LIST = new Map([
883
+ ...Array.from(ALLOW_LIST.values()),
884
+ UPDATE_STMT_VALIDATOR,
885
+ DELETE_STMT_VALIDATOR,
886
+ ].map((node) => [node.node, node]));
887
+ // NOT_ALLOW_LIST
888
+ // ParseResult
889
+ // ScanResult
890
+ // TableFunc
891
+ // IntoClause
892
+ // SubscriptingRef
893
+ // FuncExpr
894
+ // SubLink
895
+ // SubPlan
896
+ // AlternativeSubPlan
897
+ // FieldStore
898
+ // CoerceViaIO
899
+ // XmlExpr
900
+ // SetToDefault
901
+ // Query
902
+ // RoleSpec
903
+ // RangeFunction
904
+ // RangeTableFunc
905
+ // RangeTableFuncCol
906
+ // RangeTableSample
907
+ // ColumnDef
908
+ // TableLikeClause
909
+ // IndexElem
910
+ // DefElem
911
+ // LockingClause
912
+ // XmlSerialize
913
+ // PartitionElem
914
+ // PartitionSpec
915
+ // PartitionBounSpec
916
+ // PartitionRangeDatum
917
+ // PartitionCmd
918
+ // RangeTableEntry
919
+ // RTEPermissionInfo
920
+ // RangeTblFunction
921
+ // TableSampleClause
922
+ // WithCheckOption
923
+ // WindowClause
924
+ // RowMarkClause
925
+ // InferClausej
926
+ // OnConflictClause
927
+ // CTESearchClause
928
+ // CTECycleClause
929
+ // MergeWhenClause
930
+ // MergeAction
931
+ // TriggerTransition
932
+ // RawStmt
933
+ // InsertStmt
934
+ // DeleteStmt
935
+ // UpdateStmt
936
+ // MergeStmt
937
+ // SetOperationStmt
938
+ // ReturnStmt
939
+ // PLAssignStmt
940
+ // CreateSchemaStmt
941
+ // AlterTableStmt
942
+ // ReplicaIdentityStmt
943
+ // AlterTableCmd
944
+ // AlterCollationStmt
945
+ // AlterDomainStmt
946
+ // GrantStmt
947
+ // ObjectWithArgs
948
+ // AccessPriv
949
+ // GrantRoleStmt
950
+ // AlterDefaultPrivilegesStmt
951
+ // CopyStmt
952
+ // VariableSetStmt
953
+ // VariableShowStmt
954
+ // CreateStmt
955
+ // Constraint
956
+ // CreateTableSpaceStmt
957
+ // DropTableSpaceStmt
958
+ // AlterTableSpaceOptionsStmt
959
+ // AlterTableMoveAllStmt
960
+ // CreateExtensionStmt
961
+ // AlterExtensionStmt
962
+ // AlterExtensionContentsStmt
963
+ // CreateFdwStmt
964
+ // AlterFdwStmt
965
+ // CreateForeignServerStmt
966
+ // AlterForeignServerStmt
967
+ // CreateForeignTableStmt
968
+ // CreateUserMappingStmt
969
+ // AlterUserMappingStmt
970
+ // DropUserMappingStmt
971
+ // ImportForeignSchemaStmt
972
+ // CreatePolicyStmt
973
+ // AlterPolicyStmt
974
+ // CreateAmStmt
975
+ // CreateTrigStmt
976
+ // CreateEventTrigStmt
977
+ // AlterEventTrigStmt
978
+ // CreatePLangStmt
979
+ // CreateRoleStmt
980
+ // AlterRoleStmt
981
+ // AlterRoleSetStmt
982
+ // DropRoleStmt
983
+ // CreateSeqStmt
984
+ // AlterSeqStmt
985
+ // DefineStmt
986
+ // CreateDomainStmt
987
+ // CreateOpClassStmt
988
+ // CreateOpClassItem
989
+ // CreateOpFamilyStmt
990
+ // AlterOpFamilyStmt
991
+ // DropStmt
992
+ // TruncateStmt
993
+ // SecLabelStmt
994
+ // DeclareCursorStmt
995
+ // ClosePortalStmt
996
+ // FetchStmt
997
+ // IndexStmt
998
+ // CreateStatsStmt
999
+ // StatsElem
1000
+ // AlterStatsStmt
1001
+ // CreateFunctionStmt
1002
+ // FunctionParameter
1003
+ // AlterFunctionStmt
1004
+ // DoStmt
1005
+ // InlineCodeBlock
1006
+ // CallStmt
1007
+ // CallContext
1008
+ // RenameStmt
1009
+ // AlterObjectDependsStmt
1010
+ // AlterObjectSchemaStmt
1011
+ // AlterOwnerStmt
1012
+ // AlterOperatorStmt
1013
+ // AlterTypeStmt
1014
+ // RuleStmt
1015
+ // NotifyStmt
1016
+ // ListenStmt
1017
+ // UnlistenStmt
1018
+ // TransactionStmt
1019
+ // CompositeTypeStmt
1020
+ // CreateEnumStmt
1021
+ // CreateRangeStmt
1022
+ // AlterEnumStmt
1023
+ // ViewStmt
1024
+ // LoadStmt
1025
+ // CreatedbStmt
1026
+ // AlterDatabaseStmt
1027
+ // AlterDatabaseRefreshCollStmt
1028
+ // AlterDatabaseSetStmt
1029
+ // DropdbStmt
1030
+ // AlterSystemStmt
1031
+ // ClusterStmt
1032
+ // VacuumStmt
1033
+ // VacuumRelation
1034
+ // ExplainStmt
1035
+ // CreateTableAsStmt
1036
+ // RefreshMatViewStmt
1037
+ // CheckPointStmt
1038
+ // DiscardStmt
1039
+ // LockStmt
1040
+ // ConstraintsSetStmt
1041
+ // ReindexStmt
1042
+ // CreateConversionStmt
1043
+ // CreateCastStmt
1044
+ // CreateTransformStmt
1045
+ // PrepareStmt
1046
+ // ExecuteStmt
1047
+ // DeallocateStmt
1048
+ // DropOwnedStmt
1049
+ // ReassignOwnedStmt
1050
+ // AlterTSDictionaryStmt
1051
+ // AlterTSConfigurationStmt
1052
+ // PublicationTable
1053
+ // PublicationObjSpec
1054
+ // CreatePublicationStmt
1055
+ // AlterPublicationStmt
1056
+ // CreateSubscriptionStmt
1057
+ // AlterSubscriptionStmt
1058
+ // DropSubscriptionStmt
1059
+ // ScanToken
1060
+ const SYSTEM_TABLES = new Set([
1061
+ "pg_statistic",
1062
+ "pg_type",
1063
+ "pg_foreign_table",
1064
+ "pg_proc_oid_index",
1065
+ "pg_proc_proname_args_nsp_index",
1066
+ "pg_type_oid_index",
1067
+ "pg_type_typname_nsp_index",
1068
+ "pg_attribute_relid_attnam_index",
1069
+ "pg_attribute_relid_attnum_index",
1070
+ "pg_class_oid_index",
1071
+ "pg_class_relname_nsp_index",
1072
+ "pg_class_tblspc_relfilenode_index",
1073
+ "pg_attrdef_adrelid_adnum_index",
1074
+ "pg_attrdef_oid_index",
1075
+ "pg_constraint_conname_nsp_index",
1076
+ "pg_constraint_conrelid_contypid_conname_index",
1077
+ "pg_constraint_contypid_index",
1078
+ "pg_constraint_oid_index",
1079
+ "pg_constraint_conparentid_index",
1080
+ "pg_inherits_relid_seqno_index",
1081
+ "pg_inherits_parent_index",
1082
+ "pg_index_indrelid_index",
1083
+ "pg_index_indexrelid_index",
1084
+ "pg_operator_oid_index",
1085
+ "pg_operator_oprname_l_r_n_index",
1086
+ "pg_opfamily_am_name_nsp_index",
1087
+ "pg_opfamily_oid_index",
1088
+ "pg_opclass_am_name_nsp_index",
1089
+ "pg_opclass_oid_index",
1090
+ "pg_am_name_index",
1091
+ "pg_am_oid_index",
1092
+ "pg_amop_fam_strat_index",
1093
+ "pg_amop_opr_fam_index",
1094
+ "pg_amop_oid_index",
1095
+ "pg_amproc_fam_proc_index",
1096
+ "pg_amproc_oid_index",
1097
+ "pg_language_name_index",
1098
+ "pg_language_oid_index",
1099
+ "pg_largeobject_metadata_oid_index",
1100
+ "pg_largeobject_loid_pn_index",
1101
+ "pg_aggregate_fnoid_index",
1102
+ "pg_statistic_relid_att_inh_index",
1103
+ "pg_statistic_ext_oid_index",
1104
+ "pg_statistic_ext_name_index",
1105
+ "pg_statistic_ext_relid_index",
1106
+ "pg_statistic_ext_data_stxoid_inh_index",
1107
+ "pg_rewrite_oid_index",
1108
+ "pg_rewrite_rel_rulename_index",
1109
+ "pg_trigger_tgconstraint_index",
1110
+ "pg_trigger_tgrelid_tgname_index",
1111
+ "pg_trigger_oid_index",
1112
+ "pg_event_trigger_evtname_index",
1113
+ "pg_event_trigger_oid_index",
1114
+ "pg_description_o_c_o_index",
1115
+ "pg_cast_oid_index",
1116
+ "pg_cast_source_target_index",
1117
+ "pg_enum_oid_index",
1118
+ "pg_enum_typid_label_index",
1119
+ "pg_enum_typid_sortorder_index",
1120
+ "pg_namespace_nspname_index",
1121
+ "pg_namespace_oid_index",
1122
+ "pg_conversion_default_index",
1123
+ "pg_conversion_name_nsp_index",
1124
+ "pg_conversion_oid_index",
1125
+ "pg_depend_depender_index",
1126
+ "pg_depend_reference_index",
1127
+ "pg_database_datname_index",
1128
+ "pg_database_oid_index",
1129
+ "pg_db_role_setting_databaseid_rol_index",
1130
+ "pg_tablespace_oid_index",
1131
+ "pg_tablespace_spcname_index",
1132
+ "pg_authid_rolname_index",
1133
+ "pg_authid_oid_index",
1134
+ "pg_auth_members_oid_index",
1135
+ "pg_auth_members_role_member_index",
1136
+ "pg_auth_members_member_role_index",
1137
+ "pg_auth_members_grantor_index",
1138
+ "pg_shdepend_depender_index",
1139
+ "pg_shdepend_reference_index",
1140
+ "pg_shdescription_o_c_index",
1141
+ "pg_ts_config_cfgname_index",
1142
+ "pg_ts_config_oid_index",
1143
+ "pg_ts_config_map_index",
1144
+ "pg_ts_dict_dictname_index",
1145
+ "pg_ts_dict_oid_index",
1146
+ "pg_ts_parser_prsname_index",
1147
+ "pg_ts_parser_oid_index",
1148
+ "pg_ts_template_tmplname_index",
1149
+ "pg_ts_template_oid_index",
1150
+ "pg_extension_oid_index",
1151
+ "pg_extension_name_index",
1152
+ "pg_foreign_data_wrapper_oid_index",
1153
+ "pg_foreign_data_wrapper_name_index",
1154
+ "pg_foreign_server_oid_index",
1155
+ "pg_foreign_server_name_index",
1156
+ "pg_user_mapping_oid_index",
1157
+ "pg_user_mapping_user_server_index",
1158
+ "pg_foreign_table_relid_index",
1159
+ "pg_policy_oid_index",
1160
+ "pg_policy_polrelid_polname_index",
1161
+ "pg_replication_origin_roiident_index",
1162
+ "pg_replication_origin_roname_index",
1163
+ "pg_default_acl_role_nsp_obj_index",
1164
+ "pg_default_acl_oid_index",
1165
+ "pg_init_privs_o_c_o_index",
1166
+ "pg_seclabel_object_index",
1167
+ "pg_shseclabel_object_index",
1168
+ "pg_collation_name_enc_nsp_index",
1169
+ "pg_collation_oid_index",
1170
+ "pg_parameter_acl_parname_index",
1171
+ "pg_parameter_acl_oid_index",
1172
+ "pg_partitioned_table_partrelid_index",
1173
+ "pg_range_rngtypid_index",
1174
+ "pg_range_rngmultitypid_index",
1175
+ "pg_transform_oid_index",
1176
+ "pg_transform_type_lang_index",
1177
+ "pg_sequence_seqrelid_index",
1178
+ "pg_publication_oid_index",
1179
+ "pg_publication_pubname_index",
1180
+ "pg_publication_namespace_oid_index",
1181
+ "pg_publication_namespace_pnnspid_pnpubid_index",
1182
+ "pg_publication_rel_oid_index",
1183
+ "pg_publication_rel_prrelid_prpubid_index",
1184
+ "pg_publication_rel_prpubid_index",
1185
+ "pg_subscription_oid_index",
1186
+ "pg_subscription_subname_index",
1187
+ "pg_subscription_rel_srrelid_srsubid_index",
1188
+ "pg_authid",
1189
+ "pg_shadow",
1190
+ "pg_roles",
1191
+ "pg_statistic_ext_data",
1192
+ "pg_hba_file_rules",
1193
+ "pg_settings",
1194
+ "pg_file_settings",
1195
+ "pg_backend_memory_contexts",
1196
+ "pg_ident_file_mappings",
1197
+ "pg_config",
1198
+ "pg_shmem_allocations",
1199
+ "pg_tables",
1200
+ "pg_user_mapping",
1201
+ "pg_replication_origin_status",
1202
+ "pg_subscription",
1203
+ "pg_attribute",
1204
+ "pg_proc",
1205
+ "pg_class",
1206
+ "pg_attrdef",
1207
+ "pg_constraint",
1208
+ "pg_inherits",
1209
+ "pg_index",
1210
+ "pg_operator",
1211
+ "pg_statio_all_sequences",
1212
+ "pg_opfamily",
1213
+ "pg_opclass",
1214
+ "pg_am",
1215
+ "pg_amop",
1216
+ "pg_amproc",
1217
+ "pg_language",
1218
+ "pg_largeobject_metadata",
1219
+ "pg_aggregate",
1220
+ "pg_statistic_ext",
1221
+ "pg_rewrite",
1222
+ "pg_trigger",
1223
+ "pg_event_trigger",
1224
+ "pg_description",
1225
+ "pg_cast",
1226
+ "pg_enum",
1227
+ "pg_namespace",
1228
+ "pg_conversion",
1229
+ "pg_depend",
1230
+ "pg_database",
1231
+ "pg_db_role_setting",
1232
+ "pg_tablespace",
1233
+ "pg_auth_members",
1234
+ "pg_shdepend",
1235
+ "pg_shdescription",
1236
+ "pg_ts_config",
1237
+ "pg_ts_config_map",
1238
+ "pg_ts_dict",
1239
+ "pg_ts_parser",
1240
+ "pg_ts_template",
1241
+ "pg_extension",
1242
+ "pg_foreign_data_wrapper",
1243
+ "pg_foreign_server",
1244
+ "pg_policy",
1245
+ "pg_replication_origin",
1246
+ "pg_default_acl",
1247
+ "pg_init_privs",
1248
+ "pg_seclabel",
1249
+ "pg_shseclabel",
1250
+ "pg_collation",
1251
+ "pg_parameter_acl",
1252
+ "pg_partitioned_table",
1253
+ "pg_range",
1254
+ "pg_transform",
1255
+ "pg_sequence",
1256
+ "pg_publication",
1257
+ "pg_publication_namespace",
1258
+ "pg_publication_rel",
1259
+ "pg_subscription_rel",
1260
+ "pg_group",
1261
+ "pg_user",
1262
+ "pg_policies",
1263
+ "pg_rules",
1264
+ "pg_views",
1265
+ "pg_matviews",
1266
+ "pg_indexes",
1267
+ "pg_sequences",
1268
+ "pg_stats",
1269
+ "pg_stats_ext",
1270
+ "pg_stats_ext_exprs",
1271
+ "pg_publication_tables",
1272
+ "pg_locks",
1273
+ "pg_cursors",
1274
+ "pg_available_extensions",
1275
+ "pg_available_extension_versions",
1276
+ "pg_prepared_xacts",
1277
+ "pg_prepared_statements",
1278
+ "pg_seclabels",
1279
+ "pg_timezone_abbrevs",
1280
+ "pg_timezone_names",
1281
+ "pg_stat_all_tables",
1282
+ "pg_stat_xact_all_tables",
1283
+ "pg_stat_xact_user_tables",
1284
+ "pg_stat_sys_tables",
1285
+ "pg_stat_xact_sys_tables",
1286
+ "pg_stat_user_tables",
1287
+ "pg_statio_all_tables",
1288
+ "pg_statio_sys_tables",
1289
+ "pg_statio_user_tables",
1290
+ "pg_stat_all_indexes",
1291
+ "pg_stat_sys_indexes",
1292
+ "pg_stat_user_indexes",
1293
+ "pg_statio_all_indexes",
1294
+ "pg_statio_sys_indexes",
1295
+ "pg_statio_user_indexes",
1296
+ "pg_statio_sys_sequences",
1297
+ "pg_statio_user_sequences",
1298
+ "pg_stat_activity",
1299
+ "pg_stat_replication",
1300
+ "pg_stat_slru",
1301
+ "pg_stat_wal_receiver",
1302
+ "pg_stat_recovery_prefetch",
1303
+ "pg_stat_subscription",
1304
+ "pg_stat_ssl",
1305
+ "pg_stat_gssapi",
1306
+ "pg_replication_slots",
1307
+ "pg_stat_replication_slots",
1308
+ "pg_stat_database",
1309
+ "pg_stat_database_conflicts",
1310
+ "pg_stat_user_functions",
1311
+ "pg_stat_xact_user_functions",
1312
+ "pg_stat_archiver",
1313
+ "pg_stat_bgwriter",
1314
+ "pg_stat_io",
1315
+ "pg_stat_wal",
1316
+ "pg_stat_progress_analyze",
1317
+ "pg_stat_progress_vacuum",
1318
+ "pg_stat_progress_cluster",
1319
+ "pg_stat_progress_create_index",
1320
+ "pg_stat_progress_basebackup",
1321
+ "pg_stat_progress_copy",
1322
+ "pg_user_mappings",
1323
+ "pg_stat_subscription_stats",
1324
+ "pg_largeobject",
1325
+ ]);
1326
+ //# sourceMappingURL=sql-parse.js.map