@mistriwork/engine 0.0.0 → 1.0.0-rc.11

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 (572) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -1
  3. package/dist/adapters/adapter.d.ts +726 -0
  4. package/dist/adapters/adapter.js +444 -0
  5. package/dist/adapters/cache/cacheStore.d.ts +75 -0
  6. package/dist/adapters/cache/cacheStore.js +160 -0
  7. package/dist/adapters/cache/resp.d.ts +52 -0
  8. package/dist/adapters/cache/resp.js +237 -0
  9. package/dist/adapters/commands/canonicalJson.d.ts +19 -0
  10. package/dist/adapters/commands/canonicalJson.js +154 -0
  11. package/dist/adapters/connect.d.ts +29 -0
  12. package/dist/adapters/connect.js +40 -0
  13. package/dist/adapters/connectionBudget.d.ts +101 -0
  14. package/dist/adapters/connectionBudget.js +128 -0
  15. package/dist/adapters/dbLatency.d.ts +35 -0
  16. package/dist/adapters/dbLatency.js +79 -0
  17. package/dist/adapters/epochCache.d.ts +50 -0
  18. package/dist/adapters/epochCache.js +85 -0
  19. package/dist/adapters/http/egress.d.ts +48 -0
  20. package/dist/adapters/http/egress.js +175 -0
  21. package/dist/adapters/http/httpAdapter.d.ts +71 -0
  22. package/dist/adapters/http/httpAdapter.js +512 -0
  23. package/dist/adapters/http/httpDescription.d.ts +32 -0
  24. package/dist/adapters/http/httpDescription.js +246 -0
  25. package/dist/adapters/http/openapi.d.ts +98 -0
  26. package/dist/adapters/http/openapi.js +487 -0
  27. package/dist/adapters/layoutRefusal.d.ts +24 -0
  28. package/dist/adapters/layoutRefusal.js +35 -0
  29. package/dist/adapters/net/networkPolicy.d.ts +44 -0
  30. package/dist/adapters/net/networkPolicy.js +123 -0
  31. package/dist/adapters/net/untrustedDatabase.d.ts +18 -0
  32. package/dist/adapters/net/untrustedDatabase.js +120 -0
  33. package/dist/adapters/poolAdmission.d.ts +43 -0
  34. package/dist/adapters/poolAdmission.js +184 -0
  35. package/dist/adapters/poolMetrics.d.ts +121 -0
  36. package/dist/adapters/poolMetrics.js +185 -0
  37. package/dist/adapters/postgres.d.ts +441 -0
  38. package/dist/adapters/postgres.js +1841 -0
  39. package/dist/adapters/postgresCatalog.d.ts +107 -0
  40. package/dist/adapters/postgresCatalog.js +421 -0
  41. package/dist/adapters/postgresCatalogDigest.d.ts +30 -0
  42. package/dist/adapters/postgresCatalogDigest.js +93 -0
  43. package/dist/adapters/postgresCatalogRows.d.ts +64 -0
  44. package/dist/adapters/postgresCatalogRows.js +37 -0
  45. package/dist/adapters/postgresDates.d.ts +1 -0
  46. package/dist/adapters/postgresDates.js +39 -0
  47. package/dist/adapters/postgresMaintenance.d.ts +33 -0
  48. package/dist/adapters/postgresMaintenance.js +179 -0
  49. package/dist/adapters/postgresPool.d.ts +255 -0
  50. package/dist/adapters/postgresPool.js +838 -0
  51. package/dist/adapters/postgresPooler.d.ts +28 -0
  52. package/dist/adapters/postgresPooler.js +267 -0
  53. package/dist/adapters/postgresReadCatalog.d.ts +31 -0
  54. package/dist/adapters/postgresReadCatalog.js +226 -0
  55. package/dist/adapters/postgresReadSnapshot.d.ts +46 -0
  56. package/dist/adapters/postgresReadSnapshot.js +133 -0
  57. package/dist/adapters/postgresSchemaEpoch.d.ts +24 -0
  58. package/dist/adapters/postgresSchemaEpoch.js +149 -0
  59. package/dist/adapters/postgresTransactionHandle.d.ts +173 -0
  60. package/dist/adapters/postgresTransactionHandle.js +524 -0
  61. package/dist/adapters/postgresValues.d.ts +30 -0
  62. package/dist/adapters/postgresValues.js +75 -0
  63. package/dist/adapters/postgresWriteAhead.d.ts +47 -0
  64. package/dist/adapters/postgresWriteAhead.js +209 -0
  65. package/dist/adapters/replicas.d.ts +70 -0
  66. package/dist/adapters/replicas.js +208 -0
  67. package/dist/adapters/reservedSql.d.ts +38 -0
  68. package/dist/adapters/reservedSql.js +264 -0
  69. package/dist/adapters/rolePrivileges.d.ts +17 -0
  70. package/dist/adapters/rolePrivileges.js +22 -0
  71. package/dist/adapters/scoped/keyRows.d.ts +65 -0
  72. package/dist/adapters/scoped/keyRows.js +179 -0
  73. package/dist/adapters/scoped/keyTypes.d.ts +34 -0
  74. package/dist/adapters/scoped/keyTypes.js +66 -0
  75. package/dist/adapters/scoped/postgresScopeCatalog.d.ts +34 -0
  76. package/dist/adapters/scoped/postgresScopeCatalog.js +457 -0
  77. package/dist/adapters/scoped/postgresTriggers.d.ts +137 -0
  78. package/dist/adapters/scoped/postgresTriggers.js +1545 -0
  79. package/dist/adapters/scoped/scopeTriggers.d.ts +122 -0
  80. package/dist/adapters/scoped/scopeTriggers.js +131 -0
  81. package/dist/adapters/scoped/scopedCommandOperations.d.ts +5 -0
  82. package/dist/adapters/scoped/scopedCommandOperations.js +48 -0
  83. package/dist/adapters/scoped/scopedReads.d.ts +22 -0
  84. package/dist/adapters/scoped/scopedReads.js +192 -0
  85. package/dist/adapters/scoped/scopedTransaction.d.ts +159 -0
  86. package/dist/adapters/scoped/scopedTransaction.js +547 -0
  87. package/dist/adapters/scoped/sqliteScopeCatalog.d.ts +32 -0
  88. package/dist/adapters/scoped/sqliteScopeCatalog.js +420 -0
  89. package/dist/adapters/scoped/sqliteTriggerSession.d.ts +64 -0
  90. package/dist/adapters/scoped/sqliteTriggerSession.js +245 -0
  91. package/dist/adapters/scoped/sqliteTriggers.d.ts +20 -0
  92. package/dist/adapters/scoped/sqliteTriggers.js +822 -0
  93. package/dist/adapters/scoped/storedText.d.ts +45 -0
  94. package/dist/adapters/scoped/storedText.js +61 -0
  95. package/dist/adapters/scoped/triggerEffects.d.ts +98 -0
  96. package/dist/adapters/scoped/triggerEffects.js +189 -0
  97. package/dist/adapters/scoped/triggerProof.d.ts +124 -0
  98. package/dist/adapters/scoped/triggerProof.js +366 -0
  99. package/dist/adapters/scoped/updateGuard.d.ts +3 -0
  100. package/dist/adapters/scoped/updateGuard.js +40 -0
  101. package/dist/adapters/serverSettings.d.ts +45 -0
  102. package/dist/adapters/serverSettings.js +46 -0
  103. package/dist/adapters/snapshotRead.d.ts +8 -0
  104. package/dist/adapters/snapshotRead.js +37 -0
  105. package/dist/adapters/sqlite.d.ts +273 -0
  106. package/dist/adapters/sqlite.js +1557 -0
  107. package/dist/adapters/sqliteCostlyReads.d.ts +33 -0
  108. package/dist/adapters/sqliteCostlyReads.js +49 -0
  109. package/dist/adapters/sqliteDecimals.d.ts +22 -0
  110. package/dist/adapters/sqliteDecimals.js +51 -0
  111. package/dist/adapters/sqliteHandles.d.ts +43 -0
  112. package/dist/adapters/sqliteHandles.js +143 -0
  113. package/dist/adapters/sqliteStatementProcess.d.ts +29 -0
  114. package/dist/adapters/sqliteStatementProcess.js +131 -0
  115. package/dist/adapters/statementControl.d.ts +34 -0
  116. package/dist/adapters/statementControl.js +90 -0
  117. package/dist/adapters/storeHost.d.ts +133 -0
  118. package/dist/adapters/storeHost.js +13 -0
  119. package/dist/adapters/telemetry/drivers.d.ts +21 -0
  120. package/dist/adapters/telemetry/drivers.js +321 -0
  121. package/dist/adapters/telemetry/metrics.d.ts +63 -0
  122. package/dist/adapters/telemetry/metrics.js +122 -0
  123. package/dist/adapters/telemetry/otlp.d.ts +12 -0
  124. package/dist/adapters/telemetry/otlp.js +320 -0
  125. package/dist/adapters/telemetry/otlpEncode.d.ts +48 -0
  126. package/dist/adapters/telemetry/otlpEncode.js +366 -0
  127. package/dist/adapters/telemetry/otlpEnv.d.ts +1 -0
  128. package/dist/adapters/telemetry/otlpEnv.js +12 -0
  129. package/dist/adapters/telemetry/serverTiming.d.ts +83 -0
  130. package/dist/adapters/telemetry/serverTiming.js +503 -0
  131. package/dist/adapters/telemetry/start.d.ts +10 -0
  132. package/dist/adapters/telemetry/start.js +25 -0
  133. package/dist/adapters/telemetry/statement.d.ts +16 -0
  134. package/dist/adapters/telemetry/statement.js +134 -0
  135. package/dist/adapters/telemetry/trace.d.ts +127 -0
  136. package/dist/adapters/telemetry/trace.js +295 -0
  137. package/dist/adapters/writeAhead.d.ts +27 -0
  138. package/dist/adapters/writeAhead.js +46 -0
  139. package/dist/adapters/writeAttribution.d.ts +18 -0
  140. package/dist/adapters/writeAttribution.js +23 -0
  141. package/dist/adapters/writeCapture.d.ts +80 -0
  142. package/dist/adapters/writeCapture.js +20 -0
  143. package/dist/adapters/writeLanes.d.ts +94 -0
  144. package/dist/adapters/writeLanes.js +232 -0
  145. package/dist/engine.d.ts +15 -0
  146. package/dist/engine.js +13 -0
  147. package/dist/server/auth/credentials.d.ts +61 -0
  148. package/dist/server/auth/credentials.js +260 -0
  149. package/dist/server/cacheService.d.ts +50 -0
  150. package/dist/server/cacheService.js +110 -0
  151. package/dist/server/cli/args.d.ts +182 -0
  152. package/dist/server/cli/args.js +348 -0
  153. package/dist/server/cli/bin.d.ts +5 -0
  154. package/dist/server/cli/bin.js +66 -0
  155. package/dist/server/cli/browser.d.ts +15 -0
  156. package/dist/server/cli/browser.js +37 -0
  157. package/dist/server/cli/config.d.ts +50 -0
  158. package/dist/server/cli/config.js +206 -0
  159. package/dist/server/cli/startup.d.ts +36 -0
  160. package/dist/server/cli/startup.js +128 -0
  161. package/dist/server/cli/startupOptions.d.ts +63 -0
  162. package/dist/server/cli/startupOptions.js +143 -0
  163. package/dist/server/cli/subcommand.d.ts +28 -0
  164. package/dist/server/cli/subcommand.js +32 -0
  165. package/dist/server/cli/usage.d.ts +13 -0
  166. package/dist/server/cli/usage.js +31 -0
  167. package/dist/server/clientHttp.d.ts +184 -0
  168. package/dist/server/clientHttp.js +700 -0
  169. package/dist/server/clientSurface.d.ts +128 -0
  170. package/dist/server/clientSurface.js +182 -0
  171. package/dist/server/columnGrants.d.ts +106 -0
  172. package/dist/server/columnGrants.js +741 -0
  173. package/dist/server/compileCache.d.ts +1 -0
  174. package/dist/server/compileCache.js +30 -0
  175. package/dist/server/config/locations.d.ts +1 -0
  176. package/dist/server/config/locations.js +15 -0
  177. package/dist/server/config/profile.d.ts +123 -0
  178. package/dist/server/config/profile.js +236 -0
  179. package/dist/server/configPaths.d.ts +7 -0
  180. package/dist/server/configPaths.js +34 -0
  181. package/dist/server/configSections.d.ts +64 -0
  182. package/dist/server/configSections.js +72 -0
  183. package/dist/server/connectionRedaction.d.ts +30 -0
  184. package/dist/server/connectionRedaction.js +77 -0
  185. package/dist/server/connections.d.ts +358 -0
  186. package/dist/server/connections.js +988 -0
  187. package/dist/server/constraints.d.ts +82 -0
  188. package/dist/server/constraints.js +169 -0
  189. package/dist/server/demo.d.ts +9 -0
  190. package/dist/server/demo.js +554 -0
  191. package/dist/server/devclient.d.ts +108 -0
  192. package/dist/server/devclient.js +361 -0
  193. package/dist/server/evidence.d.ts +55 -0
  194. package/dist/server/evidence.js +323 -0
  195. package/dist/server/hiddenColumns.d.ts +32 -0
  196. package/dist/server/hiddenColumns.js +244 -0
  197. package/dist/server/http/baselineHeaders.d.ts +24 -0
  198. package/dist/server/http/baselineHeaders.js +12 -0
  199. package/dist/server/http/captured.d.ts +35 -0
  200. package/dist/server/http/captured.js +73 -0
  201. package/dist/server/http/clock.d.ts +1 -0
  202. package/dist/server/http/clock.js +14 -0
  203. package/dist/server/http/connectionSource.d.ts +4 -0
  204. package/dist/server/http/connectionSource.js +48 -0
  205. package/dist/server/http/context.d.ts +189 -0
  206. package/dist/server/http/context.js +11 -0
  207. package/dist/server/http/crawlerText.d.ts +15 -0
  208. package/dist/server/http/crawlerText.js +32 -0
  209. package/dist/server/http/dataRoutes.d.ts +88 -0
  210. package/dist/server/http/dataRoutes.js +137 -0
  211. package/dist/server/http/door.d.ts +57 -0
  212. package/dist/server/http/door.js +39 -0
  213. package/dist/server/http/exportRoute.d.ts +15 -0
  214. package/dist/server/http/exportRoute.js +320 -0
  215. package/dist/server/http/firstPaint.d.ts +108 -0
  216. package/dist/server/http/firstPaint.js +262 -0
  217. package/dist/server/http/httpOperationRoutes.d.ts +11 -0
  218. package/dist/server/http/httpOperationRoutes.js +50 -0
  219. package/dist/server/http/pageReads.d.ts +20 -0
  220. package/dist/server/http/pageReads.js +205 -0
  221. package/dist/server/http/pageRoutes.d.ts +39 -0
  222. package/dist/server/http/pageRoutes.js +291 -0
  223. package/dist/server/http/probes.d.ts +22 -0
  224. package/dist/server/http/probes.js +27 -0
  225. package/dist/server/http/rateLimit.d.ts +131 -0
  226. package/dist/server/http/rateLimit.js +351 -0
  227. package/dist/server/http/readRoutes.d.ts +9 -0
  228. package/dist/server/http/readRoutes.js +131 -0
  229. package/dist/server/http/readRouting.d.ts +20 -0
  230. package/dist/server/http/readRouting.js +80 -0
  231. package/dist/server/http/recordCompose.d.ts +67 -0
  232. package/dist/server/http/recordCompose.js +167 -0
  233. package/dist/server/http/recordWrites.d.ts +89 -0
  234. package/dist/server/http/recordWrites.js +298 -0
  235. package/dist/server/http/refusalReport.d.ts +38 -0
  236. package/dist/server/http/refusalReport.js +75 -0
  237. package/dist/server/http/reply.d.ts +130 -0
  238. package/dist/server/http/reply.js +394 -0
  239. package/dist/server/http/requestOrigin.d.ts +11 -0
  240. package/dist/server/http/requestOrigin.js +8 -0
  241. package/dist/server/http/router.d.ts +45 -0
  242. package/dist/server/http/router.js +22 -0
  243. package/dist/server/http/serverCore.d.ts +68 -0
  244. package/dist/server/http/serverCore.js +177 -0
  245. package/dist/server/http/traceRequest.d.ts +30 -0
  246. package/dist/server/http/traceRequest.js +224 -0
  247. package/dist/server/http/trust.d.ts +261 -0
  248. package/dist/server/http/trust.js +472 -0
  249. package/dist/server/http/writeRefusal.d.ts +33 -0
  250. package/dist/server/http/writeRefusal.js +24 -0
  251. package/dist/server/httpConnection.d.ts +49 -0
  252. package/dist/server/httpConnection.js +170 -0
  253. package/dist/server/impact.d.ts +55 -0
  254. package/dist/server/impact.js +47 -0
  255. package/dist/server/journal.d.ts +134 -0
  256. package/dist/server/journal.js +398 -0
  257. package/dist/server/keysetReadHttp.d.ts +52 -0
  258. package/dist/server/keysetReadHttp.js +85 -0
  259. package/dist/server/layouts.d.ts +49 -0
  260. package/dist/server/layouts.js +192 -0
  261. package/dist/server/migrate/cli.d.ts +102 -0
  262. package/dist/server/migrate/cli.js +702 -0
  263. package/dist/server/migrate/database.d.ts +37 -0
  264. package/dist/server/migrate/database.js +247 -0
  265. package/dist/server/migrate/desired.d.ts +76 -0
  266. package/dist/server/migrate/desired.js +292 -0
  267. package/dist/server/migrate/files.d.ts +34 -0
  268. package/dist/server/migrate/files.js +141 -0
  269. package/dist/server/migrate/flyway.d.ts +7 -0
  270. package/dist/server/migrate/flyway.js +69 -0
  271. package/dist/server/migrate/history.d.ts +70 -0
  272. package/dist/server/migrate/history.js +211 -0
  273. package/dist/server/migrate/runner.d.ts +100 -0
  274. package/dist/server/migrate/runner.js +413 -0
  275. package/dist/server/migrate/snapshot.d.ts +30 -0
  276. package/dist/server/migrate/snapshot.js +239 -0
  277. package/dist/server/migrate/target.d.ts +33 -0
  278. package/dist/server/migrate/target.js +82 -0
  279. package/dist/server/openapiDraft.d.ts +25 -0
  280. package/dist/server/openapiDraft.js +171 -0
  281. package/dist/server/operations/diagnostics.d.ts +101 -0
  282. package/dist/server/operations/diagnostics.js +284 -0
  283. package/dist/server/operations/requestMetrics.d.ts +33 -0
  284. package/dist/server/operations/requestMetrics.js +94 -0
  285. package/dist/server/packageVersion.d.ts +1 -0
  286. package/dist/server/packageVersion.js +11 -0
  287. package/dist/server/poolConfig.d.ts +34 -0
  288. package/dist/server/poolConfig.js +114 -0
  289. package/dist/server/product.d.ts +20 -0
  290. package/dist/server/product.js +12 -0
  291. package/dist/server/recordHistoryOperations.d.ts +39 -0
  292. package/dist/server/recordHistoryOperations.js +43 -0
  293. package/dist/server/recordWriteOperations.d.ts +111 -0
  294. package/dist/server/recordWriteOperations.js +329 -0
  295. package/dist/server/resourceReadHttp.d.ts +81 -0
  296. package/dist/server/resourceReadHttp.js +606 -0
  297. package/dist/server/resourceReadOperations.d.ts +147 -0
  298. package/dist/server/resourceReadOperations.js +452 -0
  299. package/dist/server/scaffoldMachine.d.ts +54 -0
  300. package/dist/server/scaffoldMachine.js +184 -0
  301. package/dist/server/seed/cli.d.ts +20 -0
  302. package/dist/server/seed/cli.js +164 -0
  303. package/dist/server/seed/lexicon.d.ts +26 -0
  304. package/dist/server/seed/lexicon.js +585 -0
  305. package/dist/server/seed/seed.d.ts +70 -0
  306. package/dist/server/seed/seed.js +779 -0
  307. package/dist/server/seed/words.d.ts +21 -0
  308. package/dist/server/seed/words.js +164 -0
  309. package/dist/server/serverRequests.d.ts +6 -0
  310. package/dist/server/serverRequests.js +33 -0
  311. package/dist/server/serverTimeouts.d.ts +33 -0
  312. package/dist/server/serverTimeouts.js +32 -0
  313. package/dist/server/shapeonly.d.ts +32 -0
  314. package/dist/server/shapeonly.js +115 -0
  315. package/dist/server/startupWarnings.d.ts +32 -0
  316. package/dist/server/startupWarnings.js +92 -0
  317. package/dist/shared/addressParams.d.ts +28 -0
  318. package/dist/shared/addressParams.js +47 -0
  319. package/dist/shared/aggregate.d.ts +49 -0
  320. package/dist/shared/aggregate.js +107 -0
  321. package/dist/shared/appCards.d.ts +123 -0
  322. package/dist/shared/appCards.js +385 -0
  323. package/dist/shared/appComponents.d.ts +177 -0
  324. package/dist/shared/appComponents.js +422 -0
  325. package/dist/shared/appDocuments.d.ts +43 -0
  326. package/dist/shared/appDocuments.js +131 -0
  327. package/dist/shared/appEmbeds.d.ts +21 -0
  328. package/dist/shared/appEmbeds.js +24 -0
  329. package/dist/shared/appIcons.d.ts +28 -0
  330. package/dist/shared/appIcons.js +223 -0
  331. package/dist/shared/appLinks.d.ts +17 -0
  332. package/dist/shared/appLinks.js +124 -0
  333. package/dist/shared/appListColumns.d.ts +3 -0
  334. package/dist/shared/appListColumns.js +66 -0
  335. package/dist/shared/appLocale.d.ts +36 -0
  336. package/dist/shared/appLocale.js +86 -0
  337. package/dist/shared/appMessages.d.ts +44 -0
  338. package/dist/shared/appMessages.js +78 -0
  339. package/dist/shared/appNoun.d.ts +21 -0
  340. package/dist/shared/appNoun.js +32 -0
  341. package/dist/shared/autoBucket.d.ts +98 -0
  342. package/dist/shared/autoBucket.js +305 -0
  343. package/dist/shared/autoValues.d.ts +25 -0
  344. package/dist/shared/autoValues.js +25 -0
  345. package/dist/shared/breakdown.d.ts +228 -0
  346. package/dist/shared/breakdown.js +570 -0
  347. package/dist/shared/breakdowntext.d.ts +41 -0
  348. package/dist/shared/breakdowntext.js +400 -0
  349. package/dist/shared/builtInThemes.d.ts +2 -0
  350. package/dist/shared/builtInThemes.js +771 -0
  351. package/dist/shared/chartSeparation.d.ts +11 -0
  352. package/dist/shared/chartSeparation.js +58 -0
  353. package/dist/shared/clauses.d.ts +22 -0
  354. package/dist/shared/clauses.js +97 -0
  355. package/dist/shared/columnCaption.d.ts +16 -0
  356. package/dist/shared/columnCaption.js +90 -0
  357. package/dist/shared/commandFieldPath.d.ts +2 -0
  358. package/dist/shared/commandFieldPath.js +7 -0
  359. package/dist/shared/commandWire.d.ts +26 -0
  360. package/dist/shared/commandWire.js +41 -0
  361. package/dist/shared/computed.d.ts +161 -0
  362. package/dist/shared/computed.js +378 -0
  363. package/dist/shared/computedParse.d.ts +13 -0
  364. package/dist/shared/computedParse.js +278 -0
  365. package/dist/shared/computedValue.d.ts +47 -0
  366. package/dist/shared/computedValue.js +191 -0
  367. package/dist/shared/connection.d.ts +30 -0
  368. package/dist/shared/connection.js +1 -0
  369. package/dist/shared/csv.d.ts +20 -0
  370. package/dist/shared/csv.js +63 -0
  371. package/dist/shared/dashLayout.d.ts +30 -0
  372. package/dist/shared/dashLayout.js +132 -0
  373. package/dist/shared/dashboardAsks.d.ts +93 -0
  374. package/dist/shared/dashboardAsks.js +129 -0
  375. package/dist/shared/dashboardTrend.d.ts +20 -0
  376. package/dist/shared/dashboardTrend.js +50 -0
  377. package/dist/shared/decimals.d.ts +37 -0
  378. package/dist/shared/decimals.js +148 -0
  379. package/dist/shared/declaredReferences.d.ts +50 -0
  380. package/dist/shared/declaredReferences.js +202 -0
  381. package/dist/shared/definedFields.d.ts +63 -0
  382. package/dist/shared/definedFields.js +103 -0
  383. package/dist/shared/definedValues.d.ts +63 -0
  384. package/dist/shared/definedValues.js +184 -0
  385. package/dist/shared/displayDefaults.d.ts +135 -0
  386. package/dist/shared/displayDefaults.js +543 -0
  387. package/dist/shared/dueDate.d.ts +6 -0
  388. package/dist/shared/dueDate.js +6 -0
  389. package/dist/shared/duration.d.ts +4 -0
  390. package/dist/shared/duration.js +23 -0
  391. package/dist/shared/fileBounds.d.ts +9 -0
  392. package/dist/shared/fileBounds.js +9 -0
  393. package/dist/shared/filter.d.ts +238 -0
  394. package/dist/shared/filter.js +332 -0
  395. package/dist/shared/firstPaint.d.ts +24 -0
  396. package/dist/shared/firstPaint.js +33 -0
  397. package/dist/shared/form.d.ts +21 -0
  398. package/dist/shared/form.js +25 -0
  399. package/dist/shared/formValues.d.ts +104 -0
  400. package/dist/shared/formValues.js +352 -0
  401. package/dist/shared/funnel.d.ts +45 -0
  402. package/dist/shared/funnel.js +108 -0
  403. package/dist/shared/httpOperations.d.ts +48 -0
  404. package/dist/shared/httpOperations.js +9 -0
  405. package/dist/shared/iconGlyphs.d.ts +4 -0
  406. package/dist/shared/iconGlyphs.js +151 -0
  407. package/dist/shared/iconWeights.d.ts +3 -0
  408. package/dist/shared/iconWeights.js +162 -0
  409. package/dist/shared/imageWidths.d.ts +32 -0
  410. package/dist/shared/imageWidths.js +38 -0
  411. package/dist/shared/keysetPage.d.ts +64 -0
  412. package/dist/shared/keysetPage.js +161 -0
  413. package/dist/shared/like.d.ts +20 -0
  414. package/dist/shared/like.js +29 -0
  415. package/dist/shared/listEmpty.d.ts +12 -0
  416. package/dist/shared/listEmpty.js +36 -0
  417. package/dist/shared/listFilters.d.ts +28 -0
  418. package/dist/shared/listFilters.js +84 -0
  419. package/dist/shared/listPresentations.d.ts +199 -0
  420. package/dist/shared/listPresentations.js +7 -0
  421. package/dist/shared/listQuestion.d.ts +52 -0
  422. package/dist/shared/listQuestion.js +137 -0
  423. package/dist/shared/lookPalettes.d.ts +62 -0
  424. package/dist/shared/lookPalettes.js +306 -0
  425. package/dist/shared/maskQuoted.d.ts +24 -0
  426. package/dist/shared/maskQuoted.js +48 -0
  427. package/dist/shared/mentionLabel.d.ts +19 -0
  428. package/dist/shared/mentionLabel.js +38 -0
  429. package/dist/shared/mentionLookup.d.ts +17 -0
  430. package/dist/shared/mentionLookup.js +64 -0
  431. package/dist/shared/menuCounts.d.ts +16 -0
  432. package/dist/shared/menuCounts.js +74 -0
  433. package/dist/shared/model.d.ts +79 -0
  434. package/dist/shared/model.js +153 -0
  435. package/dist/shared/money.d.ts +53 -0
  436. package/dist/shared/money.js +98 -0
  437. package/dist/shared/moneyEntry.d.ts +7 -0
  438. package/dist/shared/moneyEntry.js +27 -0
  439. package/dist/shared/mount.d.ts +118 -0
  440. package/dist/shared/mount.js +248 -0
  441. package/dist/shared/niceTicks.d.ts +26 -0
  442. package/dist/shared/niceTicks.js +50 -0
  443. package/dist/shared/order.d.ts +59 -0
  444. package/dist/shared/order.js +133 -0
  445. package/dist/shared/page.d.ts +135 -0
  446. package/dist/shared/page.js +1187 -0
  447. package/dist/shared/pageAnatomy.d.ts +99 -0
  448. package/dist/shared/pageAnatomy.js +370 -0
  449. package/dist/shared/pageConfig.d.ts +25 -0
  450. package/dist/shared/pageConfig.js +1308 -0
  451. package/dist/shared/pageEmptyActions.d.ts +12 -0
  452. package/dist/shared/pageEmptyActions.js +20 -0
  453. package/dist/shared/pageLayouts.d.ts +72 -0
  454. package/dist/shared/pageLayouts.js +205 -0
  455. package/dist/shared/pageModel.d.ts +785 -0
  456. package/dist/shared/pageModel.js +121 -0
  457. package/dist/shared/pagePaths.d.ts +180 -0
  458. package/dist/shared/pagePaths.js +869 -0
  459. package/dist/shared/pagePlans.d.ts +52 -0
  460. package/dist/shared/pagePlans.js +108 -0
  461. package/dist/shared/pageRoutes.d.ts +9 -0
  462. package/dist/shared/pageRoutes.js +9 -0
  463. package/dist/shared/query.d.ts +166 -0
  464. package/dist/shared/query.js +1302 -0
  465. package/dist/shared/queryDates.d.ts +12 -0
  466. package/dist/shared/queryDates.js +101 -0
  467. package/dist/shared/queryOperands.d.ts +99 -0
  468. package/dist/shared/queryOperands.js +131 -0
  469. package/dist/shared/reads.d.ts +103 -0
  470. package/dist/shared/reads.js +154 -0
  471. package/dist/shared/recordLabel.d.ts +51 -0
  472. package/dist/shared/recordLabel.js +123 -0
  473. package/dist/shared/recordReadKeys.d.ts +30 -0
  474. package/dist/shared/recordReadKeys.js +51 -0
  475. package/dist/shared/recordReads.d.ts +268 -0
  476. package/dist/shared/recordReads.js +368 -0
  477. package/dist/shared/recordview.d.ts +198 -0
  478. package/dist/shared/recordview.js +356 -0
  479. package/dist/shared/referenceModel.d.ts +58 -0
  480. package/dist/shared/referenceModel.js +194 -0
  481. package/dist/shared/refusal.d.ts +80 -0
  482. package/dist/shared/refusal.js +184 -0
  483. package/dist/shared/relatedCreate.d.ts +30 -0
  484. package/dist/shared/relatedCreate.js +162 -0
  485. package/dist/shared/resourceHttp.d.ts +464 -0
  486. package/dist/shared/resourceHttp.js +1 -0
  487. package/dist/shared/richText.d.ts +85 -0
  488. package/dist/shared/richText.js +305 -0
  489. package/dist/shared/rollups.d.ts +143 -0
  490. package/dist/shared/rollups.js +64 -0
  491. package/dist/shared/rowScope.d.ts +72 -0
  492. package/dist/shared/rowScope.js +376 -0
  493. package/dist/shared/runtimeTables.d.ts +44 -0
  494. package/dist/shared/runtimeTables.js +79 -0
  495. package/dist/shared/schema.d.ts +529 -0
  496. package/dist/shared/schema.js +627 -0
  497. package/dist/shared/schematext.d.ts +38 -0
  498. package/dist/shared/schematext.js +101 -0
  499. package/dist/shared/scopeCatalog.d.ts +29 -0
  500. package/dist/shared/scopeCatalog.js +472 -0
  501. package/dist/shared/servedApp.d.ts +686 -0
  502. package/dist/shared/servedApp.js +45 -0
  503. package/dist/shared/sessionLease.d.ts +34 -0
  504. package/dist/shared/sessionLease.js +3 -0
  505. package/dist/shared/shape.d.ts +55 -0
  506. package/dist/shared/shape.js +168 -0
  507. package/dist/shared/slug.d.ts +1 -0
  508. package/dist/shared/slug.js +12 -0
  509. package/dist/shared/sortText.d.ts +14 -0
  510. package/dist/shared/sortText.js +26 -0
  511. package/dist/shared/sqlRelation.d.ts +4 -0
  512. package/dist/shared/sqlRelation.js +8 -0
  513. package/dist/shared/sqlsaved.d.ts +44 -0
  514. package/dist/shared/sqlsaved.js +63 -0
  515. package/dist/shared/stitchedPaths.d.ts +27 -0
  516. package/dist/shared/stitchedPaths.js +38 -0
  517. package/dist/shared/structuredFilter.d.ts +22 -0
  518. package/dist/shared/structuredFilter.js +1 -0
  519. package/dist/shared/subtitlePath.d.ts +20 -0
  520. package/dist/shared/subtitlePath.js +24 -0
  521. package/dist/shared/suggest.d.ts +18 -0
  522. package/dist/shared/suggest.js +59 -0
  523. package/dist/shared/tableSizing.d.ts +4 -0
  524. package/dist/shared/tableSizing.js +9 -0
  525. package/dist/shared/tagLists.d.ts +57 -0
  526. package/dist/shared/tagLists.js +34 -0
  527. package/dist/shared/textRules.d.ts +54 -0
  528. package/dist/shared/textRules.js +133 -0
  529. package/dist/shared/theme.d.ts +94 -0
  530. package/dist/shared/theme.js +800 -0
  531. package/dist/shared/themeColor.d.ts +34 -0
  532. package/dist/shared/themeColor.js +109 -0
  533. package/dist/shared/themeFaces.d.ts +30 -0
  534. package/dist/shared/themeFaces.js +42 -0
  535. package/dist/shared/themeInk.d.ts +20 -0
  536. package/dist/shared/themeInk.js +52 -0
  537. package/dist/shared/themeLooks.d.ts +9 -0
  538. package/dist/shared/themeLooks.js +572 -0
  539. package/dist/shared/themeParts.d.ts +26 -0
  540. package/dist/shared/themeParts.js +71 -0
  541. package/dist/shared/themePartsCheck.d.ts +21 -0
  542. package/dist/shared/themePartsCheck.js +91 -0
  543. package/dist/shared/themePresets.d.ts +85 -0
  544. package/dist/shared/themePresets.js +139 -0
  545. package/dist/shared/themeRecipeWords.d.ts +156 -0
  546. package/dist/shared/themeRecipeWords.js +156 -0
  547. package/dist/shared/themeRecipes.d.ts +213 -0
  548. package/dist/shared/themeRecipes.js +234 -0
  549. package/dist/shared/themeResolve.d.ts +55 -0
  550. package/dist/shared/themeResolve.js +52 -0
  551. package/dist/shared/themeTokens.d.ts +107 -0
  552. package/dist/shared/themeTokens.js +116 -0
  553. package/dist/shared/themeType.d.ts +38 -0
  554. package/dist/shared/themeType.js +205 -0
  555. package/dist/shared/unitWord.d.ts +4 -0
  556. package/dist/shared/unitWord.js +37 -0
  557. package/dist/shared/view.d.ts +195 -0
  558. package/dist/shared/view.js +987 -0
  559. package/dist/shared/viewLabels.d.ts +47 -0
  560. package/dist/shared/viewLabels.js +459 -0
  561. package/dist/shared/viewPaths.d.ts +248 -0
  562. package/dist/shared/viewPaths.js +294 -0
  563. package/dist/shared/viewtext.d.ts +57 -0
  564. package/dist/shared/viewtext.js +282 -0
  565. package/dist/shared/vocabulary.d.ts +71 -0
  566. package/dist/shared/vocabulary.js +249 -0
  567. package/dist/shared/weekStart.d.ts +7 -0
  568. package/dist/shared/weekStart.js +36 -0
  569. package/mark.svg +1 -0
  570. package/package.json +266 -3
  571. package/schema/model.d.ts +298 -0
  572. package/schema/theme.d.ts +587 -0
