@mistriwork/engine 0.0.0-stage → 1.0.0-rc.10

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 (546) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -2
  3. package/dist/adapters/adapter.d.ts +693 -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 +436 -0
  38. package/dist/adapters/postgres.js +1890 -0
  39. package/dist/adapters/postgresCatalog.d.ts +96 -0
  40. package/dist/adapters/postgresCatalog.js +387 -0
  41. package/dist/adapters/postgresCatalogDigest.d.ts +30 -0
  42. package/dist/adapters/postgresCatalogDigest.js +87 -0
  43. package/dist/adapters/postgresCatalogRows.d.ts +62 -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/replicas.d.ts +70 -0
  64. package/dist/adapters/replicas.js +208 -0
  65. package/dist/adapters/reservedSql.d.ts +38 -0
  66. package/dist/adapters/reservedSql.js +264 -0
  67. package/dist/adapters/rolePrivileges.d.ts +17 -0
  68. package/dist/adapters/rolePrivileges.js +22 -0
  69. package/dist/adapters/scoped/keyRows.d.ts +65 -0
  70. package/dist/adapters/scoped/keyRows.js +173 -0
  71. package/dist/adapters/scoped/postgresScopeCatalog.d.ts +16 -0
  72. package/dist/adapters/scoped/postgresScopeCatalog.js +117 -0
  73. package/dist/adapters/scoped/scopedCommandOperations.d.ts +5 -0
  74. package/dist/adapters/scoped/scopedCommandOperations.js +48 -0
  75. package/dist/adapters/scoped/scopedReads.d.ts +20 -0
  76. package/dist/adapters/scoped/scopedReads.js +174 -0
  77. package/dist/adapters/scoped/scopedTransaction.d.ts +89 -0
  78. package/dist/adapters/scoped/scopedTransaction.js +303 -0
  79. package/dist/adapters/scoped/sqliteScopeCatalog.d.ts +16 -0
  80. package/dist/adapters/scoped/sqliteScopeCatalog.js +241 -0
  81. package/dist/adapters/scoped/updateGuard.d.ts +3 -0
  82. package/dist/adapters/scoped/updateGuard.js +40 -0
  83. package/dist/adapters/serverSettings.d.ts +45 -0
  84. package/dist/adapters/serverSettings.js +46 -0
  85. package/dist/adapters/sqlite.d.ts +262 -0
  86. package/dist/adapters/sqlite.js +1434 -0
  87. package/dist/adapters/sqliteCostlyReads.d.ts +33 -0
  88. package/dist/adapters/sqliteCostlyReads.js +49 -0
  89. package/dist/adapters/sqliteDecimals.d.ts +22 -0
  90. package/dist/adapters/sqliteDecimals.js +57 -0
  91. package/dist/adapters/sqliteHandles.d.ts +43 -0
  92. package/dist/adapters/sqliteHandles.js +143 -0
  93. package/dist/adapters/sqliteStatementProcess.d.ts +29 -0
  94. package/dist/adapters/sqliteStatementProcess.js +131 -0
  95. package/dist/adapters/statementControl.d.ts +34 -0
  96. package/dist/adapters/statementControl.js +90 -0
  97. package/dist/adapters/storeHost.d.ts +130 -0
  98. package/dist/adapters/storeHost.js +13 -0
  99. package/dist/adapters/telemetry/drivers.d.ts +21 -0
  100. package/dist/adapters/telemetry/drivers.js +321 -0
  101. package/dist/adapters/telemetry/metrics.d.ts +63 -0
  102. package/dist/adapters/telemetry/metrics.js +122 -0
  103. package/dist/adapters/telemetry/otlp.d.ts +12 -0
  104. package/dist/adapters/telemetry/otlp.js +320 -0
  105. package/dist/adapters/telemetry/otlpEncode.d.ts +48 -0
  106. package/dist/adapters/telemetry/otlpEncode.js +366 -0
  107. package/dist/adapters/telemetry/otlpEnv.d.ts +1 -0
  108. package/dist/adapters/telemetry/otlpEnv.js +12 -0
  109. package/dist/adapters/telemetry/serverTiming.d.ts +83 -0
  110. package/dist/adapters/telemetry/serverTiming.js +503 -0
  111. package/dist/adapters/telemetry/start.d.ts +10 -0
  112. package/dist/adapters/telemetry/start.js +25 -0
  113. package/dist/adapters/telemetry/statement.d.ts +16 -0
  114. package/dist/adapters/telemetry/statement.js +134 -0
  115. package/dist/adapters/telemetry/trace.d.ts +127 -0
  116. package/dist/adapters/telemetry/trace.js +295 -0
  117. package/dist/adapters/writeAhead.d.ts +27 -0
  118. package/dist/adapters/writeAhead.js +46 -0
  119. package/dist/adapters/writeAttribution.d.ts +18 -0
  120. package/dist/adapters/writeAttribution.js +23 -0
  121. package/dist/adapters/writeCapture.d.ts +73 -0
  122. package/dist/adapters/writeCapture.js +20 -0
  123. package/dist/adapters/writeLanes.d.ts +94 -0
  124. package/dist/adapters/writeLanes.js +232 -0
  125. package/dist/engine.d.ts +15 -0
  126. package/dist/engine.js +13 -0
  127. package/dist/server/auth/credentials.d.ts +61 -0
  128. package/dist/server/auth/credentials.js +260 -0
  129. package/dist/server/cacheService.d.ts +50 -0
  130. package/dist/server/cacheService.js +110 -0
  131. package/dist/server/cli/args.d.ts +176 -0
  132. package/dist/server/cli/args.js +342 -0
  133. package/dist/server/cli/bin.d.ts +5 -0
  134. package/dist/server/cli/bin.js +66 -0
  135. package/dist/server/cli/browser.d.ts +15 -0
  136. package/dist/server/cli/browser.js +37 -0
  137. package/dist/server/cli/config.d.ts +50 -0
  138. package/dist/server/cli/config.js +206 -0
  139. package/dist/server/cli/startup.d.ts +36 -0
  140. package/dist/server/cli/startup.js +128 -0
  141. package/dist/server/cli/startupOptions.d.ts +63 -0
  142. package/dist/server/cli/startupOptions.js +143 -0
  143. package/dist/server/cli/subcommand.d.ts +28 -0
  144. package/dist/server/cli/subcommand.js +32 -0
  145. package/dist/server/cli/usage.d.ts +13 -0
  146. package/dist/server/cli/usage.js +31 -0
  147. package/dist/server/clientHttp.d.ts +184 -0
  148. package/dist/server/clientHttp.js +700 -0
  149. package/dist/server/clientSurface.d.ts +128 -0
  150. package/dist/server/clientSurface.js +182 -0
  151. package/dist/server/columnGrants.d.ts +103 -0
  152. package/dist/server/columnGrants.js +730 -0
  153. package/dist/server/compileCache.d.ts +1 -0
  154. package/dist/server/compileCache.js +30 -0
  155. package/dist/server/config/locations.d.ts +1 -0
  156. package/dist/server/config/locations.js +15 -0
  157. package/dist/server/configPaths.d.ts +7 -0
  158. package/dist/server/configPaths.js +34 -0
  159. package/dist/server/configSections.d.ts +64 -0
  160. package/dist/server/configSections.js +72 -0
  161. package/dist/server/connectionRedaction.d.ts +30 -0
  162. package/dist/server/connectionRedaction.js +77 -0
  163. package/dist/server/connections.d.ts +353 -0
  164. package/dist/server/connections.js +978 -0
  165. package/dist/server/constraints.d.ts +82 -0
  166. package/dist/server/constraints.js +169 -0
  167. package/dist/server/demo.d.ts +9 -0
  168. package/dist/server/demo.js +554 -0
  169. package/dist/server/devclient.d.ts +108 -0
  170. package/dist/server/devclient.js +361 -0
  171. package/dist/server/evidence.d.ts +55 -0
  172. package/dist/server/evidence.js +323 -0
  173. package/dist/server/hiddenColumns.d.ts +32 -0
  174. package/dist/server/hiddenColumns.js +238 -0
  175. package/dist/server/http/baselineHeaders.d.ts +24 -0
  176. package/dist/server/http/baselineHeaders.js +12 -0
  177. package/dist/server/http/captured.d.ts +35 -0
  178. package/dist/server/http/captured.js +73 -0
  179. package/dist/server/http/clock.d.ts +1 -0
  180. package/dist/server/http/clock.js +14 -0
  181. package/dist/server/http/connectionSource.d.ts +4 -0
  182. package/dist/server/http/connectionSource.js +48 -0
  183. package/dist/server/http/context.d.ts +189 -0
  184. package/dist/server/http/context.js +11 -0
  185. package/dist/server/http/crawlerText.d.ts +15 -0
  186. package/dist/server/http/crawlerText.js +32 -0
  187. package/dist/server/http/dataRoutes.d.ts +88 -0
  188. package/dist/server/http/dataRoutes.js +137 -0
  189. package/dist/server/http/door.d.ts +57 -0
  190. package/dist/server/http/door.js +39 -0
  191. package/dist/server/http/exportRoute.d.ts +15 -0
  192. package/dist/server/http/exportRoute.js +320 -0
  193. package/dist/server/http/firstPaint.d.ts +108 -0
  194. package/dist/server/http/firstPaint.js +262 -0
  195. package/dist/server/http/httpOperationRoutes.d.ts +11 -0
  196. package/dist/server/http/httpOperationRoutes.js +50 -0
  197. package/dist/server/http/pageReads.d.ts +20 -0
  198. package/dist/server/http/pageReads.js +205 -0
  199. package/dist/server/http/pageRoutes.d.ts +39 -0
  200. package/dist/server/http/pageRoutes.js +291 -0
  201. package/dist/server/http/probes.d.ts +22 -0
  202. package/dist/server/http/probes.js +27 -0
  203. package/dist/server/http/rateLimit.d.ts +131 -0
  204. package/dist/server/http/rateLimit.js +351 -0
  205. package/dist/server/http/readRoutes.d.ts +9 -0
  206. package/dist/server/http/readRoutes.js +131 -0
  207. package/dist/server/http/readRouting.d.ts +20 -0
  208. package/dist/server/http/readRouting.js +80 -0
  209. package/dist/server/http/recordCompose.d.ts +67 -0
  210. package/dist/server/http/recordCompose.js +167 -0
  211. package/dist/server/http/recordWrites.d.ts +89 -0
  212. package/dist/server/http/recordWrites.js +298 -0
  213. package/dist/server/http/refusalReport.d.ts +38 -0
  214. package/dist/server/http/refusalReport.js +63 -0
  215. package/dist/server/http/reply.d.ts +130 -0
  216. package/dist/server/http/reply.js +394 -0
  217. package/dist/server/http/requestOrigin.d.ts +11 -0
  218. package/dist/server/http/requestOrigin.js +8 -0
  219. package/dist/server/http/router.d.ts +45 -0
  220. package/dist/server/http/router.js +22 -0
  221. package/dist/server/http/serverCore.d.ts +68 -0
  222. package/dist/server/http/serverCore.js +177 -0
  223. package/dist/server/http/traceRequest.d.ts +30 -0
  224. package/dist/server/http/traceRequest.js +224 -0
  225. package/dist/server/http/trust.d.ts +261 -0
  226. package/dist/server/http/trust.js +472 -0
  227. package/dist/server/http/writeRefusal.d.ts +33 -0
  228. package/dist/server/http/writeRefusal.js +24 -0
  229. package/dist/server/httpConnection.d.ts +49 -0
  230. package/dist/server/httpConnection.js +170 -0
  231. package/dist/server/impact.d.ts +55 -0
  232. package/dist/server/impact.js +47 -0
  233. package/dist/server/journal.d.ts +134 -0
  234. package/dist/server/journal.js +398 -0
  235. package/dist/server/keysetReadHttp.d.ts +52 -0
  236. package/dist/server/keysetReadHttp.js +85 -0
  237. package/dist/server/layouts.d.ts +49 -0
  238. package/dist/server/layouts.js +192 -0
  239. package/dist/server/migrate/cli.d.ts +55 -0
  240. package/dist/server/migrate/cli.js +517 -0
  241. package/dist/server/migrate/database.d.ts +37 -0
  242. package/dist/server/migrate/database.js +247 -0
  243. package/dist/server/migrate/desired.d.ts +76 -0
  244. package/dist/server/migrate/desired.js +292 -0
  245. package/dist/server/migrate/files.d.ts +34 -0
  246. package/dist/server/migrate/files.js +141 -0
  247. package/dist/server/migrate/flyway.d.ts +7 -0
  248. package/dist/server/migrate/flyway.js +69 -0
  249. package/dist/server/migrate/history.d.ts +70 -0
  250. package/dist/server/migrate/history.js +211 -0
  251. package/dist/server/migrate/runner.d.ts +100 -0
  252. package/dist/server/migrate/runner.js +409 -0
  253. package/dist/server/migrate/snapshot.d.ts +30 -0
  254. package/dist/server/migrate/snapshot.js +239 -0
  255. package/dist/server/migrate/target.d.ts +33 -0
  256. package/dist/server/migrate/target.js +82 -0
  257. package/dist/server/openapiDraft.d.ts +25 -0
  258. package/dist/server/openapiDraft.js +171 -0
  259. package/dist/server/operations/diagnostics.d.ts +101 -0
  260. package/dist/server/operations/diagnostics.js +284 -0
  261. package/dist/server/operations/requestMetrics.d.ts +33 -0
  262. package/dist/server/operations/requestMetrics.js +94 -0
  263. package/dist/server/packageVersion.d.ts +1 -0
  264. package/dist/server/packageVersion.js +11 -0
  265. package/dist/server/poolConfig.d.ts +34 -0
  266. package/dist/server/poolConfig.js +114 -0
  267. package/dist/server/product.d.ts +20 -0
  268. package/dist/server/product.js +12 -0
  269. package/dist/server/recordHistoryOperations.d.ts +39 -0
  270. package/dist/server/recordHistoryOperations.js +43 -0
  271. package/dist/server/recordWriteOperations.d.ts +111 -0
  272. package/dist/server/recordWriteOperations.js +329 -0
  273. package/dist/server/resourceReadHttp.d.ts +81 -0
  274. package/dist/server/resourceReadHttp.js +606 -0
  275. package/dist/server/resourceReadOperations.d.ts +147 -0
  276. package/dist/server/resourceReadOperations.js +452 -0
  277. package/dist/server/scaffoldMachine.d.ts +54 -0
  278. package/dist/server/scaffoldMachine.js +184 -0
  279. package/dist/server/seed/cli.d.ts +20 -0
  280. package/dist/server/seed/cli.js +164 -0
  281. package/dist/server/seed/lexicon.d.ts +26 -0
  282. package/dist/server/seed/lexicon.js +585 -0
  283. package/dist/server/seed/seed.d.ts +70 -0
  284. package/dist/server/seed/seed.js +779 -0
  285. package/dist/server/seed/words.d.ts +21 -0
  286. package/dist/server/seed/words.js +164 -0
  287. package/dist/server/serverRequests.d.ts +6 -0
  288. package/dist/server/serverRequests.js +33 -0
  289. package/dist/server/serverTimeouts.d.ts +33 -0
  290. package/dist/server/serverTimeouts.js +32 -0
  291. package/dist/server/shapeonly.d.ts +32 -0
  292. package/dist/server/shapeonly.js +110 -0
  293. package/dist/server/startupWarnings.d.ts +32 -0
  294. package/dist/server/startupWarnings.js +92 -0
  295. package/dist/shared/addressParams.d.ts +28 -0
  296. package/dist/shared/addressParams.js +47 -0
  297. package/dist/shared/appCards.d.ts +123 -0
  298. package/dist/shared/appCards.js +385 -0
  299. package/dist/shared/appComponents.d.ts +177 -0
  300. package/dist/shared/appComponents.js +422 -0
  301. package/dist/shared/appDocuments.d.ts +43 -0
  302. package/dist/shared/appDocuments.js +131 -0
  303. package/dist/shared/appEmbeds.d.ts +21 -0
  304. package/dist/shared/appEmbeds.js +24 -0
  305. package/dist/shared/appIcons.d.ts +28 -0
  306. package/dist/shared/appIcons.js +223 -0
  307. package/dist/shared/appLinks.d.ts +17 -0
  308. package/dist/shared/appLinks.js +124 -0
  309. package/dist/shared/appListColumns.d.ts +3 -0
  310. package/dist/shared/appListColumns.js +66 -0
  311. package/dist/shared/appLocale.d.ts +36 -0
  312. package/dist/shared/appLocale.js +86 -0
  313. package/dist/shared/appMessages.d.ts +44 -0
  314. package/dist/shared/appMessages.js +78 -0
  315. package/dist/shared/appNoun.d.ts +21 -0
  316. package/dist/shared/appNoun.js +32 -0
  317. package/dist/shared/autoBucket.d.ts +98 -0
  318. package/dist/shared/autoBucket.js +305 -0
  319. package/dist/shared/autoValues.d.ts +25 -0
  320. package/dist/shared/autoValues.js +25 -0
  321. package/dist/shared/breakdown.d.ts +228 -0
  322. package/dist/shared/breakdown.js +557 -0
  323. package/dist/shared/breakdowntext.d.ts +41 -0
  324. package/dist/shared/breakdowntext.js +400 -0
  325. package/dist/shared/builtInThemes.d.ts +2 -0
  326. package/dist/shared/builtInThemes.js +771 -0
  327. package/dist/shared/chartSeparation.d.ts +11 -0
  328. package/dist/shared/chartSeparation.js +58 -0
  329. package/dist/shared/clauses.d.ts +22 -0
  330. package/dist/shared/clauses.js +97 -0
  331. package/dist/shared/columnCaption.d.ts +16 -0
  332. package/dist/shared/columnCaption.js +90 -0
  333. package/dist/shared/commandFieldPath.d.ts +2 -0
  334. package/dist/shared/commandFieldPath.js +7 -0
  335. package/dist/shared/commandWire.d.ts +26 -0
  336. package/dist/shared/commandWire.js +41 -0
  337. package/dist/shared/computed.d.ts +161 -0
  338. package/dist/shared/computed.js +378 -0
  339. package/dist/shared/computedParse.d.ts +13 -0
  340. package/dist/shared/computedParse.js +278 -0
  341. package/dist/shared/computedValue.d.ts +47 -0
  342. package/dist/shared/computedValue.js +191 -0
  343. package/dist/shared/connection.d.ts +30 -0
  344. package/dist/shared/connection.js +1 -0
  345. package/dist/shared/csv.d.ts +20 -0
  346. package/dist/shared/csv.js +63 -0
  347. package/dist/shared/dashLayout.d.ts +30 -0
  348. package/dist/shared/dashLayout.js +132 -0
  349. package/dist/shared/dashboardAsks.d.ts +93 -0
  350. package/dist/shared/dashboardAsks.js +129 -0
  351. package/dist/shared/dashboardTrend.d.ts +20 -0
  352. package/dist/shared/dashboardTrend.js +50 -0
  353. package/dist/shared/declaredReferences.d.ts +50 -0
  354. package/dist/shared/declaredReferences.js +202 -0
  355. package/dist/shared/definedFields.d.ts +63 -0
  356. package/dist/shared/definedFields.js +103 -0
  357. package/dist/shared/definedValues.d.ts +63 -0
  358. package/dist/shared/definedValues.js +184 -0
  359. package/dist/shared/displayDefaults.d.ts +135 -0
  360. package/dist/shared/displayDefaults.js +529 -0
  361. package/dist/shared/dueDate.d.ts +6 -0
  362. package/dist/shared/dueDate.js +6 -0
  363. package/dist/shared/duration.d.ts +4 -0
  364. package/dist/shared/duration.js +23 -0
  365. package/dist/shared/fileBounds.d.ts +9 -0
  366. package/dist/shared/fileBounds.js +9 -0
  367. package/dist/shared/filter.d.ts +217 -0
  368. package/dist/shared/filter.js +305 -0
  369. package/dist/shared/firstPaint.d.ts +24 -0
  370. package/dist/shared/firstPaint.js +33 -0
  371. package/dist/shared/form.d.ts +21 -0
  372. package/dist/shared/form.js +25 -0
  373. package/dist/shared/formValues.d.ts +104 -0
  374. package/dist/shared/formValues.js +352 -0
  375. package/dist/shared/funnel.d.ts +45 -0
  376. package/dist/shared/funnel.js +108 -0
  377. package/dist/shared/httpOperations.d.ts +48 -0
  378. package/dist/shared/httpOperations.js +9 -0
  379. package/dist/shared/iconGlyphs.d.ts +4 -0
  380. package/dist/shared/iconGlyphs.js +151 -0
  381. package/dist/shared/iconWeights.d.ts +3 -0
  382. package/dist/shared/iconWeights.js +162 -0
  383. package/dist/shared/imageWidths.d.ts +32 -0
  384. package/dist/shared/imageWidths.js +38 -0
  385. package/dist/shared/keysetPage.d.ts +64 -0
  386. package/dist/shared/keysetPage.js +161 -0
  387. package/dist/shared/like.d.ts +20 -0
  388. package/dist/shared/like.js +29 -0
  389. package/dist/shared/listEmpty.d.ts +12 -0
  390. package/dist/shared/listEmpty.js +36 -0
  391. package/dist/shared/listFilters.d.ts +28 -0
  392. package/dist/shared/listFilters.js +84 -0
  393. package/dist/shared/listPresentations.d.ts +199 -0
  394. package/dist/shared/listPresentations.js +7 -0
  395. package/dist/shared/listQuestion.d.ts +52 -0
  396. package/dist/shared/listQuestion.js +137 -0
  397. package/dist/shared/lookPalettes.d.ts +62 -0
  398. package/dist/shared/lookPalettes.js +306 -0
  399. package/dist/shared/maskQuoted.d.ts +24 -0
  400. package/dist/shared/maskQuoted.js +48 -0
  401. package/dist/shared/mentionLabel.d.ts +19 -0
  402. package/dist/shared/mentionLabel.js +38 -0
  403. package/dist/shared/mentionLookup.d.ts +17 -0
  404. package/dist/shared/mentionLookup.js +64 -0
  405. package/dist/shared/menuCounts.d.ts +16 -0
  406. package/dist/shared/menuCounts.js +74 -0
  407. package/dist/shared/model.d.ts +79 -0
  408. package/dist/shared/model.js +153 -0
  409. package/dist/shared/money.d.ts +44 -0
  410. package/dist/shared/money.js +81 -0
  411. package/dist/shared/moneyEntry.d.ts +7 -0
  412. package/dist/shared/moneyEntry.js +27 -0
  413. package/dist/shared/mount.d.ts +118 -0
  414. package/dist/shared/mount.js +248 -0
  415. package/dist/shared/niceTicks.d.ts +26 -0
  416. package/dist/shared/niceTicks.js +50 -0
  417. package/dist/shared/order.d.ts +59 -0
  418. package/dist/shared/order.js +133 -0
  419. package/dist/shared/page.d.ts +135 -0
  420. package/dist/shared/page.js +1187 -0
  421. package/dist/shared/pageAnatomy.d.ts +99 -0
  422. package/dist/shared/pageAnatomy.js +370 -0
  423. package/dist/shared/pageConfig.d.ts +25 -0
  424. package/dist/shared/pageConfig.js +1308 -0
  425. package/dist/shared/pageEmptyActions.d.ts +12 -0
  426. package/dist/shared/pageEmptyActions.js +20 -0
  427. package/dist/shared/pageLayouts.d.ts +72 -0
  428. package/dist/shared/pageLayouts.js +205 -0
  429. package/dist/shared/pageModel.d.ts +785 -0
  430. package/dist/shared/pageModel.js +121 -0
  431. package/dist/shared/pagePaths.d.ts +180 -0
  432. package/dist/shared/pagePaths.js +869 -0
  433. package/dist/shared/pagePlans.d.ts +52 -0
  434. package/dist/shared/pagePlans.js +108 -0
  435. package/dist/shared/pageRoutes.d.ts +9 -0
  436. package/dist/shared/pageRoutes.js +9 -0
  437. package/dist/shared/query.d.ts +166 -0
  438. package/dist/shared/query.js +1302 -0
  439. package/dist/shared/queryDates.d.ts +12 -0
  440. package/dist/shared/queryDates.js +101 -0
  441. package/dist/shared/queryOperands.d.ts +99 -0
  442. package/dist/shared/queryOperands.js +131 -0
  443. package/dist/shared/reads.d.ts +103 -0
  444. package/dist/shared/reads.js +154 -0
  445. package/dist/shared/recordLabel.d.ts +51 -0
  446. package/dist/shared/recordLabel.js +123 -0
  447. package/dist/shared/recordReadKeys.d.ts +30 -0
  448. package/dist/shared/recordReadKeys.js +51 -0
  449. package/dist/shared/recordReads.d.ts +268 -0
  450. package/dist/shared/recordReads.js +368 -0
  451. package/dist/shared/recordview.d.ts +198 -0
  452. package/dist/shared/recordview.js +356 -0
  453. package/dist/shared/referenceModel.d.ts +58 -0
  454. package/dist/shared/referenceModel.js +194 -0
  455. package/dist/shared/refusal.d.ts +64 -0
  456. package/dist/shared/refusal.js +144 -0
  457. package/dist/shared/relatedCreate.d.ts +30 -0
  458. package/dist/shared/relatedCreate.js +162 -0
  459. package/dist/shared/resourceHttp.d.ts +464 -0
  460. package/dist/shared/resourceHttp.js +1 -0
  461. package/dist/shared/richText.d.ts +85 -0
  462. package/dist/shared/richText.js +305 -0
  463. package/dist/shared/rollups.d.ts +143 -0
  464. package/dist/shared/rollups.js +64 -0
  465. package/dist/shared/rowScope.d.ts +72 -0
  466. package/dist/shared/rowScope.js +376 -0
  467. package/dist/shared/runtimeTables.d.ts +44 -0
  468. package/dist/shared/runtimeTables.js +79 -0
  469. package/dist/shared/schema.d.ts +523 -0
  470. package/dist/shared/schema.js +627 -0
  471. package/dist/shared/schematext.d.ts +38 -0
  472. package/dist/shared/schematext.js +101 -0
  473. package/dist/shared/scopeCatalog.d.ts +29 -0
  474. package/dist/shared/scopeCatalog.js +468 -0
  475. package/dist/shared/servedApp.d.ts +681 -0
  476. package/dist/shared/servedApp.js +45 -0
  477. package/dist/shared/sessionLease.d.ts +34 -0
  478. package/dist/shared/sessionLease.js +3 -0
  479. package/dist/shared/shape.d.ts +55 -0
  480. package/dist/shared/shape.js +168 -0
  481. package/dist/shared/slug.d.ts +1 -0
  482. package/dist/shared/slug.js +12 -0
  483. package/dist/shared/sortText.d.ts +14 -0
  484. package/dist/shared/sortText.js +26 -0
  485. package/dist/shared/sqlRelation.d.ts +4 -0
  486. package/dist/shared/sqlRelation.js +8 -0
  487. package/dist/shared/sqlsaved.d.ts +44 -0
  488. package/dist/shared/sqlsaved.js +63 -0
  489. package/dist/shared/stitchedPaths.d.ts +27 -0
  490. package/dist/shared/stitchedPaths.js +38 -0
  491. package/dist/shared/structuredFilter.d.ts +22 -0
  492. package/dist/shared/structuredFilter.js +1 -0
  493. package/dist/shared/subtitlePath.d.ts +20 -0
  494. package/dist/shared/subtitlePath.js +24 -0
  495. package/dist/shared/suggest.d.ts +18 -0
  496. package/dist/shared/suggest.js +59 -0
  497. package/dist/shared/tableSizing.d.ts +4 -0
  498. package/dist/shared/tableSizing.js +9 -0
  499. package/dist/shared/tagLists.d.ts +57 -0
  500. package/dist/shared/tagLists.js +34 -0
  501. package/dist/shared/textRules.d.ts +54 -0
  502. package/dist/shared/textRules.js +133 -0
  503. package/dist/shared/theme.d.ts +94 -0
  504. package/dist/shared/theme.js +800 -0
  505. package/dist/shared/themeColor.d.ts +34 -0
  506. package/dist/shared/themeColor.js +109 -0
  507. package/dist/shared/themeFaces.d.ts +30 -0
  508. package/dist/shared/themeFaces.js +42 -0
  509. package/dist/shared/themeInk.d.ts +20 -0
  510. package/dist/shared/themeInk.js +52 -0
  511. package/dist/shared/themeLooks.d.ts +9 -0
  512. package/dist/shared/themeLooks.js +572 -0
  513. package/dist/shared/themeParts.d.ts +26 -0
  514. package/dist/shared/themeParts.js +71 -0
  515. package/dist/shared/themePartsCheck.d.ts +21 -0
  516. package/dist/shared/themePartsCheck.js +91 -0
  517. package/dist/shared/themePresets.d.ts +85 -0
  518. package/dist/shared/themePresets.js +139 -0
  519. package/dist/shared/themeRecipeWords.d.ts +156 -0
  520. package/dist/shared/themeRecipeWords.js +156 -0
  521. package/dist/shared/themeRecipes.d.ts +213 -0
  522. package/dist/shared/themeRecipes.js +234 -0
  523. package/dist/shared/themeResolve.d.ts +55 -0
  524. package/dist/shared/themeResolve.js +52 -0
  525. package/dist/shared/themeTokens.d.ts +107 -0
  526. package/dist/shared/themeTokens.js +116 -0
  527. package/dist/shared/themeType.d.ts +38 -0
  528. package/dist/shared/themeType.js +205 -0
  529. package/dist/shared/unitWord.d.ts +4 -0
  530. package/dist/shared/unitWord.js +37 -0
  531. package/dist/shared/view.d.ts +195 -0
  532. package/dist/shared/view.js +987 -0
  533. package/dist/shared/viewLabels.d.ts +47 -0
  534. package/dist/shared/viewLabels.js +459 -0
  535. package/dist/shared/viewPaths.d.ts +248 -0
  536. package/dist/shared/viewPaths.js +294 -0
  537. package/dist/shared/viewtext.d.ts +57 -0
  538. package/dist/shared/viewtext.js +282 -0
  539. package/dist/shared/vocabulary.d.ts +71 -0
  540. package/dist/shared/vocabulary.js +249 -0
  541. package/dist/shared/weekStart.d.ts +7 -0
  542. package/dist/shared/weekStart.js +36 -0
  543. package/mark.svg +1 -0
  544. package/package.json +261 -4
  545. package/schema/model.d.ts +298 -0
  546. package/schema/theme.d.ts +587 -0
