@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,104 @@
1
+ /**
2
+ * How a form reads a record's own values, in the browser as someone types and on the server after: a condition in
3
+ * the query language compiled to comparisons and judged against a row, a scalar a declaration may hold, the words a
4
+ * default fills in (`today`, `now`, `me`), the starting values a schema's DEFAULTs already say, a stored value as an
5
+ * expression reads it, and a multi-step form's step. The engine's, because the kit's New form draws a table's form
6
+ * with them in both shells; the App framework's form declarations — their parsing, validation, child groups and
7
+ * rules — are formRules.ts and formLines.ts, which re-export what they always named.
8
+ */
9
+ import { type ColumnMeta, type TableMeta } from './schema.js';
10
+ import type { ComputedValue } from './computed.js';
11
+ /** Data only: local columns, no paths, expressions, clock or executable hooks. */
12
+ export type FormScalar = string | number | boolean | null;
13
+ /** The comparisons a compiled condition holds: the query language's own, named for the evaluator. */
14
+ export type FormOperator = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte';
15
+ /**
16
+ * A condition in the query language — the one a page section's `when` and an
17
+ * action's `when` speak — read against a record's own values rather than run
18
+ * as SQL: "completed = false", "stage = closed_won and probability < 100".
19
+ * One language for every condition an App writes; what a form or a rule can
20
+ * evaluate in memory is its comparisons of local columns (`=`, `!=`, `<`,
21
+ * `<=`, `>`, `>=`, `in`, `is (not) empty`) under `and`, `or` and brackets.
22
+ */
23
+ export type FormCondition = string;
24
+ /** One compiled comparison: true when the field compares with any of the values (one, or an `in` list), or with
25
+ * the record's own `other` column. */
26
+ interface Comparison {
27
+ field: string;
28
+ operator: FormOperator;
29
+ values: readonly FormScalar[];
30
+ other?: string;
31
+ }
32
+ /** A compiled condition: OR of ANDs, the query language's own filter shape. */
33
+ export type CompiledCondition = readonly (readonly Comparison[])[];
34
+ /** A finite, data-only step in a multi-step form. Fields belong to one step. The
35
+ * parser gives a step without an id its label's slug, as `step()` does. */
36
+ export interface FormStep<Field extends string = string> {
37
+ id: string;
38
+ /** The short name: the review's section, the stepper's entry and the progress bar's "Step 2 of 5: Income". */
39
+ label: string;
40
+ /** Every field the step asks, in order, rows read through. */
41
+ fields: Field[];
42
+ /** The fields as rows, where any row holds more than one (at most three side by side, stacking on a narrow
43
+ screen); absent, one field to a row. Authored as an inner list: `[['first_name', 'last_name'], 'dob']`. */
44
+ rows?: Field[][];
45
+ /** The step's heading in the intake style (the room's h1); absent, its label. */
46
+ title?: string;
47
+ /** One sentence under the title. */
48
+ lead?: string;
49
+ /** The primary button's words on this step; absent, "Continue". */
50
+ next?: string;
51
+ /** The primary's words while every field of the step is empty (each optional): "Skip". */
52
+ skip?: string;
53
+ }
54
+ /** How a multi-step form is drawn, both under one progress bar: `stepper` (the step's name over its fields) or `intake`
55
+ (the step's title large, one question at a time, a sticky bar of actions and an editable review). */
56
+ export type FormStyle = 'stepper' | 'intake';
57
+ /** Comparisons in one condition, counted after `or` is multiplied out. */
58
+ export declare const MAX_FORM_PREDICATES = 16;
59
+ /** The longest condition text. */
60
+ export declare const MAX_FORM_CONDITION = 2000;
61
+ export declare const LOCAL_FIELD: RegExp;
62
+ export declare const RESERVED: Set<string>;
63
+ export declare function scalar(raw: unknown, where: string): FormScalar;
64
+ /** A condition's text, compiled through the query language's own parser. `columns`, when known, type its literals. */
65
+ export declare function compileCondition(raw: unknown, where: string, columns?: readonly ColumnMeta[], table?: string, paths?: boolean): CompiledCondition;
66
+ type Family = 'number' | 'boolean' | 'text' | 'date' | 'datetime' | 'instant';
67
+ export declare function family(column: ColumnMeta): Family | undefined;
68
+ interface Decimal {
69
+ coefficient: bigint;
70
+ scale: number;
71
+ }
72
+ type Normalized = {
73
+ kind: 'null';
74
+ } | {
75
+ kind: 'number';
76
+ value: Decimal;
77
+ } | {
78
+ kind: 'boolean';
79
+ value: boolean;
80
+ } | {
81
+ kind: 'text' | 'date' | 'datetime' | 'instant';
82
+ value: string;
83
+ };
84
+ export declare function normalize(column: ColumnMeta, raw: unknown): Normalized | undefined;
85
+ export declare function columnNamed(columns: readonly ColumnMeta[], name: string): ColumnMeta | undefined;
86
+ export declare function rowValue(row: Readonly<Record<string, unknown>>, name: string): unknown;
87
+ export declare function comparisonResult(p: Comparison, row: Readonly<Record<string, unknown>>, columns: readonly ColumnMeta[]): boolean | 'unknown';
88
+ export declare function conditionResult(condition: CompiledCondition, row: Readonly<Record<string, unknown>>, columns: readonly ColumnMeta[]): boolean | 'unknown';
89
+ /** Whether a record's values meet a condition: 'unknown' where a value cannot be compared, or the condition cannot be read against these columns. */
90
+ export declare function evaluateFormCondition(condition: FormCondition, row: Readonly<Record<string, unknown>>, columns: readonly ColumnMeta[], paths?: boolean): boolean | 'unknown';
91
+ /** The word a form default fills in for its column — the constants `today`, `now`, `me` — or undefined for a literal. */
92
+ export declare function formDefaultWord(column: ColumnMeta, value: unknown): 'today' | 'now' | 'me' | undefined;
93
+ /**
94
+ * A New form's starting values the schema already says: a vocabulary column's
95
+ * literal DEFAULT (`status … default 'booked'`) is the choice the form opens
96
+ * on, so the person sees what the database would write. A clock or a sequence
97
+ * stays the database's to fill. The form's own `defaults` win.
98
+ */
99
+ export declare function inferredFormDefaults(table: {
100
+ columns: readonly ColumnMeta[];
101
+ }): Record<string, string>;
102
+ /** A stored value as the evaluator reads it, by its column's kind: a number, a yes-or-no, a day, text; null for none. */
103
+ export declare function typedValue(table: TableMeta, column: string, value: unknown): ComputedValue;
104
+ export {};
@@ -0,0 +1,352 @@
1
+ /**
2
+ * How a form reads a record's own values, in the browser as someone types and on the server after: a condition in
3
+ * the query language compiled to comparisons and judged against a row, a scalar a declaration may hold, the words a
4
+ * default fills in (`today`, `now`, `me`), the starting values a schema's DEFAULTs already say, a stored value as an
5
+ * expression reads it, and a multi-step form's step. The engine's, because the kit's New form draws a table's form
6
+ * with them in both shells; the App framework's form declarations — their parsing, validation, child groups and
7
+ * rules — are formRules.ts and formLines.ts, which re-export what they always named.
8
+ */
9
+ import { columnKind, isFlagColumn } from './schema.js';
10
+ import { NO_ONE_HERE, parseQuery } from './query.js';
11
+ /** Comparisons in one condition, counted after `or` is multiplied out. */
12
+ export const MAX_FORM_PREDICATES = 16;
13
+ /** The longest condition text. */
14
+ export const MAX_FORM_CONDITION = 2000;
15
+ const MAX_FORM_TEXT = 4096;
16
+ // eslint-disable-next-line no-control-regex -- Declaration names must exclude ASCII control characters.
17
+ export const LOCAL_FIELD = /^[^\s.\x00-\x1f\x7f]{1,256}$/u;
18
+ export const RESERVED = new Set(['__proto__', 'prototype', 'constructor']);
19
+ function fail(where) {
20
+ // Never stringify rejected data: it may contain row values or executable hooks.
21
+ throw new Error(`${where}: invalid form declaration.`);
22
+ }
23
+ export function scalar(raw, where) {
24
+ if (raw === null)
25
+ return null;
26
+ if (typeof raw === 'boolean')
27
+ return raw;
28
+ if (typeof raw === 'string' && raw.length <= MAX_FORM_TEXT)
29
+ return raw;
30
+ if (typeof raw === 'number' && Number.isFinite(raw) && Math.abs(raw) <= Number.MAX_SAFE_INTEGER)
31
+ return raw;
32
+ return fail(where);
33
+ }
34
+ function frozen(value) {
35
+ return Object.freeze(value);
36
+ }
37
+ const QUERY_OPERATORS = { '=': 'eq', '!=': 'ne', '<': 'lt', '<=': 'lte', '>': 'gt', '>=': 'gte' };
38
+ /* The one table a condition is read against, for the parser: with the
39
+ record's columns it types each literal by its column ("02134" stays text
40
+ beside a zip code) and names a mistyped column; without, it judges the
41
+ words alone, which is what an App's parse can know before a catalog. */
42
+ function conditionSchema(name, columns) {
43
+ return {
44
+ label: '',
45
+ dialect: 'sqlite',
46
+ readAt: '',
47
+ foreignKeys: [],
48
+ tables: [{ name, schema: '', id: name, isView: false, columns: [...columns] }],
49
+ };
50
+ }
51
+ /* A validation reads its own columns and, through one reference, the record that reference names
52
+ (`order_id.status`): the rule a child keeps about its parent ("parts only while the order is on the bench"),
53
+ judged on the server with the parent read in the write's own transaction. One hop: a longer path is a rule
54
+ about a record two tables away, which a command reading it states more plainly. */
55
+ function readsThroughReference(column) {
56
+ const [via, name, ...more] = column.split('.');
57
+ return !more.length && name !== undefined && [via, name].every((part) => LOCAL_FIELD.test(part) && !RESERVED.has(part));
58
+ }
59
+ function comparison(condition, where, paths) {
60
+ if (!LOCAL_FIELD.test(condition.column) || RESERVED.has(condition.column)) {
61
+ if (!paths || !readsThroughReference(condition.column))
62
+ throw new Error(paths
63
+ ? `${where}: "${condition.column}" goes past one reference; a validation reads the record's own columns and, through one reference, that record's (order_id.status).`
64
+ : `${where}: "${condition.column}" is a path; a condition here reads the record's own columns.`);
65
+ }
66
+ const values = (v) => (Array.isArray(v) ? v : [v]).map((item) => scalar(item, where));
67
+ if (condition.other !== undefined) {
68
+ const op = QUERY_OPERATORS[condition.op];
69
+ if (!op || !LOCAL_FIELD.test(condition.other) || RESERVED.has(condition.other))
70
+ fail(where);
71
+ return { field: condition.column, operator: op, values: [], other: condition.other };
72
+ }
73
+ if (condition.op === 'isNull')
74
+ return { field: condition.column, operator: 'eq', values: [null] };
75
+ if (condition.op === 'isNotNull')
76
+ return { field: condition.column, operator: 'ne', values: [null] };
77
+ if (condition.op === 'in')
78
+ return { field: condition.column, operator: 'eq', values: values(condition.value) };
79
+ const op = QUERY_OPERATORS[condition.op];
80
+ if (!op) {
81
+ throw new Error(`${where}: "${condition.op}" matches text, which a condition here cannot; compare with =, !=, <, <=, >, >=, in or is empty.`);
82
+ }
83
+ return { field: condition.column, operator: op, values: values(condition.value) };
84
+ }
85
+ /** A condition's text, compiled through the query language's own parser. `columns`, when known, type its literals. */
86
+ export function compileCondition(raw, where, columns, table = 'record', paths = false) {
87
+ if (typeof raw !== 'string' || !raw.trim() || raw.length > MAX_FORM_CONDITION) {
88
+ throw new Error(`${where}: a condition is query-language text, like "status = shipped".`);
89
+ }
90
+ // Against the record's columns a bare word beside a number, date or flag may name another column.
91
+ const parsed = parseQuery(`${table} ${raw}`, columns ? { schema: conditionSchema(table, columns), columnValues: true } : {});
92
+ /* A form's condition and a validation are judged against the record's own values, in the browser as someone
93
+ types and on the server after: no session is either place, so `me` is nobody's here (appMe.ts checkMe). */
94
+ if (parsed.errors[0]?.message === NO_ONE_HERE)
95
+ throw new Error(`${where} compares with me. A form's conditions and a validation read the record's own values, where the session is not; ` +
96
+ 'show the field always, or narrow who may write it with roles.');
97
+ if (parsed.errors.length)
98
+ throw new Error(`${where}: ${parsed.errors[0].message}`);
99
+ const query = parsed.query;
100
+ if (query.orderBy.length || query.columns.length || query.limit !== undefined) {
101
+ throw new Error(`${where}: a condition is only a condition — no sort, show or limit.`);
102
+ }
103
+ if (!query.filter.groups.length)
104
+ throw new Error(`${where}: a condition is query-language text, like "status = shipped".`);
105
+ const groups = query.filter.groups.map((group) => frozen(group.map((c) => frozen(comparison(c, where, paths)))));
106
+ if (groups.flat().length > MAX_FORM_PREDICATES)
107
+ throw new Error(`${where}: a condition compares at most ${MAX_FORM_PREDICATES} times.`);
108
+ return frozen(groups);
109
+ }
110
+ export function family(column) {
111
+ const type = column.type.trim().toLowerCase();
112
+ if (/^(?:bool|boolean)$/.test(type))
113
+ return 'boolean';
114
+ if (/^(?:(?:tiny|small|medium|big)?int(?:eger)?|int[248]|(?:small|big)?serial|numeric|decimal|real|double(?: precision)?|float[48]?)(?:\s*\(\s*\d+(?:\s*,\s*\d+)?\s*\))?(?: unsigned)?$/.test(type))
115
+ return 'number';
116
+ if (/^(?:date)$/.test(type))
117
+ return 'date';
118
+ if (/^(?:timestamptz(?:\(\d+\))?|timestamp(?:\(\d+\))? with time zone)$/.test(type))
119
+ return 'instant';
120
+ if (/^(?:datetime|timestamp)(?:\(\d+\))?(?: without time zone)?$/.test(type))
121
+ return 'datetime';
122
+ if (column.allowed ||
123
+ /^(?:text|(?:tiny|medium|long)text|n?varchar|(?:character varying)|n?char|character|uuid|clob)(?:\(\d+\))?$/.test(type) ||
124
+ type.startsWith('enum('))
125
+ return 'text';
126
+ return undefined;
127
+ }
128
+ function decimal(raw) {
129
+ if (typeof raw === 'bigint')
130
+ raw = raw.toString();
131
+ if (typeof raw === 'number') {
132
+ if (!Number.isFinite(raw) || Math.abs(raw) > Number.MAX_SAFE_INTEGER)
133
+ return undefined;
134
+ raw = String(raw);
135
+ }
136
+ if (typeof raw !== 'string' || raw.length > MAX_FORM_TEXT)
137
+ return undefined;
138
+ const match = /^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))(?:[eE]([+-]?\d{1,4}))?$/.exec(raw.trim());
139
+ if (!match)
140
+ return undefined;
141
+ const exponent = Number(match[5] ?? 0);
142
+ if (Math.abs(exponent) > MAX_FORM_TEXT)
143
+ return undefined;
144
+ const fraction = match[3] ?? match[4] ?? '';
145
+ let digits = ((match[2] ?? '0') + fraction).replace(/^0+/, '') || '0';
146
+ let scale = fraction.length - exponent;
147
+ while (digits.endsWith('0') && digits !== '0') {
148
+ digits = digits.slice(0, -1);
149
+ scale--;
150
+ }
151
+ return { coefficient: BigInt((match[1] === '-' ? '-' : '') + digits), scale: digits === '0' ? 0 : scale };
152
+ }
153
+ function validDate(value) {
154
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
155
+ if (!match)
156
+ return false;
157
+ const [, y, m, d] = match;
158
+ const year = Number(y), month = Number(m), day = Number(d);
159
+ const days = [31, year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
160
+ return year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1];
161
+ }
162
+ function dateValue(raw, kind) {
163
+ // Date instances are accepted only for instants; interpreting local dates using
164
+ // the machine's timezone would make validation depend on deployment settings.
165
+ if (raw instanceof Date && kind === 'instant') {
166
+ const time = Date.prototype.getTime.call(raw);
167
+ if (!Number.isFinite(time))
168
+ return undefined;
169
+ raw = new Date(time).toISOString();
170
+ }
171
+ if (typeof raw !== 'string' || raw.length > 64)
172
+ return undefined;
173
+ if (kind === 'date')
174
+ return validDate(raw) ? raw : undefined;
175
+ const match = /^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}(?::?\d{2})?)?$/.exec(raw);
176
+ if (!match || !validDate(match[1]) || Number(match[2]) > 23 || Number(match[3]) > 59 || Number(match[4] ?? 0) > 59)
177
+ return undefined;
178
+ const [, date, hour, minute, seconds = '00', fraction = '', zone] = match;
179
+ if (kind === 'datetime')
180
+ return zone ? undefined : `${date}T${hour}:${minute}:${seconds}.${fraction.padEnd(9, '0')}`;
181
+ if (!zone)
182
+ return undefined;
183
+ let offset = 0;
184
+ if (zone !== 'Z') {
185
+ const parts = /^([+-])(\d{2})(?::?(\d{2}))?$/.exec(zone);
186
+ const hours = Number(parts[2]), minutes = Number(parts[3] ?? 0);
187
+ if (hours > 14 || minutes > 59 || (hours === 14 && minutes !== 0))
188
+ return undefined;
189
+ offset = (hours * 60 + minutes) * (parts[1] === '-' ? -1 : 1);
190
+ }
191
+ const time = Date.parse(`${date}T${hour}:${minute}:${seconds}Z`) - offset * 60_000;
192
+ // Store epoch nanoseconds as decimal text; comparison converts only this exact
193
+ // internally produced integer, never the original DB identifier or timestamp.
194
+ return String(BigInt(time) * 1000000n + BigInt(fraction.padEnd(9, '0')));
195
+ }
196
+ export function normalize(column, raw) {
197
+ const kind = family(column);
198
+ if (!kind)
199
+ return undefined;
200
+ if (raw === null)
201
+ return { kind: 'null' };
202
+ if (kind === 'number') {
203
+ const value = decimal(raw);
204
+ if (!value || (/int|serial/i.test(column.type) && value.scale > 0))
205
+ return undefined;
206
+ return { kind, value };
207
+ }
208
+ if (kind === 'boolean') {
209
+ if (raw === true || raw === 1 || raw === 1n || (typeof raw === 'string' && /^(true|yes|1|t)$/i.test(raw.trim())))
210
+ return { kind, value: true };
211
+ if (raw === false || raw === 0 || raw === 0n || (typeof raw === 'string' && /^(false|no|0|f)$/i.test(raw.trim())))
212
+ return { kind, value: false };
213
+ return undefined;
214
+ }
215
+ if (kind === 'text')
216
+ return typeof raw === 'string' && raw.length <= MAX_FORM_TEXT ? { kind, value: raw } : undefined;
217
+ const value = dateValue(raw, kind);
218
+ return value === undefined ? undefined : { kind, value };
219
+ }
220
+ function compare(left, op, right) {
221
+ if (!left || !right)
222
+ return 'unknown';
223
+ if (left.kind === 'null' || right.kind === 'null') {
224
+ if (op !== 'eq' && op !== 'ne')
225
+ return 'unknown';
226
+ const equal = left.kind === right.kind;
227
+ return op === 'eq' ? equal : !equal;
228
+ }
229
+ if (left.kind !== right.kind)
230
+ return 'unknown';
231
+ let order;
232
+ if (left.kind === 'number' && right.kind === 'number') {
233
+ const scale = Math.max(left.value.scale, right.value.scale);
234
+ const a = left.value.coefficient * 10n ** BigInt(scale - left.value.scale);
235
+ const b = right.value.coefficient * 10n ** BigInt(scale - right.value.scale);
236
+ order = a < b ? -1 : a > b ? 1 : 0;
237
+ }
238
+ else if (left.kind === 'instant' && right.kind === 'instant') {
239
+ const a = BigInt(left.value), b = BigInt(right.value);
240
+ order = a < b ? -1 : a > b ? 1 : 0;
241
+ }
242
+ else if (left.kind === 'boolean' && right.kind === 'boolean') {
243
+ if (op !== 'eq' && op !== 'ne')
244
+ return 'unknown';
245
+ order = left.value === right.value ? 0 : 1;
246
+ }
247
+ else if (typeof left.value === 'string' && typeof right.value === 'string') {
248
+ // Text ordering is deliberately unavailable: DB collations are not portable.
249
+ if (left.kind === 'text' && op !== 'eq' && op !== 'ne')
250
+ return 'unknown';
251
+ order = left.value < right.value ? -1 : left.value > right.value ? 1 : 0;
252
+ }
253
+ else
254
+ return 'unknown';
255
+ switch (op) {
256
+ case 'eq':
257
+ return order === 0;
258
+ case 'ne':
259
+ return order !== 0;
260
+ case 'lt':
261
+ return order < 0;
262
+ case 'lte':
263
+ return order <= 0;
264
+ case 'gt':
265
+ return order > 0;
266
+ case 'gte':
267
+ return order >= 0;
268
+ }
269
+ }
270
+ export function columnNamed(columns, name) {
271
+ const matches = columns.filter((c) => c.name === name);
272
+ return matches.length === 1 ? matches[0] : undefined;
273
+ }
274
+ export function rowValue(row, name) {
275
+ const descriptor = Object.getOwnPropertyDescriptor(row, name);
276
+ return descriptor && Object.hasOwn(descriptor, 'value') ? descriptor.value : undefined;
277
+ }
278
+ export function comparisonResult(p, row, columns) {
279
+ const column = columnNamed(columns, p.field);
280
+ if (!column)
281
+ return 'unknown';
282
+ if (p.other !== undefined) {
283
+ const other = columnNamed(columns, p.other);
284
+ return !other || family(column) !== family(other)
285
+ ? 'unknown'
286
+ : compare(normalize(column, rowValue(row, p.field)), p.operator, normalize(other, rowValue(row, p.other)));
287
+ }
288
+ const results = p.values.map((value) => compare(normalize(column, rowValue(row, p.field)), p.operator, normalize(column, value)));
289
+ return results.includes('unknown') ? 'unknown' : results.some((r) => r === true);
290
+ }
291
+ export function conditionResult(condition, row, columns) {
292
+ const results = condition.map((group) => group.map((p) => comparisonResult(p, row, columns)));
293
+ // Unknown dependencies never disappear behind a short-circuiting branch.
294
+ if (results.flat().includes('unknown'))
295
+ return 'unknown';
296
+ return results.some((group) => group.every((r) => r === true));
297
+ }
298
+ /** Whether a record's values meet a condition: 'unknown' where a value cannot be compared, or the condition cannot be read against these columns. */
299
+ export function evaluateFormCondition(condition, row, columns, paths = false) {
300
+ let compiled;
301
+ try {
302
+ compiled = compileCondition(condition, 'Condition', columns, 'record', paths);
303
+ }
304
+ catch {
305
+ return 'unknown';
306
+ }
307
+ return conditionResult(compiled, row, columns);
308
+ }
309
+ /** The word a form default fills in for its column — the constants `today`, `now`, `me` — or undefined for a literal. */
310
+ export function formDefaultWord(column, value) {
311
+ // columnKind, not family: a SQLite TEXT declared a date (`TEXT as date`) is a date here.
312
+ if (value === 'today' || value === 'now')
313
+ return columnKind(column.type) === 'date' ? value : undefined;
314
+ return value === 'me' && (column.references || columnKind(column.type) === 'text') ? 'me' : undefined;
315
+ }
316
+ /**
317
+ * A New form's starting values the schema already says: a vocabulary column's
318
+ * literal DEFAULT (`status … default 'booked'`) is the choice the form opens
319
+ * on, so the person sees what the database would write. A clock or a sequence
320
+ * stays the database's to fill. The form's own `defaults` win.
321
+ */
322
+ export function inferredFormDefaults(table) {
323
+ const out = {};
324
+ for (const column of table.columns) {
325
+ if (!column.allowed?.length || column.flag || column.default === undefined)
326
+ continue;
327
+ const literal = /^'((?:[^']|'')*)'(?:::[\w\s."]+)?$/.exec(column.default.trim())?.[1]?.replace(/''/g, "'") ?? column.default.trim();
328
+ if (column.allowed.includes(literal))
329
+ out[column.name] = literal;
330
+ }
331
+ return out;
332
+ }
333
+ /** A stored value as the evaluator reads it, by its column's kind: a number, a yes-or-no, a day, text; null for none. */
334
+ export function typedValue(table, column, value) {
335
+ if (value === null || value === undefined || value === '')
336
+ return null;
337
+ const meta = table.columns.find((c) => c.name === column);
338
+ if (!meta)
339
+ return null;
340
+ if (isFlagColumn(meta))
341
+ return value === true || value === 1 || /^(1|true|t|yes|y)$/i.test(String(value));
342
+ const kind = columnKind(meta.type);
343
+ if (kind === 'number') {
344
+ const n = Number(value);
345
+ return Number.isFinite(n) ? n : null;
346
+ }
347
+ if (kind === 'date') {
348
+ const text = String(value);
349
+ return /^\d{4}-\d{2}-\d{2}$/.test(text) ? { day: text } : Number.isNaN(Date.parse(text)) ? null : { instant: new Date(text) };
350
+ }
351
+ return String(value);
352
+ }
@@ -0,0 +1,45 @@
1
+ export interface FunnelStage {
2
+ /** The stage as a reader says it, said from the catalogs by the time it is parsed. */
3
+ label: string;
4
+ /** Conditions only (segments are words in it); absent, every row the section holds. */
5
+ query?: string;
6
+ /** Counted against the chain before it, and not required by the stages after it. */
7
+ optional?: boolean;
8
+ }
9
+ export declare const FUNNEL_MIN_STAGES = 2;
10
+ export declare const FUNNEL_MAX_STAGES = 8;
11
+ /** The answer's column for stage `index` (0-based): the alias its measure is asked under. */
12
+ export declare const stageColumn: (index: number) => string;
13
+ /**
14
+ * The conditions of each stage's reached rows: the required stages before it, then its own. Empty text for a stage
15
+ * that asks nothing of the rows, which are all of them.
16
+ */
17
+ export declare function funnelChains(stages: readonly Pick<FunnelStage, 'query' | 'optional'>[]): string[];
18
+ /**
19
+ * The stage each stage is a share of: the last required stage before it. The first stage has none. A funnel whose
20
+ * first stage is optional is refused where it is parsed (appViews.ts), so every later stage has one.
21
+ */
22
+ export declare function funnelBasis(stages: readonly Pick<FunnelStage, 'optional'>[]): Array<number | null>;
23
+ /** The line a funnel asks: its table, the section's conditions, then one count per stage. */
24
+ export declare function funnelText(section: {
25
+ table?: string;
26
+ query?: string;
27
+ stages?: readonly FunnelStage[];
28
+ }): string | null;
29
+ /**
30
+ * One condition's opposite, or undefined where the language cannot say it exactly. The opposite is exact for a row
31
+ * with nothing in the column too: `status = approved` is not `status != approved` (a SQL comparison skips an empty
32
+ * value), it is `status != approved or status is empty`. Unsaid on purpose: a phrase of dates, a nested `or`, `has`,
33
+ * anything the language has no word for, since the drill must open the rows the figure counted and no others.
34
+ */
35
+ export declare function negateCondition(condition: string): string | undefined;
36
+ /**
37
+ * The rows that do not hold a query, or undefined when any of its conditions cannot be turned over exactly. A query
38
+ * is its conditions all at once, so its opposite is any one of their opposites.
39
+ */
40
+ export declare function negateQuery(query: string, segments?: Readonly<Record<string, string>>): string | undefined;
41
+ /**
42
+ * The rows a stage lost: those that reached the stage it is a share of and do not hold its own conditions. Only a
43
+ * required stage drops rows (an optional one is a side road), and only where its conditions can be turned over.
44
+ */
45
+ export declare function droppedQuery(stages: readonly FunnelStage[], index: number, segments?: Readonly<Record<string, string>>): string | undefined;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * A funnel over rows (`funnel()`, a dashboard section): how many of the rows a section holds reach each of its stages,
3
+ * in order. The stages are conditions on the one table; a row reaches stage k when it holds the section's own query and
4
+ * every required stage up to k. An optional stage is counted against the chain before it, and the stages after it do
5
+ * not need it — so one key covers a strict road and an any-order checklist (every stage optional).
6
+ *
7
+ * Every stage is counted in the one statement (`count when [...]`, breakdown.ts): one snapshot, so a later stage can
8
+ * never exceed an earlier one under concurrent writes, which separate counts could.
9
+ *
10
+ * Pure text in, text out: the client draws from it, the server asks from it for a first page (firstPaintRooms.ts), and
11
+ * `mistri check` judges with it.
12
+ */
13
+ import { andQuery, topLevelConditions } from './query.js';
14
+ export const FUNNEL_MIN_STAGES = 2;
15
+ export const FUNNEL_MAX_STAGES = 8;
16
+ /** The answer's column for stage `index` (0-based): the alias its measure is asked under. */
17
+ export const stageColumn = (index) => `stage_${index + 1}`;
18
+ /**
19
+ * The conditions of each stage's reached rows: the required stages before it, then its own. Empty text for a stage
20
+ * that asks nothing of the rows, which are all of them.
21
+ */
22
+ export function funnelChains(stages) {
23
+ const required = [];
24
+ return stages.map((stage) => {
25
+ const chain = andQuery(...required, stage.query);
26
+ if (!stage.optional && stage.query?.trim())
27
+ required.push(stage.query);
28
+ return chain;
29
+ });
30
+ }
31
+ /**
32
+ * The stage each stage is a share of: the last required stage before it. The first stage has none. A funnel whose
33
+ * first stage is optional is refused where it is parsed (appViews.ts), so every later stage has one.
34
+ */
35
+ export function funnelBasis(stages) {
36
+ let last = null;
37
+ return stages.map((stage, index) => {
38
+ const basis = last;
39
+ if (!stage.optional)
40
+ last = index;
41
+ return basis;
42
+ });
43
+ }
44
+ /** The line a funnel asks: its table, the section's conditions, then one count per stage. */
45
+ export function funnelText(section) {
46
+ if (!section.table || !section.stages?.length)
47
+ return null;
48
+ const measures = funnelChains(section.stages).map((chain, index) => chain ? `count when [${chain}] as ${stageColumn(index)}` : `count as ${stageColumn(index)}`);
49
+ return [section.table, section.query, measures.join(', ')].filter(Boolean).join(' ');
50
+ }
51
+ const COMPARE_OPPOSITE = { '=': '!=', '!=': '=', '>': '<=', '>=': '<', '<': '>=', '<=': '>' };
52
+ /* A value that is a phrase of the date grammar or a clock word, not a plain value: its opposite is not what `!=` says. */
53
+ const NOT_PLAIN_VALUE = /^(today|yesterday|tomorrow|now|this|next|last|previous)$/i;
54
+ const VALUE = String.raw `("[^"]*"|'[^']*'|[^\s"',()]+)`;
55
+ /**
56
+ * One condition's opposite, or undefined where the language cannot say it exactly. The opposite is exact for a row
57
+ * with nothing in the column too: `status = approved` is not `status != approved` (a SQL comparison skips an empty
58
+ * value), it is `status != approved or status is empty`. Unsaid on purpose: a phrase of dates, a nested `or`, `has`,
59
+ * anything the language has no word for, since the drill must open the rows the figure counted and no others.
60
+ */
61
+ export function negateCondition(condition) {
62
+ const text = condition.replace(/\s+/g, ' ').trim();
63
+ if (!text || text.startsWith('('))
64
+ return undefined;
65
+ const rows = /^(any|no) (.+)$/i.exec(text);
66
+ if (rows)
67
+ return `${rows[1].toLowerCase() === 'any' ? 'no' : 'any'} ${rows[2]}`;
68
+ const empty = /^([\w.$+]+) is (not )?empty$/i.exec(text);
69
+ if (empty)
70
+ return `${empty[1]} is ${empty[2] ? '' : 'not '}empty`;
71
+ const compare = new RegExp(String.raw `^([\w.$+]+) (=|!=|>=|<=|>|<) ${VALUE}$`).exec(text);
72
+ if (compare && !NOT_PLAIN_VALUE.test(compare[3]))
73
+ return `${compare[1]} ${COMPARE_OPPOSITE[compare[2]]} ${compare[3]} or ${compare[1]} is empty`;
74
+ const among = /^([\w.$+]+) in \((.+)\)$/i.exec(text);
75
+ if (among) {
76
+ const values = among[2].match(new RegExp(String.raw `${VALUE}(?=\s*(,|$))`, 'g'));
77
+ const whole = new RegExp(String.raw `^\s*${VALUE}(\s*,\s*${VALUE})*\s*$`);
78
+ if (!values?.length || !whole.test(among[2]) || values.some((value) => NOT_PLAIN_VALUE.test(value)))
79
+ return undefined;
80
+ return `${values.map((value) => `${among[1]} != ${value}`).join(' and ')} or ${among[1]} is empty`;
81
+ }
82
+ return undefined;
83
+ }
84
+ /**
85
+ * The rows that do not hold a query, or undefined when any of its conditions cannot be turned over exactly. A query
86
+ * is its conditions all at once, so its opposite is any one of their opposites.
87
+ */
88
+ export function negateQuery(query, segments) {
89
+ const held = topLevelConditions(query, segments);
90
+ if (!held.length)
91
+ return undefined;
92
+ const opposites = held.map(negateCondition);
93
+ return opposites.every((text) => text !== undefined) ? opposites.join(' or ') : undefined;
94
+ }
95
+ /**
96
+ * The rows a stage lost: those that reached the stage it is a share of and do not hold its own conditions. Only a
97
+ * required stage drops rows (an optional one is a side road), and only where its conditions can be turned over.
98
+ */
99
+ export function droppedQuery(stages, index, segments) {
100
+ const stage = stages[index];
101
+ if (!stage || stage.optional || index === 0 || !stage.query?.trim())
102
+ return undefined;
103
+ const opposite = negateQuery(stage.query, segments);
104
+ if (!opposite)
105
+ return undefined;
106
+ const before = stages.slice(0, index).flatMap((earlier) => (!earlier.optional && earlier.query?.trim() ? [earlier.query] : []));
107
+ return andQuery(...before, opposite);
108
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The documented reads of one resource of an HTTP connection, as the
3
+ * explorer's API tab offers them.
4
+ *
5
+ * Shared so the form the client draws and the request the server builds come
6
+ * from one shape: whatever the tab shows a box for is exactly what the server
7
+ * will send, and nothing the description does not declare can reach either.
8
+ */
9
+ /** What a list parameter does, so the tab can draw the right box for it. */
10
+ type HttpParamKind = 'filter' | 'search' | 'sort' | 'offset' | 'limit' | 'page' | 'size' | 'cursor';
11
+ export interface HttpParam {
12
+ /** The query parameter, as the API spells it. */
13
+ name: string;
14
+ kind: HttpParamKind;
15
+ /** A filter's column. */
16
+ column?: string;
17
+ /** A filter that takes several values (its operators include `in`). */
18
+ many?: boolean;
19
+ /** A sort's documented values. */
20
+ values?: string[];
21
+ }
22
+ export interface HttpOperations {
23
+ resource: string;
24
+ /** The list GET: its path and the parameters its description declares. `next` points at the cursor a page names. */
25
+ list: {
26
+ path: string;
27
+ params: HttpParam[];
28
+ next?: string;
29
+ };
30
+ /** The item GET: its path template and the key it names. */
31
+ item: {
32
+ path: string;
33
+ key: string;
34
+ };
35
+ }
36
+ /** One read, as it went: the request line and the answer, never a header. */
37
+ export interface HttpOperationReply {
38
+ request: {
39
+ method: 'GET';
40
+ path: string;
41
+ query: string;
42
+ };
43
+ status: number;
44
+ /** The body, whole, when the API answered 2xx; absent otherwise, because egress never reads an error's body. */
45
+ json?: unknown;
46
+ ms: number;
47
+ }
48
+ export {};