@@ -0,0 +1,107 @@
1
+ /**
2
+ * PostgreSQL introspection: the catalog queries that describe a database, and
3
+ * the one reading of the rows they return.
4
+ *
5
+ * It sits apart from the adapter because describing a database is a different
6
+ * job from connecting to one, querying it or writing to it — and because it is
7
+ * the half that carries an invariant of its own. Every query here has an
8
+ * explicit ORDER BY: the catalog promises no order, so without them the same
9
+ * server may hand back a table's two foreign keys either way round, its
10
+ * indexed columns in any order and its checks in any order, and a description
11
+ * taken twice then differs with nothing changed underneath it. The ordering is
12
+ * the point of this module rather than decoration, and `test/postgres.test.ts`
13
+ * ("two reads of one database describe it identically") is what holds it.
14
+ *
15
+ * Where SQLite hands you a per-table PRAGMA, Postgres hands you a catalog you
16
+ * can query in one shot. That difference is worth exploiting: introspection
17
+ * here is a fixed handful of queries regardless of how many tables exist, which
18
+ * matters the first time someone points this at a schema with four hundred of
19
+ * them.
20
+ *
21
+ * The queries below read `information_schema` for columns and `pg_catalog` for
22
+ * keys, checks and row estimates. `information_schema` is the portable half but
23
+ * it has no cheap row count and describes composite keys awkwardly;
24
+ * `pg_catalog` carries both, at the cost of being Postgres-specific. Since we
25
+ * are already inside the Postgres adapter, that cost is zero.
26
+ */
27
+ import { type DatabaseSchema } from '../shared/schema.js';
28
+ import type { EpochCache } from './epochCache.js';
29
+ import type { PgQuery } from './postgresPool.js';
30
+ import { type SqlStyle } from '../shared/filter.js';
31
+ /** The style row-scoped reads compile with on this server: POSTGRES_INLINE_STYLE
32
+ * from 12, where `AS NOT MATERIALIZED` exists; before it, every CTE is
33
+ * materialized anyway and the words would be a syntax error. */
34
+ export declare function postgresScopeStyle(db: PgQuery): Promise<SqlStyle>;
35
+ export declare const SYSTEM_SCHEMAS: string[];
36
+ /**
37
+ * A relation that belongs to an extension is the extension's, not the App's:
38
+ * PlanetScale preinstalls hypopg (its views, in `pscale_extensions`) in every
39
+ * database and PostGIS brings `spatial_ref_sys` to Neon and Supabase, none of
40
+ * which the App declared and a tenant policy can name no owner for. Extension
41
+ * membership is a `pg_depend` row with `deptype = 'e'` on `pg_extension`; the
42
+ * description and the catalog digest both leave such relations out, so they
43
+ * agree. `alias` is the `pg_class` row's alias in the caller's query.
44
+ */
45
+ export declare function notExtensionMember(alias: string): string;
46
+ /** The adapter as its own description names it: the schemas it was pointed at,
47
+ * and what it calls itself. Passed per description rather than captured, so the
48
+ * leased writer inside a scoped transaction describes the same reach as the
49
+ * reader does on connect. */
50
+ interface CatalogSource {
51
+ readonly schemas: readonly string[];
52
+ readonly label: string;
53
+ readonly dialect: 'postgres';
54
+ }
55
+ export declare function describePostgresCatalog(db: PgQuery, source: CatalogSource): Promise<DatabaseSchema>;
56
+ /** Where a table is, and whether writing to it makes sense. */
57
+ export interface Located {
58
+ kind: string;
59
+ schema: string;
60
+ name: string;
61
+ isView: boolean;
62
+ }
63
+ /** One column, as the write path needs it: name, type, null-ness, key-ness. */
64
+ export interface PgColumnRow {
65
+ name: string;
66
+ /** Its declared type, as format_type says it: a domain by its own name. What a protected edit compares by (updateGuard.ts). */
67
+ type: string;
68
+ /** The type a value is coerced for (writtenType): a domain's base type. Used for input coercion only. */
69
+ written: string;
70
+ notnull: boolean;
71
+ is_pk: boolean;
72
+ }
73
+ /**
74
+ * The write path, on its own handle.
75
+ *
76
+ * Every reader carries `default_transaction_read_only = on`. A separate
77
+ * writer pool is opened on the first edit: a connection that can write
78
+ * should exist because somebody wrote, not because somebody connected.
79
+ *
80
+ * Every guard below is the SQLite adapter's, one for one. An edit refused on
81
+ * SQLite and allowed on Postgres would mean the safety of a cell editor
82
+ * depended on which database it was pointed at.
83
+ *
84
+ * A table's columns as the catalog has them now, not as they were on connect.
85
+ *
86
+ * `information_schema` would do for the names and types, but not for the
87
+ * primary key — it describes a composite one across two more views — and
88
+ * the key is the whole safety argument for a write. `pg_catalog` answers
89
+ * both in one query, and this is the Postgres adapter, so being
90
+ * Postgres-specific costs nothing.
91
+ *
92
+ * Read per write rather than from the cached schema: a column added since
93
+ * the connection opened is a column the editor should be able to write, and
94
+ * one dropped since is one it must not.
95
+ */
96
+ /**
97
+ * A column's type as a write coerces a value for it (shared/schema.ts coerceForColumn), from the column's type and
98
+ * modifier expressions: with its domains unwrapped through pg_type.typbasetype, the modifier the innermost one that
99
+ * has one gives, said by format_type. A domain over integer is then an integer column, so "" is NULL and "7.0" is 7,
100
+ * as they are for a column declared integer; by the domain's own name the write sent them as text, which the domain's
101
+ * input refused. The scope's parent check coerces a reference by the same text (postgresScopeCatalog.ts). Every
102
+ * function and operator in pg_catalog, as the scope's reads name them.
103
+ */
104
+ export declare const writtenType: (type: string, typmod: string) => string;
105
+ export declare function postgresColumnsOf(schema: string, name: string, db: PgQuery | undefined, epoch: string | undefined, cache: EpochCache<unknown>, connect: () => Promise<PgQuery>): Promise<PgColumnRow[]>;
106
+ export declare function assertPostgresTable(id: string, db: PgQuery | undefined, epoch: string | undefined, cache: EpochCache<unknown>, connect: () => Promise<PgQuery>): Promise<Located>;
107
+ export {};
@@ -0,0 +1,421 @@
1
+ /**
2
+ * PostgreSQL introspection: the catalog queries that describe a database, and
3
+ * the one reading of the rows they return.
4
+ *
5
+ * It sits apart from the adapter because describing a database is a different
6
+ * job from connecting to one, querying it or writing to it — and because it is
7
+ * the half that carries an invariant of its own. Every query here has an
8
+ * explicit ORDER BY: the catalog promises no order, so without them the same
9
+ * server may hand back a table's two foreign keys either way round, its
10
+ * indexed columns in any order and its checks in any order, and a description
11
+ * taken twice then differs with nothing changed underneath it. The ordering is
12
+ * the point of this module rather than decoration, and `test/postgres.test.ts`
13
+ * ("two reads of one database describe it identically") is what holds it.
14
+ *
15
+ * Where SQLite hands you a per-table PRAGMA, Postgres hands you a catalog you
16
+ * can query in one shot. That difference is worth exploiting: introspection
17
+ * here is a fixed handful of queries regardless of how many tables exist, which
18
+ * matters the first time someone points this at a schema with four hundred of
19
+ * them.
20
+ *
21
+ * The queries below read `information_schema` for columns and `pg_catalog` for
22
+ * keys, checks and row estimates. `information_schema` is the portable half but
23
+ * it has no cheap row count and describes composite keys awkwardly;
24
+ * `pg_catalog` carries both, at the cost of being Postgres-specific. Since we
25
+ * are already inside the Postgres adapter, that cost is zero.
26
+ */
27
+ import { chooseColumnReference, columnKind, deleteRuleOf, } from '../shared/schema.js';
28
+ import { checkFlag, checksIn } from '../shared/vocabulary.js';
29
+ import { catalogTextRule } from '../shared/textRules.js';
30
+ import { checkedText, firstVocabulary, postgresRowEstimate, } from './postgresCatalogRows.js';
31
+ import { Refusal } from './adapter.js';
32
+ import { RESERVED_SCHEMAS } from './reservedSql.js';
33
+ import { POSTGRES_INLINE_STYLE, POSTGRES_STYLE } from '../shared/filter.js';
34
+ /** The style row-scoped reads compile with on this server: POSTGRES_INLINE_STYLE
35
+ * from 12, where `AS NOT MATERIALIZED` exists; before it, every CTE is
36
+ * materialized anyway and the words would be a syntax error. */
37
+ export async function postgresScopeStyle(db) {
38
+ const result = await db.query(`SELECT current_setting('server_version_num')::int AS version`);
39
+ return Number(result.rows[0]?.version) >= 120_000 ? POSTGRES_INLINE_STYLE : POSTGRES_STYLE;
40
+ }
41
+ /** Schemas that are the server's own business, not the user's data. */
42
+ /** pg_catalog's own equality, which no operator of the same name elsewhere on the search_path can stand in for. */
43
+ const EQ = 'OPERATOR(pg_catalog.=)';
44
+ const NE = 'OPERATOR(pg_catalog.<>)';
45
+ export const SYSTEM_SCHEMAS = ['pg_catalog', 'information_schema', 'pg_toast'];
46
+ /**
47
+ * A relation that belongs to an extension is the extension's, not the App's:
48
+ * PlanetScale preinstalls hypopg (its views, in `pscale_extensions`) in every
49
+ * database and PostGIS brings `spatial_ref_sys` to Neon and Supabase, none of
50
+ * which the App declared and a tenant policy can name no owner for. Extension
51
+ * membership is a `pg_depend` row with `deptype = 'e'` on `pg_extension`; the
52
+ * description and the catalog digest both leave such relations out, so they
53
+ * agree. `alias` is the `pg_class` row's alias in the caller's query.
54
+ */
55
+ export function notExtensionMember(alias) {
56
+ return `NOT EXISTS (SELECT 1 FROM pg_catalog.pg_depend ext
57
+ WHERE ext.classid ${EQ} 'pg_catalog.pg_class'::regclass AND ext.objid ${EQ} ${alias}.oid
58
+ AND ext.refclassid ${EQ} 'pg_catalog.pg_extension'::regclass AND ext.deptype ${EQ} 'e')`;
59
+ }
60
+ export async function describePostgresCatalog(db, source) {
61
+ const filterSchemas = source.schemas.length ? `AND n.nspname = ANY($1)` : `AND n.nspname <> ALL($1)`;
62
+ const schemaParam = source.schemas.length
63
+ ? source.schemas.filter((schema) => !RESERVED_SCHEMAS.includes(schema))
64
+ : [...SYSTEM_SCHEMAS, ...RESERVED_SCHEMAS];
65
+ /* 1. Relations, with the planner's row estimate.
66
+ `reltuples` is an estimate, not a count, and is labelled as such in
67
+ the UI. An exact count on a large table is a sequential scan, which
68
+ is a strange thing for a schema browser to do on connect. */
69
+ const rels = await db.query(`SELECT n.nspname AS table_schema,
70
+ c.relname AS table_name,
71
+ c.relkind AS kind,
72
+ CASE WHEN c.reltuples < 0 THEN NULL ELSE c.reltuples END AS approx_rows,
73
+ obj_description(c.oid) AS comment
74
+ FROM pg_class c
75
+ JOIN pg_namespace n ON n.oid = c.relnamespace
76
+ WHERE c.relkind IN ('r','v','m','p','f')
77
+ AND ${notExtensionMember('c')}
78
+ ${filterSchemas}
79
+ /* Temporary tables belong to one session. Another session's show
80
+ in pg_class but not in information_schema, so they would arrive
81
+ with no columns, and none of them is anything to browse. */
82
+ AND n.nspname !~ '^pg_(toast_)?temp_'
83
+ ORDER BY n.nspname, c.relname`, [schemaParam]);
84
+ const relRows = rels.rows;
85
+ const wanted = new Set(relRows.map((r) => `${r.table_schema}.${r.table_name}`));
86
+ /* 2. Columns, in one pass over information_schema. */
87
+ const cols = await db.query(
88
+ /* `col_description` joined on rather than left out.
89
+
90
+ A column comment is the table's own documentation — the one place a
91
+ schema explains itself — and SQLite has none to read. It lives in `pg_description` rather
92
+ than `information_schema`, which is why it needs the join. */
93
+ `SELECT c.table_schema, c.table_name, c.column_name, c.data_type,
94
+ c.is_nullable, c.column_default, c.ordinal_position, c.is_identity, c.identity_generation, c.is_generated,
95
+ c.character_maximum_length, c.numeric_scale,
96
+ col_description(pc.oid, c.ordinal_position::int) AS comment,
97
+ /* Cast to text before aggregating: enumlabel has type "name",
98
+ and the driver hands a name[] back as the literal string
99
+ '{open,held,closed}' rather than an array — the same value,
100
+ typed as something no caller can use. */
101
+ (SELECT array_agg(e.enumlabel::text ORDER BY e.enumsortorder)
102
+ FROM pg_enum e
103
+ JOIN pg_type t ON t.oid = e.enumtypid
104
+ JOIN pg_namespace tn ON tn.oid = t.typnamespace
105
+ WHERE t.typname = c.udt_name AND tn.nspname = c.udt_schema) AS enum_labels
106
+ FROM information_schema.columns c
107
+ LEFT JOIN pg_namespace pn ON pn.nspname = c.table_schema
108
+ LEFT JOIN pg_class pc ON pc.relname = c.table_name AND pc.relnamespace = pn.oid
109
+ WHERE c.table_schema ${source.schemas.length ? '= ANY($1)' : '<> ALL($1)'}
110
+ ORDER BY c.table_schema, c.table_name, c.ordinal_position`, [schemaParam]);
111
+ /* Checks, for the other half of the vocabulary. A `status text CHECK
112
+ (status IN (...))` is far commoner in the wild than a real enum type,
113
+ and to anything reading the catalog it is an untyped text column unless
114
+ the constraint is read too. Postgres stores what it rewrote rather than
115
+ what was written, which `checkVocabulary` knows about. */
116
+ const checks = await db.query(`SELECT n.nspname AS table_schema, cl.relname AS table_name,
117
+ pg_get_constraintdef(co.oid) AS expression
118
+ FROM pg_constraint co
119
+ JOIN pg_class cl ON cl.oid = co.conrelid
120
+ JOIN pg_namespace n ON n.oid = cl.relnamespace
121
+ WHERE co.contype = 'c'
122
+ AND n.nspname ${source.schemas.length ? '= ANY($1)' : '<> ALL($1)'}
123
+ ORDER BY n.nspname, cl.relname, co.conname`, [schemaParam]);
124
+ const checksByTable = new Map();
125
+ for (const row of checks.rows) {
126
+ const id = `${row.table_schema}.${row.table_name}`;
127
+ const list = checksByTable.get(id) ?? [];
128
+ /* `pg_get_constraintdef` returns `CHECK ((expr))`; the parser wants the
129
+ expression, and `checksIn` is the same unwrapping SQLite needs. */
130
+ list.push(...checksIn(row.expression));
131
+ checksByTable.set(id, list);
132
+ }
133
+ /* 3. Keys. `unnest ... WITH ORDINALITY` keeps composite key columns in
134
+ their declared order, which a plain array_agg over conkey would not
135
+ guarantee and which matters for a two-column join.
136
+
137
+ `attname` is of type `name`, not `text`, so aggregating it yields
138
+ `name[]` — an array OID the driver has no parser for, which arrives
139
+ as the raw string "{a,b}" rather than an array. The ::text casts are
140
+ what make these come back as JavaScript arrays. */
141
+ const keys = await db.query(
142
+ /* Its functions and operators named in pg_catalog, as the scope's own catalog reads are (scoped/postgresTriggers.ts
143
+ CAT): a `public.unnest(int2[])` or `public.array_agg(text)` would otherwise answer here before the built-in, and
144
+ a foreign key read with no columns is one a scoped write's parent check never makes. */
145
+ `SELECT con.conname AS constraint_name,
146
+ fn.nspname AS from_schema,
147
+ f.relname AS from_table,
148
+ (SELECT pg_catalog.array_agg(a.attname::pg_catalog.text ORDER BY k.ord)
149
+ FROM pg_catalog.unnest(con.conkey) WITH ORDINALITY AS k(attnum, ord)
150
+ JOIN pg_catalog.pg_attribute a ON a.attrelid ${EQ} f.oid AND a.attnum ${EQ} k.attnum) AS from_columns,
151
+ tn.nspname AS to_schema,
152
+ t.relname AS to_table,
153
+ (SELECT pg_catalog.array_agg(a.attname::pg_catalog.text ORDER BY k.ord)
154
+ FROM pg_catalog.unnest(con.confkey) WITH ORDINALITY AS k(attnum, ord)
155
+ JOIN pg_catalog.pg_attribute a ON a.attrelid ${EQ} t.oid AND a.attnum ${EQ} k.attnum) AS to_columns,
156
+ con.confdeltype AS delete_rule
157
+ FROM pg_catalog.pg_constraint con
158
+ JOIN pg_catalog.pg_class f ON f.oid ${EQ} con.conrelid
159
+ JOIN pg_catalog.pg_namespace fn ON fn.oid ${EQ} f.relnamespace
160
+ JOIN pg_catalog.pg_class t ON t.oid ${EQ} con.confrelid
161
+ JOIN pg_catalog.pg_namespace tn ON tn.oid ${EQ} t.relnamespace
162
+ -- Never a clone that points at a partition: a foreign key to a partitioned table is copied once per partition of
163
+ -- it (conparentid names the original), each naming a partition the App and its policy never declare, which a
164
+ -- scoped parent check then counted through and refused. The original is the reference: an ordinary table's
165
+ -- write is checked through the partitioned table it names. A partition of a referencing table keeps its copy,
166
+ -- which names the same parent, so the partition shows its reference and a delete of the parent row sees it. A
167
+ -- key declared on a partition alone, or naming one, is read as declared; no scoped write targets a table in a
168
+ -- partition or inheritance hierarchy (postgresScopeCatalog.ts), so none is written through a table above it.
169
+ WHERE con.contype ${EQ} 'f'
170
+ AND NOT EXISTS (SELECT FROM pg_catalog.pg_constraint pc
171
+ WHERE pc.oid ${EQ} con.conparentid AND pc.confrelid ${NE} con.confrelid)
172
+ ORDER BY fn.nspname, f.relname, con.conname`);
173
+ const pks = await db.query(`SELECT n.nspname AS table_schema,
174
+ c.relname AS table_name,
175
+ (SELECT pg_catalog.array_agg(a.attname::pg_catalog.text ORDER BY k.ord)
176
+ FROM pg_catalog.unnest(con.conkey) WITH ORDINALITY AS k(attnum, ord)
177
+ JOIN pg_catalog.pg_attribute a ON a.attrelid ${EQ} c.oid AND a.attnum ${EQ} k.attnum) AS columns
178
+ FROM pg_catalog.pg_constraint con
179
+ JOIN pg_catalog.pg_class c ON c.oid ${EQ} con.conrelid
180
+ JOIN pg_catalog.pg_namespace n ON n.oid ${EQ} c.relnamespace
181
+ WHERE con.contype ${EQ} 'p'
182
+ ORDER BY n.nspname, c.relname, con.conname`);
183
+ const pkByTable = new Map();
184
+ for (const row of pks.rows) {
185
+ pkByTable.set(`${row.table_schema}.${row.table_name}`, row.columns ?? []);
186
+ }
187
+ /* Only the leading column of each index.
188
+
189
+ `indkey[0]` is the first key column, and it is the only one an ORDER BY
190
+ can be satisfied by — an index on (customer_id, opened_at) makes
191
+ `ORDER BY customer_id` free and `ORDER BY opened_at` a full sort. An
192
+ expression index has attnum 0 and joins to nothing, which drops it, as
193
+ it should: there is no bare column to sort by. */
194
+ const indexes = await db.query(`SELECT n.nspname AS table_schema,
195
+ c.relname AS table_name,
196
+ a.attname::text AS column_name,
197
+ -- Unique by itself (an App's natural-key address): one column, the whole table, no expression.
198
+ (i.indisunique AND i.indnatts = 1 AND i.indpred IS NULL AND i.indexprs IS NULL) AS sole_unique,
199
+ -- Unique as a pair (a natural key within a tenant): two key columns and nothing included.
200
+ CASE WHEN i.indisunique AND i.indnatts = 2 AND i.indpred IS NULL AND i.indexprs IS NULL THEN
201
+ (SELECT array_agg(pa.attname::text ORDER BY k.ord)
202
+ FROM unnest(i.indkey::int2[]) WITH ORDINALITY AS k(attnum, ord)
203
+ JOIN pg_attribute pa ON pa.attrelid = c.oid AND pa.attnum = k.attnum) END AS unique_pair,
204
+ -- The key columns a pg_trgm operator class indexes, at any position: what
205
+ -- serves a contains (ILIKE '%x%') search, which a B-tree never does.
206
+ (SELECT coalesce(array_agg(ta.attname::text), '{}')
207
+ FROM unnest(i.indkey::int2[], i.indclass::oid[]) AS k(attnum, opclass)
208
+ JOIN pg_opclass oc ON oc.oid = k.opclass
209
+ JOIN pg_attribute ta ON ta.attrelid = c.oid AND ta.attnum = k.attnum
210
+ WHERE oc.opcname IN ('gin_trgm_ops', 'gist_trgm_ops')) AS trigram_columns
211
+ FROM pg_index i
212
+ JOIN pg_class c ON c.oid = i.indrelid
213
+ JOIN pg_namespace n ON n.oid = c.relnamespace
214
+ JOIN pg_attribute a ON a.attrelid = c.oid AND a.attnum = i.indkey[0]
215
+ WHERE i.indisvalid
216
+ ORDER BY n.nspname, c.relname, a.attname`);
217
+ const indexedByTable = new Map();
218
+ const uniqueByTable = new Map();
219
+ const pairsByTable = new Map();
220
+ const trigramByTable = new Map();
221
+ for (const row of indexes.rows) {
222
+ const id = `${row.table_schema}.${row.table_name}`;
223
+ const set = indexedByTable.get(id) ?? new Set();
224
+ set.add(row.column_name);
225
+ indexedByTable.set(id, set);
226
+ if (row.sole_unique)
227
+ uniqueByTable.set(id, (uniqueByTable.get(id) ?? new Set()).add(row.column_name));
228
+ if (row.unique_pair?.length === 2)
229
+ pairsByTable.set(id, [...(pairsByTable.get(id) ?? []), [row.unique_pair[0], row.unique_pair[1]]]);
230
+ for (const column of row.trigram_columns ?? [])
231
+ trigramByTable.set(id, (trigramByTable.get(id) ?? new Set()).add(column));
232
+ }
233
+ const foreignKeys = [];
234
+ /* A column-level reference map, so the table view can show "this column
235
+ points there" without searching the whole key list per cell. A column
236
+ can sit in several keys — a tenant table's ownership column carries its
237
+ own reference to the tenancy profile and its part in each composite
238
+ tenant key — so every candidate is gathered and the link a reader
239
+ follows is chosen by the one shared rule the SQLite catalog applies. */
240
+ const refCandidates = new Map();
241
+ for (const row of keys.rows) {
242
+ const from = `${row.from_schema}.${row.from_table}`;
243
+ const to = `${row.to_schema}.${row.to_table}`;
244
+ // Keys can point out of the browsed schema set; those edges lead
245
+ // nowhere the user can click, so they are dropped rather than shown broken.
246
+ if (!wanted.has(from) || !wanted.has(to))
247
+ continue;
248
+ foreignKeys.push({
249
+ name: row.constraint_name,
250
+ from: { table: from, columns: row.from_columns ?? [] },
251
+ to: { table: to, columns: row.to_columns ?? [] },
252
+ onDelete: deleteRuleOf(row.delete_rule),
253
+ });
254
+ (row.from_columns ?? []).forEach((col, i) => {
255
+ const at = `${from}.${col}`;
256
+ const listed = refCandidates.get(at) ?? [];
257
+ listed.push({
258
+ reference: { table: to, column: row.to_columns?.[i] ?? row.to_columns?.[0] ?? '' },
259
+ composite: (row.from_columns ?? []).length > 1,
260
+ });
261
+ refCandidates.set(at, listed);
262
+ });
263
+ }
264
+ const refByColumn = new Map();
265
+ for (const [at, listed] of refCandidates) {
266
+ /* Describing a database this tool did not design: a column whose keys
267
+ name no single link simply shows none. The scoped catalogs, which
268
+ attest a write boundary, are the ones that refuse a contradiction. */
269
+ const chosen = chooseColumnReference(listed);
270
+ if (chosen.kind === 'one')
271
+ refByColumn.set(at, chosen.reference);
272
+ }
273
+ const columnsByTable = new Map();
274
+ for (const row of cols.rows) {
275
+ const id = `${row.table_schema}.${row.table_name}`;
276
+ if (!wanted.has(id))
277
+ continue;
278
+ const list = columnsByTable.get(id) ?? [];
279
+ list.push(row);
280
+ columnsByTable.set(id, list);
281
+ }
282
+ const tables = relRows.map((r) => {
283
+ const id = `${r.table_schema}.${r.table_name}`;
284
+ const pk = new Set(pkByTable.get(id) ?? []);
285
+ const tableChecks = checksByTable.get(id) ?? [];
286
+ const columns = (columnsByTable.get(id) ?? []).map((c) => ({
287
+ name: c.column_name,
288
+ type: c.data_type,
289
+ nullable: c.is_nullable === 'YES',
290
+ primaryKey: pk.has(c.column_name),
291
+ references: refByColumn.get(`${id}.${c.column_name}`),
292
+ default: c.column_default ?? undefined,
293
+ /* The type string stays what the database calls it; the places a sum must say travel beside it. */
294
+ ...(c.data_type === 'numeric' && c.numeric_scale !== null && c.numeric_scale !== undefined ? { scale: Number(c.numeric_scale) } : {}),
295
+ identity: c.is_identity === 'YES' ? (c.identity_generation === 'ALWAYS' ? 'always' : 'by-default') : undefined,
296
+ comment: c.comment ?? undefined,
297
+ // The database computes a generated column; nothing may write it (as sqlite.ts says of its own).
298
+ ...(c.is_generated === 'ALWAYS' ? { writable: false } : {}),
299
+ /* The type wins where there is one: an enum's labels are the whole
300
+ truth, while a check is one rule among however many the table has. */
301
+ allowed: c.enum_labels?.length ? c.enum_labels : firstVocabulary(tableChecks, c.column_name),
302
+ /* An integer a check pins to 0 and 1 reads as the boolean it stands for. */
303
+ ...(columnKind(c.data_type) === 'number' && tableChecks.some((check) => checkFlag(check, c.column_name))
304
+ ? { flag: true }
305
+ : {}),
306
+ /* A text column's length and form, where the type and the checks say them: a form checks them as someone types. */
307
+ ...(() => {
308
+ if (columnKind(c.data_type) !== 'text' || c.enum_labels?.length)
309
+ return {};
310
+ const text = catalogTextRule({
311
+ max: c.character_maximum_length === null ? null : Number(c.character_maximum_length),
312
+ ...checkedText(tableChecks, c.column_name),
313
+ });
314
+ return text ? { text } : {};
315
+ })(),
316
+ }));
317
+ return {
318
+ name: r.table_name,
319
+ schema: r.table_schema,
320
+ id,
321
+ columns,
322
+ approxRows: postgresRowEstimate(r.approx_rows),
323
+ comment: r.comment ?? undefined,
324
+ // Views and materialised views are read-only; foreign tables are
325
+ // remote. All three are worth flagging rather than silently listing.
326
+ isView: r.kind === 'v' || r.kind === 'm' || r.kind === 'f',
327
+ indexed: [...(indexedByTable.get(id) ?? [])],
328
+ trigram: [...(trigramByTable.get(id) ?? [])],
329
+ ...(uniqueByTable.get(id)?.size ? { unique: [...uniqueByTable.get(id)] } : {}),
330
+ ...(pairsByTable.get(id)?.length ? { uniquePairs: pairsByTable.get(id) } : {}),
331
+ };
332
+ });
333
+ return {
334
+ label: source.label,
335
+ dialect: source.dialect,
336
+ tables,
337
+ foreignKeys,
338
+ readAt: new Date().toISOString(),
339
+ };
340
+ }
341
+ /**
342
+ * The write path, on its own handle.
343
+ *
344
+ * Every reader carries `default_transaction_read_only = on`. A separate
345
+ * writer pool is opened on the first edit: a connection that can write
346
+ * should exist because somebody wrote, not because somebody connected.
347
+ *
348
+ * Every guard below is the SQLite adapter's, one for one. An edit refused on
349
+ * SQLite and allowed on Postgres would mean the safety of a cell editor
350
+ * depended on which database it was pointed at.
351
+ *
352
+ * A table's columns as the catalog has them now, not as they were on connect.
353
+ *
354
+ * `information_schema` would do for the names and types, but not for the
355
+ * primary key — it describes a composite one across two more views — and
356
+ * the key is the whole safety argument for a write. `pg_catalog` answers
357
+ * both in one query, and this is the Postgres adapter, so being
358
+ * Postgres-specific costs nothing.
359
+ *
360
+ * Read per write rather than from the cached schema: a column added since
361
+ * the connection opened is a column the editor should be able to write, and
362
+ * one dropped since is one it must not.
363
+ */
364
+ /**
365
+ * A column's type as a write coerces a value for it (shared/schema.ts coerceForColumn), from the column's type and
366
+ * modifier expressions: with its domains unwrapped through pg_type.typbasetype, the modifier the innermost one that
367
+ * has one gives, said by format_type. A domain over integer is then an integer column, so "" is NULL and "7.0" is 7,
368
+ * as they are for a column declared integer; by the domain's own name the write sent them as text, which the domain's
369
+ * input refused. The scope's parent check coerces a reference by the same text (postgresScopeCatalog.ts). Every
370
+ * function and operator in pg_catalog, as the scope's reads name them.
371
+ */
372
+ export const writtenType = (type, typmod) => `(WITH RECURSIVE d(type, typmod, depth) AS (
373
+ SELECT ${type}, ${typmod}, 0
374
+ UNION ALL
375
+ SELECT t.typbasetype, CASE WHEN t.typtypmod OPERATOR(pg_catalog.<>) -1 THEN t.typtypmod ELSE d.typmod END, d.depth OPERATOR(pg_catalog.+) 1
376
+ FROM d JOIN pg_catalog.pg_type t ON t.oid OPERATOR(pg_catalog.=) d.type
377
+ WHERE t.typtype OPERATOR(pg_catalog.=) 'd' AND d.depth OPERATOR(pg_catalog.<) 32)
378
+ SELECT pg_catalog.format_type(d.type, d.typmod) FROM d ORDER BY d.depth DESC LIMIT 1)`;
379
+ export async function postgresColumnsOf(schema, name, db, epoch, cache, connect) {
380
+ const kept = cache.get(epoch, `columns:${schema}.${name}`);
381
+ if (kept)
382
+ return kept;
383
+ db ??= await connect();
384
+ const result = await db.query(`SELECT a.attname AS name,
385
+ format_type(a.atttypid, a.atttypmod) AS type,
386
+ ${writtenType('a.atttypid', 'a.atttypmod')} AS written,
387
+ a.attnotnull AS notnull,
388
+ COALESCE(k.is_pk, false) AS is_pk
389
+ FROM pg_attribute a
390
+ JOIN pg_class c ON c.oid = a.attrelid
391
+ JOIN pg_namespace n ON n.oid = c.relnamespace
392
+ LEFT JOIN LATERAL (
393
+ SELECT true AS is_pk FROM pg_index i
394
+ WHERE i.indrelid = c.oid AND i.indisprimary AND a.attnum = ANY (i.indkey)
395
+ ) k ON true
396
+ WHERE n.nspname = $1 AND c.relname = $2
397
+ AND a.attnum > 0 AND NOT a.attisdropped
398
+ ORDER BY a.attnum`, [schema, name]);
399
+ return cache.set(epoch, `columns:${schema}.${name}`, result.rows);
400
+ }
401
+ export async function assertPostgresTable(id, db, epoch, cache, connect) {
402
+ const dot = id.indexOf('.');
403
+ const schema = dot === -1 ? 'public' : id.slice(0, dot);
404
+ const name = dot === -1 ? id : id.slice(dot + 1);
405
+ if (RESERVED_SCHEMAS.includes(schema))
406
+ throw new Refusal('Reserved resources are runtime-only.');
407
+ const kept = cache.get(epoch, `table:${id}`);
408
+ if (kept)
409
+ return kept;
410
+ db ??= await connect();
411
+ const found = await db.query(`SELECT c.relkind AS kind FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
412
+ WHERE n.nspname = $1 AND c.relname = $2 AND c.relkind IN ('r','v','m','p','f')`, [schema, name]);
413
+ if (!found.rows.length)
414
+ throw new Error(`No table or view called "${id}" in this database.`);
415
+ /* `v` is a view and `m` a materialised one. Both are read-only as far as
416
+ the write path is concerned — the relkind is asked for here rather than
417
+ re-derived from the cached schema, so a view created since the
418
+ connection opened is still recognised as one. */
419
+ const kind = String(found.rows[0]?.kind ?? 'r');
420
+ return cache.set(epoch, `table:${id}`, { schema, name, kind, isView: kind === 'v' || kind === 'm' });
421
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * One statement that changes whenever anything a full attestation reads
3
+ * changes: the `(oid, xmin)` of every catalog row the whole-catalog
4
+ * description, the pinned relation description and the store attestation
5
+ * depend on, over the same schemas, plus role membership and attributes and
6
+ * the store's meta row. Transactional DDL inserts, updates or deletes those
7
+ * rows, and a changed or removed row changes the digest. What does not change
8
+ * it is what attests nothing: VACUUM and ANALYZE update `pg_class` in place,
9
+ * and comments live elsewhere.
10
+ *
11
+ * A tenant source compares it with the digest of its last full attestation that
12
+ * passed, read in that attestation's own snapshot. Equal, that attestation
13
+ * stands for this snapshot; different, the full one runs again. The digest
14
+ * must be read after the source's LOCK, as the first statement of the
15
+ * snapshot, so DDL cannot land between it and the reads it vouches for.
16
+ *
17
+ * The statement has no parameters, so it can ride in the message that
18
+ * begins the snapshot (PostgresAdapter.readSnapshot's prologue): the schema
19
+ * names are this codebase's constants, spelled as literals. A runtime
20
+ * store's meta row is not in it: stores are attested when they are opened.
21
+ *
22
+ * Not seen: an object in `pg_catalog` renamed by a superuser, which could
23
+ * change the text of a default or index expression. It changes no read, and
24
+ * the attestation already trusts `pg_catalog` as everything else does.
25
+ */
26
+ export declare function postgresCatalogDigestStatement(excludedSchemas: readonly string[]): string;
27
+ /** The digest a digest statement answered, from its result. */
28
+ export declare function postgresCatalogDigestOf(result: {
29
+ rows: readonly Record<string, unknown>[];
30
+ } | undefined): string;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A digest of the PostgreSQL catalog rows a description reads.
3
+ *
4
+ * The tenant sources attest every snapshot against it (tenantPostgresCatalog.ts,
5
+ * tenantReadSource.ts), and a scoped transaction's writer reads it before it
6
+ * describes the catalog (PostgresAdapter), so either describes again only when
7
+ * the digest has moved.
8
+ */
9
+ import { Refusal } from './adapter.js';
10
+ import { notExtensionMember } from './postgresCatalog.js';
11
+ /* pg_catalog's operators by name, as the scope's own catalog reads use them (scoped/postgresTriggers.ts CAT): the
12
+ text concatenation the digest is built from is polymorphic, and a `public.||(text, oid)` would otherwise answer one
13
+ digest whatever the catalog said, which reads as nothing having moved. */
14
+ const EQ = 'OPERATOR(pg_catalog.=)';
15
+ const NE = 'OPERATOR(pg_catalog.<>)';
16
+ const CAT = 'OPERATOR(pg_catalog.||)';
17
+ /**
18
+ * One statement that changes whenever anything a full attestation reads
19
+ * changes: the `(oid, xmin)` of every catalog row the whole-catalog
20
+ * description, the pinned relation description and the store attestation
21
+ * depend on, over the same schemas, plus role membership and attributes and
22
+ * the store's meta row. Transactional DDL inserts, updates or deletes those
23
+ * rows, and a changed or removed row changes the digest. What does not change
24
+ * it is what attests nothing: VACUUM and ANALYZE update `pg_class` in place,
25
+ * and comments live elsewhere.
26
+ *
27
+ * A tenant source compares it with the digest of its last full attestation that
28
+ * passed, read in that attestation's own snapshot. Equal, that attestation
29
+ * stands for this snapshot; different, the full one runs again. The digest
30
+ * must be read after the source's LOCK, as the first statement of the
31
+ * snapshot, so DDL cannot land between it and the reads it vouches for.
32
+ *
33
+ * The statement has no parameters, so it can ride in the message that
34
+ * begins the snapshot (PostgresAdapter.readSnapshot's prologue): the schema
35
+ * names are this codebase's constants, spelled as literals. A runtime
36
+ * store's meta row is not in it: stores are attested when they are opened.
37
+ *
38
+ * Not seen: an object in `pg_catalog` renamed by a superuser, which could
39
+ * change the text of a default or index expression. It changes no read, and
40
+ * the attestation already trusts `pg_catalog` as everything else does.
41
+ */
42
+ export function postgresCatalogDigestStatement(excludedSchemas) {
43
+ // Constants only: a name that is not a plain identifier is a programming error, never quoted around.
44
+ if (excludedSchemas.some((name) => !/^[a-z_][a-z0-9_]*$/.test(name)))
45
+ throw new Refusal('The catalog digest names only plain identifiers.');
46
+ const excludedLiteral = `ARRAY[${excludedSchemas.map((name) => `'${name}'`).join(', ')}]`;
47
+ return `WITH ns AS (SELECT n.oid, n.xmin FROM pg_catalog.pg_namespace n
48
+ WHERE n.nspname ${NE} ALL(${excludedLiteral}::pg_catalog.text[]) AND n.nspname OPERATOR(pg_catalog.!~) '^pg_(toast_)?temp_'),
49
+ /* An extension's own relations are left out, as the description leaves them out (see notExtensionMember). */
50
+ rel AS (SELECT c.oid, c.xmin FROM pg_catalog.pg_class c JOIN ns ON ns.oid ${EQ} c.relnamespace WHERE ${notExtensionMember('c')}),
51
+ seen(v) AS (
52
+ SELECT 'n' ${CAT} ns.oid ${CAT} ':' ${CAT} ns.xmin FROM ns
53
+ UNION ALL SELECT 'c' ${CAT} rel.oid ${CAT} ':' ${CAT} rel.xmin FROM rel
54
+ UNION ALL SELECT 'a' ${CAT} a.attrelid ${CAT} '.' ${CAT} a.attnum ${CAT} ':' ${CAT} a.xmin
55
+ FROM pg_catalog.pg_attribute a JOIN rel ON rel.oid ${EQ} a.attrelid
56
+ UNION ALL SELECT 'd' ${CAT} d.oid ${CAT} ':' ${CAT} d.xmin FROM pg_catalog.pg_attrdef d JOIN rel ON rel.oid ${EQ} d.adrelid
57
+ UNION ALL SELECT 'k' ${CAT} k.oid ${CAT} ':' ${CAT} k.xmin FROM pg_catalog.pg_constraint k
58
+ WHERE k.connamespace ${EQ} ANY (SELECT oid FROM ns) OR k.conrelid ${EQ} ANY (SELECT oid FROM rel) OR k.confrelid ${EQ} ANY (SELECT oid FROM rel)
59
+ UNION ALL SELECT 'i' ${CAT} i.indexrelid ${CAT} ':' ${CAT} i.xmin FROM pg_catalog.pg_index i JOIN rel ON rel.oid ${EQ} i.indrelid
60
+ UNION ALL SELECT 't' ${CAT} g.oid ${CAT} ':' ${CAT} g.xmin FROM pg_catalog.pg_trigger g JOIN rel ON rel.oid ${EQ} g.tgrelid
61
+ UNION ALL SELECT 'r' ${CAT} w.oid ${CAT} ':' ${CAT} w.xmin FROM pg_catalog.pg_rewrite w JOIN rel ON rel.oid ${EQ} w.ev_class
62
+ UNION ALL SELECT 'p' ${CAT} p.oid ${CAT} ':' ${CAT} p.xmin FROM pg_catalog.pg_policy p JOIN rel ON rel.oid ${EQ} p.polrelid
63
+ UNION ALL SELECT 'y' ${CAT} y.oid ${CAT} ':' ${CAT} y.xmin FROM pg_catalog.pg_type y JOIN ns ON ns.oid ${EQ} y.typnamespace
64
+ UNION ALL SELECT 'e' ${CAT} e.oid ${CAT} ':' ${CAT} e.xmin FROM pg_catalog.pg_enum e
65
+ JOIN pg_catalog.pg_type y ON y.oid ${EQ} e.enumtypid JOIN ns ON ns.oid ${EQ} y.typnamespace
66
+ UNION ALL SELECT 'f' ${CAT} f.oid ${CAT} ':' ${CAT} f.xmin FROM pg_catalog.pg_proc f JOIN ns ON ns.oid ${EQ} f.pronamespace
67
+ UNION ALL SELECT 'o' ${CAT} o.oid ${CAT} ':' ${CAT} o.xmin FROM pg_catalog.pg_operator o JOIN ns ON ns.oid ${EQ} o.oprnamespace
68
+ UNION ALL SELECT 'q' ${CAT} q.oid ${CAT} ':' ${CAT} q.xmin FROM pg_catalog.pg_opclass q JOIN ns ON ns.oid ${EQ} q.opcnamespace
69
+ /* What else a store attestation counts in the runtime schema (postgresRuntimeSchemaProblems): one more
70
+ object there refuses the store, so it moves the digest too. */
71
+ UNION ALL SELECT 'v' ${CAT} v.oid ${CAT} ':' ${CAT} v.xmin FROM pg_catalog.pg_conversion v JOIN ns ON ns.oid ${EQ} v.connamespace
72
+ UNION ALL SELECT 'F' ${CAT} o.oid ${CAT} ':' ${CAT} o.xmin FROM pg_catalog.pg_opfamily o JOIN ns ON ns.oid ${EQ} o.opfnamespace
73
+ UNION ALL SELECT 'Tc' ${CAT} t.oid ${CAT} ':' ${CAT} t.xmin FROM pg_catalog.pg_ts_config t JOIN ns ON ns.oid ${EQ} t.cfgnamespace
74
+ UNION ALL SELECT 'Td' ${CAT} t.oid ${CAT} ':' ${CAT} t.xmin FROM pg_catalog.pg_ts_dict t JOIN ns ON ns.oid ${EQ} t.dictnamespace
75
+ UNION ALL SELECT 'Tp' ${CAT} t.oid ${CAT} ':' ${CAT} t.xmin FROM pg_catalog.pg_ts_parser t JOIN ns ON ns.oid ${EQ} t.prsnamespace
76
+ UNION ALL SELECT 'Tt' ${CAT} t.oid ${CAT} ':' ${CAT} t.xmin FROM pg_catalog.pg_ts_template t JOIN ns ON ns.oid ${EQ} t.tmplnamespace
77
+ UNION ALL SELECT 'x' ${CAT} x.oid ${CAT} ':' ${CAT} x.xmin FROM pg_catalog.pg_statistic_ext x JOIN ns ON ns.oid ${EQ} x.stxnamespace
78
+ UNION ALL SELECT 'X' ${CAT} x.oid ${CAT} ':' ${CAT} x.xmin FROM pg_catalog.pg_extension x JOIN ns ON ns.oid ${EQ} x.extnamespace
79
+ UNION ALL SELECT 'l' ${CAT} l.oid ${CAT} ':' ${CAT} l.xmin FROM pg_catalog.pg_collation l
80
+ WHERE l.collnamespace ${EQ} ANY (SELECT oid FROM ns)
81
+ OR l.oid ${EQ} ANY (SELECT a.attcollation FROM pg_catalog.pg_attribute a JOIN rel ON rel.oid ${EQ} a.attrelid)
82
+ UNION ALL SELECT 'm' ${CAT} m.roleid ${CAT} '.' ${CAT} m.member ${CAT} ':' ${CAT} m.xmin FROM pg_catalog.pg_auth_members m
83
+ UNION ALL SELECT 'u' ${CAT} r.oid ${CAT} ':' ${CAT} r.rolname ${CAT} ':' ${CAT} r.rolsuper ${CAT} ':' ${CAT} r.rolinherit FROM pg_catalog.pg_roles r
84
+ UNION ALL SELECT 's' ${CAT} current_user)
85
+ SELECT pg_catalog.md5(pg_catalog.string_agg(v, ',' ORDER BY v)) AS fingerprint FROM seen`;
86
+ }
87
+ /** The digest a digest statement answered, from its result. */
88
+ export function postgresCatalogDigestOf(result) {
89
+ const value = result?.rows[0]?.fingerprint;
90
+ if (typeof value !== 'string')
91
+ throw new Refusal('The catalog digest could not be read.');
92
+ return value;
93
+ }