@@ -0,0 +1,217 @@
1
+ /** One condition in a filter. Values are bound, never interpolated. */
2
+ export interface Condition {
3
+ column: string;
4
+ op: Op;
5
+ /** Absent for `is null` / `is not null`; an array for `in`. */
6
+ value?: string | number | boolean | Array<string | number>;
7
+ /**
8
+ * Compare text by its bytes rather than by the column's collation; `binary`
9
+ * is the only value, and only a comparison takes it. An API cursor resumes
10
+ * where the last page stopped, which is sound only when the ORDER BY and the
11
+ * boundary comparison agree exactly on every engine — a locale collation
12
+ * can order `a`, `B` and `b` differently from one database to the next.
13
+ */
14
+ collation?: 'binary';
15
+ /**
16
+ * Compare with another column rather than a value: `on_hand <
17
+ * product_id.reorder_level`. A column name or, in a view, a reference path;
18
+ * only the six comparisons take it, and `value` is then absent. It becomes
19
+ * an identifier in the statement, so only a builder that resolves it (a
20
+ * view's, which checks every path against the catalog it was given) may
21
+ * compile it; `buildWhere` refuses it otherwise, and a structured request
22
+ * cannot use it to name a column its reader was never granted.
23
+ */
24
+ other?: string;
25
+ /**
26
+ * Rows of another table that point at this one: `any opportunity where
27
+ * stage = negotiation` holds where at least one such row matches. Written
28
+ * as `EXISTS (…)` over the child's relation, so a row scope on the child
29
+ * narrows it as it narrows a list of those rows. Only a builder that knows
30
+ * the row it is asked of (a view's, a breakdown's: `buildWhere`'s
31
+ * `exists`) compiles it; everywhere else it is refused, never dropped.
32
+ * `op` is `isNotNull` for `any`, `isNull` for `no`.
33
+ */
34
+ any?: AnyRows;
35
+ }
36
+ /**
37
+ * The child rows an `any` condition asks about: the reference they point
38
+ * at the record through, as `child.column` (`+`-joined for a composite key)
39
+ * — endpoints, as a rollup's `via`, so a layer that renames tables rewrites
40
+ * it without resolving anything — and which of them count: conditions over
41
+ * the child's own columns and paths up from it.
42
+ */
43
+ export interface AnyRows {
44
+ via: string;
45
+ filter?: Filter;
46
+ }
47
+ export type Op = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'contains' | 'startsWith' | 'endsWith'
48
+ /**
49
+ * A LIKE pattern written by hand, wildcards and all.
50
+ *
51
+ * The deliberate opposite of `contains`, which escapes `%` and `_` so that
52
+ * searching for `50%` finds a percent sign. Here they are the point: `like
53
+ * Wh%` is a prefix, `like _a%` is "second letter a". The escape character
54
+ * is still declared, so `like 50#%` finds the literal — the one thing a
55
+ * pass-through pattern would otherwise make impossible to ask for.
56
+ */
57
+ | 'like' | 'in'
58
+ /**
59
+ * A record's tags hold any of the labels: `tags has (bug, docs)` (tagLists.ts).
60
+ * Only a builder that knows the record's tags compiles it (`buildWhere`'s
61
+ * `membership`); everywhere else it is refused.
62
+ */
63
+ | 'has' | 'isNull' | 'isNotNull';
64
+ /**
65
+ * The operators, as a value rather than only as a type.
66
+ *
67
+ * `Op` is checked by the compiler, and the compiler is not present when a
68
+ * request arrives: `/api/query`, `/api/count`, `/api/view/run` and
69
+ * `/api/references` all cast a request body straight to `Filter`, so the type
70
+ * was a comment as far as those paths were concerned. This is the list
71
+ * `buildWhere` actually checks against.
72
+ */
73
+ export declare const OPS: ReadonlySet<string>;
74
+ /**
75
+ * A filter is OR-of-ANDs, which is the shape every UI condition builder
76
+ * produces and the shape that compiles to SQL without parentheses gymnastics.
77
+ * An empty `groups` means no filter.
78
+ */
79
+ export interface Filter {
80
+ groups: Condition[][];
81
+ }
82
+ export interface SqlFragment {
83
+ text: string;
84
+ params: unknown[];
85
+ }
86
+ /** How each dialect quotes an identifier and writes a placeholder. */
87
+ export interface SqlStyle {
88
+ quote(identifier: string): string;
89
+ /** Postgres wants $1, $2…; sqlite wants ?. */
90
+ placeholder(index: number): string;
91
+ /**
92
+ * The operator that matches text without regard to case.
93
+ *
94
+ * `contains` is a browsing operator: someone typing `contains nakamura`
95
+ * means the name however it is capitalised, and the same query returning a
96
+ * row on SQLite and nothing on Postgres is the tool disagreeing with
97
+ * itself about what it was asked. SQLite's LIKE folds ASCII case already;
98
+ * Postgres needs to be asked.
99
+ */
100
+ likeOp: string;
101
+ /**
102
+ * A date or timestamp cut down to a period: day, week, month, quarter or year, or the weekday or hour it recurs on.
103
+ * A week is said by its first day (`2026-10-05`), the ISO weekday `weekStart` names (1 Monday … 7 Sunday; Monday
104
+ * when unsaid), so a week label is a day label and sorts, survives JSON and reads alike on every engine.
105
+ *
106
+ * Every engine here has this and every engine spells it differently, which
107
+ * is exactly what a style is for. The result is *text* on purpose —
108
+ * `2026-08`, `2026-Q3` — rather than a truncated timestamp: a breakdown's
109
+ * group key is a label, it has to survive JSON, sort correctly as a string,
110
+ * and mean the same thing on all three engines. A `date_trunc` returning a
111
+ * timestamp does none of those.
112
+ *
113
+ * SQLite has no date type, only text in a format `strftime` understands.
114
+ * That is a real limit rather than an oversight here: a column holding
115
+ * `14/03/2025` is not a date to SQLite either, and a bucket over it is
116
+ * null — which the breakdown shows as a group rather than hiding.
117
+ */
118
+ dateBucket(expression: string, unit: DateUnit, weekStart?: number): string;
119
+ /**
120
+ * The clause that orders and compares text by its bytes. Absent where no
121
+ * one clause does that for every text column, and then a binary collation
122
+ * is refused rather than approximated.
123
+ */
124
+ binaryText?: string;
125
+ /** An expression as text, for a record label that joins values into words. */
126
+ text(expression: string): string;
127
+ /** Text pieces joined into one: the dialect's concatenation. */
128
+ concat(parts: readonly string[]): string;
129
+ /**
130
+ * How many rows meet a predicate, as one aggregate among others in a
131
+ * SELECT. Absent, `COUNT(CASE WHEN … THEN 1 END)`, which every engine here
132
+ * reads and which is 0, not NULL, over no rows.
133
+ */
134
+ countWhere?(predicate: string): string;
135
+ /**
136
+ * Said between a common table expression's name and its body. Postgres 12
137
+ * and later inline a CTE referenced once and materialize one referenced
138
+ * twice; a row scope's CTE is referenced as often as the read joins its
139
+ * table, and materializing it copies the whole scoped slice before the
140
+ * outer filter, sort and limit can use an index (rowScope.ts).
141
+ */
142
+ cteHint?: string;
143
+ /**
144
+ * The engine, for what a style's hooks cannot say one at a time: a computed
145
+ * column's date arithmetic and its yes-or-no (computed.ts). Absent is SQLite's.
146
+ */
147
+ dialect?: 'sqlite' | 'postgres';
148
+ /**
149
+ * One key of a JSON column (`specs.capacity`, definedFields.ts): as its JSON
150
+ * value (a select or a sort), as text (an equality, a pattern, emptiness;
151
+ * a yes-or-no as `true`/`false`), or as a number where it holds one (a
152
+ * range against a number). The key is an identifier, checked where the
153
+ * path resolves, so it is written as a literal. Absent: no JSON keys here.
154
+ */
155
+ jsonKey?(expression: string, key: string, as: 'value' | 'text' | 'number'): string;
156
+ /** Whether a JSON key's list (or its one value) holds any of the bound values: `has` on a many-of-a-list field. */
157
+ jsonHas?(expression: string, key: string, holes: readonly string[]): string;
158
+ }
159
+ /** The periods a breakdown can group dates by: a calendar's (day to year), and the two that recur — the ISO
160
+ weekday, "1" (Monday) to "7", and the hour of the day, "00" to "23" — which a heat map crosses. */
161
+ export type DateUnit = 'day' | 'week' | 'month' | 'quarter' | 'year' | 'weekday' | 'hour';
162
+ /** A week start as the SQL may say it: an ISO weekday, 1 to 7, Monday when unsaid. Never a request's text. */
163
+ export declare function weekStartDay(weekStart: number | undefined): number;
164
+ export declare const ANSI_STYLE: SqlStyle;
165
+ export declare const POSTGRES_STYLE: SqlStyle;
166
+ /**
167
+ * Postgres 12 and later: row-scope CTEs stay inlined however often a read
168
+ * joins their table. The adapter picks it once it knows the server's version
169
+ * (PostgresAdapter.scopeStyle); an older server keeps POSTGRES_STYLE, where every CTE
170
+ * is materialized anyway and the hint would be a syntax error.
171
+ */
172
+ export declare const POSTGRES_INLINE_STYLE: SqlStyle;
173
+ /** One ORDER BY term: an expression and its direction, and the vocabulary it sorts by where it has one. */
174
+ interface OrderTerm {
175
+ expression: string;
176
+ direction: 'asc' | 'desc';
177
+ /** The values in their declared order (schema.ts `declaredOrder`). */
178
+ declared?: readonly string[];
179
+ }
180
+ /**
181
+ * An ORDER BY clause, or nothing. A term with a declared vocabulary sorts its
182
+ * values in the order they were written, through a CASE every engine reads,
183
+ * anything outside it (NULL, where the column may hold one) after the last
184
+ * and the value itself as the tiebreak there. The values are bound
185
+ * parameters like any other, numbered from `startIndex`: the clause sits
186
+ * after the WHERE, so its parameters follow the WHERE's. A term already
187
+ * written as text (an alias, a distance) is passed through.
188
+ */
189
+ export declare function orderClauseSql(terms: readonly (OrderTerm | string)[], style: SqlStyle, startIndex?: number): SqlFragment;
190
+ /**
191
+ * An expression under a requested collation. Unrequested, it is unchanged; a
192
+ * collation the style cannot say is refused, never dropped: silently falling
193
+ * back to the column's collation is the disagreement this exists to prevent.
194
+ */
195
+ export declare function collate(expression: string, collation: unknown, style: SqlStyle): string;
196
+ /**
197
+ * Compile a filter to a WHERE clause plus bound parameters.
198
+ *
199
+ * `startIndex` exists for Postgres, where placeholders are numbered across the
200
+ * whole statement rather than positional.
201
+ *
202
+ * `column` exists for views. A multi-table statement needs
203
+ * `"customer_1"."name"` where a single-table one needs `"name"`, and the
204
+ * difference is *only* how an identifier is written — the operators, the
205
+ * empty-IN case, the LIKE wrapping and the invariant that every value is a
206
+ * bound parameter are the same either way. Passing the resolver in keeps one
207
+ * predicate builder rather than two that can drift; a second copy of this
208
+ * function is a second chance to interpolate a value by accident.
209
+ */
210
+ export declare function buildWhere(filter: Filter | undefined, style: SqlStyle, startIndex?: number, column?: (name: string, condition?: Condition) => string,
211
+ /** How a column-to-column comparison's other side is written; absent, one is refused. */
212
+ other?: (name: string) => string,
213
+ /** How `has` is written for a column naming a record's tags, given the bound labels' placeholders; absent, `has` is refused. */
214
+ membership?: (name: string, holes: readonly string[]) => string,
215
+ /** How an `any` condition is written: an EXISTS over the child's rows, binding nothing of its own; absent, one is refused. */
216
+ exists?: (rows: AnyRows) => string): SqlFragment;
217
+ export {};
@@ -0,0 +1,305 @@
1
+ /*
2
+ * A filter, and the one place it becomes SQL. The query language, views, row
3
+ * scopes and breakdowns in shared/ build their WHERE clauses through it, so
4
+ * it lives here rather than with the adapters that run the statements.
5
+ */
6
+ import { LIKE_ESCAPE, likePattern } from './like.js';
7
+ import { Refusal } from './refusal.js';
8
+ /**
9
+ * The operators, as a value rather than only as a type.
10
+ *
11
+ * `Op` is checked by the compiler, and the compiler is not present when a
12
+ * request arrives: `/api/query`, `/api/count`, `/api/view/run` and
13
+ * `/api/references` all cast a request body straight to `Filter`, so the type
14
+ * was a comment as far as those paths were concerned. This is the list
15
+ * `buildWhere` actually checks against.
16
+ */
17
+ export const OPS = new Set([
18
+ '=',
19
+ '!=',
20
+ '>',
21
+ '>=',
22
+ '<',
23
+ '<=',
24
+ 'contains',
25
+ 'startsWith',
26
+ 'endsWith',
27
+ 'like',
28
+ 'in',
29
+ 'has',
30
+ 'isNull',
31
+ 'isNotNull',
32
+ ]);
33
+ /** How many days a date is past its week's first day, `start` the ISO weekday it starts on, from the ISO weekday
34
+ expression `isoDay`: `(isoDay + 7 - start) % 7`, so Monday is 0 in a Monday week and Sunday 0 in a Sunday one. */
35
+ const intoWeek = (isoDay, start) => `(${isoDay} + ${7 - start}) % 7`;
36
+ /** A week start as the SQL may say it: an ISO weekday, 1 to 7, Monday when unsaid. Never a request's text. */
37
+ export function weekStartDay(weekStart) {
38
+ if (weekStart === undefined)
39
+ return 1;
40
+ if (!Number.isInteger(weekStart) || weekStart < 1 || weekStart > 7)
41
+ throw new Error(`A week starts on an ISO weekday, 1 (Monday) to 7 (Sunday), not ${String(weekStart).slice(0, 20)}.`);
42
+ return weekStart;
43
+ }
44
+ export const ANSI_STYLE = {
45
+ dialect: 'sqlite',
46
+ // Doubling an embedded quote is the standard escape and is what makes a
47
+ // table called `weird"name` safe rather than a syntax error.
48
+ quote: (id) => `"${id.replace(/"/g, '""')}"`,
49
+ placeholder: () => '?',
50
+ likeOp: 'LIKE',
51
+ /* `strftime` has no quarter, so it is arithmetic on the month: 1–3 → 1.
52
+ Written with the engine's own integer division rather than a CASE, which
53
+ would be four branches to say one sum. */
54
+ /* A week: `weekday N` moves forward to the week's last day (N counts from Sunday at 0) or stays on it, and six
55
+ days back is its first, the date alone. */
56
+ dateBucket: (e, unit, weekStart) => unit === 'week'
57
+ ? `strftime('%Y-%m-%d', ${e}, 'weekday ${(weekStartDay(weekStart) + 6) % 7}', '-6 days')`
58
+ : unit === 'quarter'
59
+ ? `strftime('%Y', ${e}) || '-Q' || CAST((CAST(strftime('%m', ${e}) AS INTEGER) + 2) / 3 AS TEXT)`
60
+ : unit === 'weekday'
61
+ ? /* `%w` counts from Sunday at 0; the ISO week starts on Monday at 1, as the other two engines say it. */
62
+ `CAST((CAST(strftime('%w', ${e}) AS INTEGER) + 6) % 7 + 1 AS TEXT)`
63
+ : `strftime('${{ day: '%Y-%m-%d', month: '%Y-%m', year: '%Y', hour: '%H' }[unit]}', ${e})`,
64
+ // SQLite's default, said aloud so a column declared NOCASE cannot change it.
65
+ binaryText: ' COLLATE BINARY',
66
+ text: (e) => `CAST(${e} AS TEXT)`,
67
+ concat: (parts) => `(${parts.join(' || ')})`,
68
+ /* json1: json_extract reads a true as 1, so text says a yes-or-no by its JSON type. */
69
+ jsonKey: (e, key, as) => as === 'value'
70
+ ? `json_extract(${e}, '$.${key}')`
71
+ : as === 'number'
72
+ ? `CASE WHEN json_type(${e}, '$.${key}') IN ('integer', 'real') THEN json_extract(${e}, '$.${key}') END`
73
+ : `CASE json_type(${e}, '$.${key}') WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE CAST(json_extract(${e}, '$.${key}') AS TEXT) END`,
74
+ jsonHas: (e, key, holes) => `EXISTS (SELECT 1 FROM json_each(${e}, '$.${key}') WHERE value IN (${holes.join(', ')}))`,
75
+ };
76
+ export const POSTGRES_STYLE = {
77
+ dialect: 'postgres',
78
+ quote: ANSI_STYLE.quote,
79
+ placeholder: (i) => `$${i}`,
80
+ likeOp: 'ILIKE',
81
+ /* `to_char` rather than `date_trunc`, for the text the interface says it
82
+ returns. `Q` is a to_char field, so the quarter needs no arithmetic. */
83
+ /* A week: the date less the days it is past its week's first (`date - integer` is a date). */
84
+ dateBucket: (e, unit, weekStart) => unit === 'week'
85
+ ? `to_char(CAST(${e} AS date) - CAST(${intoWeek(`CAST(EXTRACT(ISODOW FROM ${e}) AS integer)`, weekStartDay(weekStart))} AS integer), 'YYYY-MM-DD')`
86
+ : `to_char(${e}, '${{ day: 'YYYY-MM-DD', month: 'YYYY-MM', quarter: 'YYYY-"Q"Q', year: 'YYYY', weekday: 'ID', hour: 'HH24' }[unit]}')`,
87
+ /* "C" is byte order in every encoding and every database, whatever the
88
+ cluster's or the column's own collation says. */
89
+ binaryText: ' COLLATE "C"',
90
+ text: (e) => `CAST(${e} AS TEXT)`,
91
+ concat: (parts) => `(${parts.join(' || ')})`,
92
+ countWhere: (predicate) => `COUNT(*) FILTER (WHERE ${predicate})`,
93
+ /* Through jsonb whatever the column is (json or jsonb): `->` orders numbers as numbers, `->>` is the text,
94
+ `?|` asks a list's elements (and a lone string) for any of the values. */
95
+ jsonKey: (e, key, as) => as === 'value'
96
+ ? `((${e})::jsonb -> '${key}')`
97
+ : as === 'number'
98
+ ? `CASE WHEN jsonb_typeof((${e})::jsonb -> '${key}') = 'number' THEN ((${e})::jsonb ->> '${key}')::numeric END`
99
+ : `((${e})::jsonb ->> '${key}')`,
100
+ jsonHas: (e, key, holes) => `(((${e})::jsonb -> '${key}') ?| ARRAY[${holes.join(', ')}]::text[])`,
101
+ };
102
+ /**
103
+ * Postgres 12 and later: row-scope CTEs stay inlined however often a read
104
+ * joins their table. The adapter picks it once it knows the server's version
105
+ * (PostgresAdapter.scopeStyle); an older server keeps POSTGRES_STYLE, where every CTE
106
+ * is materialized anyway and the hint would be a syntax error.
107
+ */
108
+ export const POSTGRES_INLINE_STYLE = { ...POSTGRES_STYLE, cteHint: ' NOT MATERIALIZED' };
109
+ /**
110
+ * An ORDER BY clause, or nothing. A term with a declared vocabulary sorts its
111
+ * values in the order they were written, through a CASE every engine reads,
112
+ * anything outside it (NULL, where the column may hold one) after the last
113
+ * and the value itself as the tiebreak there. The values are bound
114
+ * parameters like any other, numbered from `startIndex`: the clause sits
115
+ * after the WHERE, so its parameters follow the WHERE's. A term already
116
+ * written as text (an alias, a distance) is passed through.
117
+ */
118
+ export function orderClauseSql(terms, style, startIndex = 1) {
119
+ if (!terms.length)
120
+ return { text: '', params: [] };
121
+ const params = [];
122
+ const text = terms
123
+ .map((term) => {
124
+ if (typeof term === 'string')
125
+ return term;
126
+ const dir = term.direction === 'desc' ? 'DESC' : 'ASC';
127
+ if (!term.declared?.length)
128
+ return `${term.expression} ${dir}`;
129
+ const rank = term.declared
130
+ .map((value, at) => {
131
+ params.push(value);
132
+ return `WHEN ${style.placeholder(startIndex + params.length - 1)} THEN ${at}`;
133
+ })
134
+ .join(' ');
135
+ return `CASE ${term.expression} ${rank} ELSE ${term.declared.length} END ${dir}, ${term.expression} ${dir}`;
136
+ })
137
+ .join(', ');
138
+ return { text: ` ORDER BY ${text}`, params };
139
+ }
140
+ /**
141
+ * An expression under a requested collation. Unrequested, it is unchanged; a
142
+ * collation the style cannot say is refused, never dropped: silently falling
143
+ * back to the column's collation is the disagreement this exists to prevent.
144
+ */
145
+ export function collate(expression, collation, style) {
146
+ if (collation === undefined)
147
+ return expression;
148
+ if (collation !== 'binary' || !style.binaryText)
149
+ throw new Refusal('This comparison cannot be made by bytes on this database.');
150
+ return `${expression}${style.binaryText}`;
151
+ }
152
+ const COMPARISONS = new Set(['=', '!=', '>', '>=', '<', '<=']);
153
+ /**
154
+ * Compile a filter to a WHERE clause plus bound parameters.
155
+ *
156
+ * `startIndex` exists for Postgres, where placeholders are numbered across the
157
+ * whole statement rather than positional.
158
+ *
159
+ * `column` exists for views. A multi-table statement needs
160
+ * `"customer_1"."name"` where a single-table one needs `"name"`, and the
161
+ * difference is *only* how an identifier is written — the operators, the
162
+ * empty-IN case, the LIKE wrapping and the invariant that every value is a
163
+ * bound parameter are the same either way. Passing the resolver in keeps one
164
+ * predicate builder rather than two that can drift; a second copy of this
165
+ * function is a second chance to interpolate a value by accident.
166
+ */
167
+ export function buildWhere(filter, style, startIndex = 1,
168
+ /* Told the condition too, so a JSON key can be read as the comparison needs it (SqlStyle.jsonKey). */
169
+ column = (name) => style.quote(name),
170
+ /** How a column-to-column comparison's other side is written; absent, one is refused. */
171
+ other,
172
+ /** How `has` is written for a column naming a record's tags, given the bound labels' placeholders; absent, `has` is refused. */
173
+ membership,
174
+ /** How an `any` condition is written: an EXISTS over the child's rows, binding nothing of its own; absent, one is refused. */
175
+ exists) {
176
+ if (!filter?.groups.length)
177
+ return { text: '', params: [] };
178
+ const params = [];
179
+ let index = startIndex;
180
+ const next = () => style.placeholder(index++);
181
+ /* A condition every group holds is said once, before the OR: the same
182
+ rows (AND distributes over OR in SQL's three-valued logic too), and the
183
+ shape an engine can read a range from. A keyset page's bound is in every
184
+ branch of its continuation (keysetPage.ts); SQLite read the OR-of-ANDs
185
+ as one index search per branch and a sort of everything they found —
186
+ page two of a million rows was 150 ms — and the factored form as one
187
+ range, 0.1 ms. */
188
+ const nonempty = filter.groups.filter((g) => g.length);
189
+ const common = nonempty.length > 1
190
+ ? nonempty[0].filter((c, at) => nonempty[0].findIndex((d) => sameCondition(c, d)) === at && nonempty.every((g) => g.some((d) => sameCondition(c, d))))
191
+ : [];
192
+ const rest = common.length ? nonempty.map((g) => g.filter((c) => !common.some((d) => sameCondition(c, d)))) : nonempty;
193
+ const compile = (group) => group
194
+ .map((c) => {
195
+ if (c.collation !== undefined && !COMPARISONS.has(c.op)) {
196
+ throw new Refusal('Only a comparison can compare text by bytes.');
197
+ }
198
+ /* Before the column is written: child rows are no column of this row. Their
199
+ values are bound where their relation is planned (rowScope.ts `filtered`),
200
+ so the EXISTS carries no parameter here and the numbering is untouched. */
201
+ if (c.any !== undefined) {
202
+ if (!exists || typeof c.any !== 'object' || c.any === null)
203
+ throw new Refusal('This read cannot ask about the rows that point at it.');
204
+ /* `no task …` is the same rows asked the other way: none of them matches. */
205
+ return c.op === 'isNull' ? `NOT ${exists(c.any)}` : exists(c.any);
206
+ }
207
+ /* Before the column is written: a record's tags are no column. */
208
+ if (c.op === 'has') {
209
+ if (!membership || c.other !== undefined)
210
+ throw new Refusal("This read cannot ask a record's tags.");
211
+ const labels = (Array.isArray(c.value) ? c.value : [c.value]).filter((v) => typeof v === 'string' || typeof v === 'number');
212
+ if (!labels.length)
213
+ return '1 = 0';
214
+ const holes = labels.map((v) => {
215
+ params.push(String(v));
216
+ return next();
217
+ });
218
+ return membership(c.column, holes);
219
+ }
220
+ const col = collate(column(c.column, c), c.collation, style);
221
+ if (c.other !== undefined) {
222
+ if (!other || typeof c.other !== 'string' || !COMPARISONS.has(c.op)) {
223
+ throw new Refusal('This read cannot compare two columns.');
224
+ }
225
+ return `${col} ${c.op} ${collate(other(c.other), c.collation, style)}`;
226
+ }
227
+ switch (c.op) {
228
+ case 'isNull':
229
+ return `${col} IS NULL`;
230
+ case 'isNotNull':
231
+ return `${col} IS NOT NULL`;
232
+ case 'in': {
233
+ const list = Array.isArray(c.value) ? c.value : [c.value];
234
+ if (!list.length)
235
+ return '1 = 0'; // an empty IN matches nothing
236
+ const holes = list.map((v) => {
237
+ params.push(v ?? null);
238
+ return next();
239
+ });
240
+ return `${col} IN (${holes.join(', ')})`;
241
+ }
242
+ /* All three go through one pattern builder, which escapes the
243
+ wildcards in the value: `contains 50%` is a search for a
244
+ percent sign, not a search for everything. */
245
+ case 'contains':
246
+ case 'startsWith':
247
+ case 'endsWith':
248
+ params.push(likePattern(c.value, c.op));
249
+ return `${col} ${style.likeOp} ${next()} ESCAPE '${LIKE_ESCAPE}'`;
250
+ /* Bound, not escaped: the wildcards belong to whoever typed them.
251
+ Still a parameter — the value never becomes SQL text — so the
252
+ safety argument is unchanged, and still `ESCAPE '#'`, so the
253
+ way to ask for a literal `%` is the same one `contains` uses
254
+ internally. */
255
+ case 'like':
256
+ params.push(String(c.value ?? ''));
257
+ return `${col} ${style.likeOp} ${next()} ESCAPE '${LIKE_ESCAPE}'`;
258
+ default: {
259
+ /* The one field in a structured request that becomes SQL text
260
+ rather than a bound parameter — and until now it was checked
261
+ only by the config-file parser, so every endpoint that casts
262
+ a body to `Filter` accepted whatever it was sent. The column
263
+ is quoted and the value is bound; this was the gap between
264
+ those two, and the whole safety argument is that a structured
265
+ request cannot express injection.
266
+
267
+ Checked here rather than at each caller: one choke point
268
+ covers the four endpoints and anything added later. */
269
+ if (!OPS.has(c.op)) {
270
+ throw new Refusal(`"${String(c.op)}" is not an operator this tool knows.`);
271
+ }
272
+ params.push(c.value ?? null);
273
+ return `${col} ${c.op} ${next()}`;
274
+ }
275
+ }
276
+ })
277
+ .join(' AND ');
278
+ const shared = common.length ? compile(common) : '';
279
+ /* A group that held only the shared conditions is true once they are:
280
+ the OR after them is then true, and not said. */
281
+ const groupSql = rest.some((g) => !g.length) ? [] : rest.map(compile);
282
+ if (!shared && !groupSql.length)
283
+ return { text: '', params: [] };
284
+ const alternatives = groupSql.length === 1 ? groupSql[0] : groupSql.map((g) => `(${g})`).join(' OR ');
285
+ const text = !shared
286
+ ? alternatives
287
+ : !groupSql.length
288
+ ? shared
289
+ : `${shared} AND ${groupSql.length === 1 ? alternatives : `(${alternatives})`}`;
290
+ return { text: ` WHERE ${text}`, params };
291
+ }
292
+ /** The same condition, field for field: what may be said once for every group. */
293
+ function sameCondition(a, b) {
294
+ if (a === b)
295
+ return true;
296
+ if (a.column !== b.column || a.op !== b.op || a.collation !== b.collation || a.other !== b.other || a.any !== b.any)
297
+ return false;
298
+ if (Array.isArray(a.value) || Array.isArray(b.value)) {
299
+ return (Array.isArray(a.value) &&
300
+ Array.isArray(b.value) &&
301
+ a.value.length === b.value.length &&
302
+ a.value.every((v, i) => v === b.value[i]));
303
+ }
304
+ return a.value === b.value;
305
+ }
@@ -0,0 +1,24 @@
1
+ /** The id of the page's data block: `<script type="application/json" id=…>`, never run. */
2
+ export declare const FIRST_PAINT_ELEMENT = "mistri-first-paint";
3
+ /** One answer: the reply's JSON and the account the reply said it was for (`x-mistri-account`), as a fetch would have been told. */
4
+ export interface FirstPaintRead {
5
+ body: unknown;
6
+ account?: string;
7
+ /** The tables it answered from (`mistri-reads`), where a reply's header would have said: live sync asks it again only when one changes. */
8
+ reads?: string;
9
+ }
10
+ /** What the page carries. `reads` by readKey, `items` by itemKey. */
11
+ export interface FirstPaintData {
12
+ reads: Record<string, FirstPaintRead>;
13
+ items: Record<string, FirstPaintRead>;
14
+ }
15
+ /** A request as the client sends it: `GET /api/app?app=compass`, or a POST and its body. */
16
+ export declare function readKey(method: 'GET' | 'POST', url: string, payload?: unknown): string;
17
+ /**
18
+ * One read a batch carries, on the connection it goes to: a breakdown
19
+ * (`{ text, limit }` or `{ def, limit }`), a list's rows (the `run` a
20
+ * dashboard's table asks) or a count (`{ q, countLimit }`), each as its item
21
+ * is sent.
22
+ */
23
+ export type FirstPaintItemKind = 'breakdown' | 'run' | 'count';
24
+ export declare function itemKey(kind: FirstPaintItemKind, owner: string, item: unknown): string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A first page's data, carried in the page itself (server/http/firstPaint.ts
3
+ * writes it, client/firstPaint.ts reads it).
4
+ *
5
+ * The shell used to arrive empty and ask for everything it draws in three
6
+ * rounds — who is here, then the runtime, then the App, its schema, its
7
+ * pages and saved views together — and only then the first room's rows:
8
+ * four round trips before a first page, each a network's latency. The
9
+ * server knows the address when it sends the page, so it asks those same
10
+ * requests of itself, through the same routes and gate a fetch reaches, and
11
+ * writes each answer into the page under the request it answers. The client
12
+ * asks as it always did; a request the page already answers is answered
13
+ * from it, once, and any other goes out.
14
+ *
15
+ * An answer is keyed by the request exactly as the client sends it: the
16
+ * method, the address with its query string and the JSON body, the App's
17
+ * selector included (requestIdentity.ts). A read that a batch carries — a
18
+ * dashboard's breakdowns and lists, the menu's and a list's tab counts — is
19
+ * keyed by the one item, because which items share a batch depends on what a
20
+ * paint mounted together, which the server cannot know and need not.
21
+ *
22
+ * Imports nothing but the key text, so the entry chunk carries no more than this.
23
+ */
24
+ import { canonicalText } from './recordReadKeys.js';
25
+ /** The id of the page's data block: `<script type="application/json" id=…>`, never run. */
26
+ export const FIRST_PAINT_ELEMENT = 'mistri-first-paint';
27
+ /** A request as the client sends it: `GET /api/app?app=compass`, or a POST and its body. */
28
+ export function readKey(method, url, payload) {
29
+ return `${method} ${url}\u0000${payload === undefined ? '' : canonicalText(payload)}`;
30
+ }
31
+ export function itemKey(kind, owner, item) {
32
+ return `${kind}\u0000${owner}\u0000${canonicalText(item)}`;
33
+ }
@@ -0,0 +1,21 @@
1
+ import type { ColumnMeta, TableMeta } from './schema.js';
2
+ /** The explicit selection wins; otherwise steps declare the form's fields
3
+ * in order. Groups only arrange fields and do not narrow a schema-derived form. */
4
+ export declare function formShownFields(form: {
5
+ show?: readonly string[];
6
+ steps?: readonly {
7
+ fields: readonly string[];
8
+ }[];
9
+ } | undefined): readonly string[] | undefined;
10
+ /** A single key that can be omitted because the catalog promises a value. */
11
+ export declare function autoKey(table: TableMeta): string | null;
12
+ /** Omitting this column cannot rely on a database default or assigned key. */
13
+ export declare function isRequired(column: ColumnMeta, assigned: string | null): boolean;
14
+ /**
15
+ * The columns a new row must be given and `writes` does not write: while any
16
+ * is left, every New form of those fields is refused by the database, so none
17
+ * is offered (accessibleSchema) and `mistri check` says which. Judged on
18
+ * the whole catalog, since a column the writer cannot even read is one it
19
+ * cannot fill either.
20
+ */
21
+ export declare function unformedColumns(table: TableMeta, writes: (column: string) => boolean): string[];
@@ -0,0 +1,25 @@
1
+ /** The explicit selection wins; otherwise steps declare the form's fields
2
+ * in order. Groups only arrange fields and do not narrow a schema-derived form. */
3
+ export function formShownFields(form) {
4
+ return form?.show ?? form?.steps?.flatMap((step) => step.fields);
5
+ }
6
+ /** A single key that can be omitted because the catalog promises a value. */
7
+ export function autoKey(table) {
8
+ const pk = table.columns.filter((c) => c.primaryKey);
9
+ return pk.length === 1 && (pk[0].identity || pk[0].default !== undefined || pk[0].hasDefault === true) ? pk[0].name : null;
10
+ }
11
+ /** Omitting this column cannot rely on a database default or assigned key. */
12
+ export function isRequired(column, assigned) {
13
+ return !column.nullable && column.default === undefined && column.hasDefault !== true && !column.identity && column.name !== assigned;
14
+ }
15
+ /**
16
+ * The columns a new row must be given and `writes` does not write: while any
17
+ * is left, every New form of those fields is refused by the database, so none
18
+ * is offered (accessibleSchema) and `mistri check` says which. Judged on
19
+ * the whole catalog, since a column the writer cannot even read is one it
20
+ * cannot fill either.
21
+ */
22
+ export function unformedColumns(table, writes) {
23
+ const assigned = autoKey(table);
24
+ return table.columns.filter((column) => isRequired(column, assigned) && !writes(column.name)).map((column) => column.name);
25
+ }