@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,99 @@
1
+ /**
2
+ * The record page's anatomy, chosen from the catalog: the page an App draws
3
+ * for a resource it gave none, and the page the scaffold writes.
4
+ *
5
+ * The good record pages in the samples (Depot's order, Forecourt's vehicle,
6
+ * Commons' thread) share one skeleton, and a page built any other way read
7
+ * as a database dump: a header with the record's status and a line of facts
8
+ * under its name, a summary of its figures, its children as tabs, and beside
9
+ * them a rail of the rest of its properties over its history. This says, for
10
+ * one table, which columns go where — name-like, status, money, date and
11
+ * count columns, and the rollups the catalog serves — so the default page and
12
+ * the scaffold's are one rule.
13
+ *
14
+ * Pure: the caller says what only it knows (which columns are money in the
15
+ * App's words, whether the resource keeps a history, what a list is called).
16
+ */
17
+ import { type ColumnMeta, type DatabaseSchema, type ForeignKey, type TableMeta } from './schema.js';
18
+ import { type PageDef, type PageSection } from './pageModel.js';
19
+ /** What the caller knows that the catalog does not. */
20
+ export interface AnatomyHints {
21
+ /** Whether a number column is money, where the caller knows (a display rule); undefined leaves it to the name. */
22
+ money?: (table: TableMeta, column: ColumnMeta) => boolean | undefined;
23
+ /** The column naming a table's rows, where the App says (recordLabel); the catalog's guess otherwise. */
24
+ label?: (table: TableMeta) => string | undefined;
25
+ /** Whether a column is the record's status where the caller knows (the App dresses it in tones); undefined leaves it
26
+ to the name — status, state, stage, phase. */
27
+ status?: (table: TableMeta, column: ColumnMeta) => boolean | undefined;
28
+ /** Whether the record keeps a history, so the aside may end with it. */
29
+ history?: boolean;
30
+ /** Whether a table that points here is one the App reads, so its list may stand on the page; absent is every one. */
31
+ includes?: (child: TableMeta) => boolean;
32
+ /** A related list's title, where the caller has the words; absent is the table's name as the page says it. */
33
+ title?: (fk: ForeignKey, child: TableMeta, ambiguous: boolean) => string | undefined;
34
+ /** What one record of a table is called, mid-sentence ("work order"), where the caller has the word (its `noun`). */
35
+ noun?: (table: TableMeta) => string | undefined;
36
+ }
37
+ interface RelatedPick {
38
+ title?: string;
39
+ from: string;
40
+ whose: string;
41
+ show: string[];
42
+ sort?: string;
43
+ }
44
+ /** The one child row that matters now — the next visit, the current lease — as a card. */
45
+ interface CurrentPick {
46
+ title: string;
47
+ from: string;
48
+ whose: string;
49
+ show: string[];
50
+ query?: string;
51
+ sort?: string;
52
+ }
53
+ /** Which columns go where on one record's page. */
54
+ interface Anatomy {
55
+ /** The header's status chip: a vocabulary column named like a state. */
56
+ status?: string;
57
+ /** The header's facts line: the parent, a figure, a date — at most four. */
58
+ facts: string[];
59
+ /** A summary of the record's figures: its rollups, then money the facts did not say — at most four. */
60
+ summary: string[];
61
+ /** The children, drawn as tabs: at most four lists of at most four columns. */
62
+ related: RelatedPick[];
63
+ /** The record it belongs to, as a card in the aside: the reference and two of the parent's own fields. */
64
+ parent?: {
65
+ title: string;
66
+ paths: string[];
67
+ };
68
+ /** The child that is current, as a card in the aside. */
69
+ current?: CurrentPick;
70
+ /** The rest of the record's own fields, as a property rail in the aside, titled by the record's noun. */
71
+ properties: string[];
72
+ /** The record's noun as a heading: what the rail of its own fields is called ("Patient"), never "Details". */
73
+ noun: string;
74
+ history: boolean;
75
+ }
76
+ /** A column named for words a reader reads rather than scans (a description, a body, notes): the rail puts it last,
77
+ and a page of little else is an article (pageLayouts.ts, chooseLayout). */
78
+ export declare const isLongText: (column: string) => boolean;
79
+ /** A rail's worth of fields. */
80
+ export declare const MAX_PROPERTIES = 12;
81
+ /** Which of a table's columns go where on its record's page, or nothing where a record has no key to open it by. */
82
+ export declare function recordAnatomy(schema: DatabaseSchema, baseId: string, hints?: AnatomyHints): Anatomy | null;
83
+ /** The anatomy as a page: header, summary, the lists as tabs, and the aside's parent, current child and rail over the history. */
84
+ export declare function anatomySections(anatomy: Anatomy): PageSection[];
85
+ /** The page an App draws for a resource it declared none for (appProjection.ts, /api/pages/suggested). */
86
+ export declare function anatomyPage(schema: DatabaseSchema, baseId: string, hints?: AnatomyHints): PageDef | null;
87
+ /**
88
+ * An App's record page that declares no aside gets the generated page's: the
89
+ * record's remaining fields as a property rail, titled by its noun ("Bike").
90
+ * Five pages of one App wrote `fields([...the rest], { title: 'Bike', region:
91
+ * 'aside' })` by hand; the rule is the anatomy's, so the two cannot drift.
92
+ * Remaining is judged against the reader's own catalog (so a column they cannot
93
+ * read is not offered) and against what the page already says: any fields
94
+ * section's path, a header's status, a card's reference. A fields section with
95
+ * no paths is the whole record, so nothing remains. An empty remainder draws
96
+ * no aside.
97
+ */
98
+ export declare function withDefaultAside(schema: DatabaseSchema, page: PageDef): PageDef;
99
+ export {};
@@ -0,0 +1,370 @@
1
+ /**
2
+ * The record page's anatomy, chosen from the catalog: the page an App draws
3
+ * for a resource it gave none, and the page the scaffold writes.
4
+ *
5
+ * The good record pages in the samples (Depot's order, Forecourt's vehicle,
6
+ * Commons' thread) share one skeleton, and a page built any other way read
7
+ * as a database dump: a header with the record's status and a line of facts
8
+ * under its name, a summary of its figures, its children as tabs, and beside
9
+ * them a rail of the rest of its properties over its history. This says, for
10
+ * one table, which columns go where — name-like, status, money, date and
11
+ * count columns, and the rollups the catalog serves — so the default page and
12
+ * the scaffold's are one rule.
13
+ *
14
+ * Pure: the caller says what only it knows (which columns are money in the
15
+ * App's words, whether the resource keeps a history, what a list is called).
16
+ */
17
+ import { columnKind, findTable, labelColumn, primaryKey, referencesFrom, referencesTo, } from './schema.js';
18
+ import { pageHop } from './pagePaths.js';
19
+ import { humanName } from './model.js';
20
+ import { headingOf, recordNoun } from './appNoun.js';
21
+ import { DEFAULT_PAGE_LIST_LIMIT } from './pageModel.js';
22
+ const MONEY = /(^|_)(amount|total|subtotal|price|cost|revenue|budget|quota|fee|fees|salary|balance|value|pay|paid|wage|rent|charge|charges|billed|deposit|pipeline)$/i;
23
+ const STATE = /^(status|state|stage|phase)$|_(status|state|stage)$/i;
24
+ const COUNTED = /^(qty|quantity|units|seats|beds|baths|bedrooms|bathrooms|count|headcount|employees|capacity|size|sq_ft|sqft|area|mileage|minutes|hours)$|_(count|qty)$/i;
25
+ /* Dates a person reads a record by, most telling first; housekeeping stamps are the aside's. */
26
+ const DATE_PICK = [
27
+ /^(due|due_on|due_at|due_date|deadline)$/i,
28
+ /close/i,
29
+ /(ends?|expires?)_/i,
30
+ /(starts?|begins?)_/i,
31
+ /date/i,
32
+ /_on$/i,
33
+ /_at$/i,
34
+ ];
35
+ const HOUSEKEEPING = /^(created|updated|modified|deleted|sys_)/i;
36
+ const OPAQUE = /blob|bytea|binary|json|xml|tsvector|vector/i;
37
+ const SECRET = /(password|passwd|secret|token|hash|salt)/i;
38
+ const VERSION = /^(version|lock_version|row_version|rowversion|revision)$/i;
39
+ const LONG_TEXT = /(description|body|notes?|summary|content|details|comments?|bio|message|text|html|markdown)$/i;
40
+ /** A column named for words a reader reads rather than scans (a description, a body, notes): the rail puts it last,
41
+ and a page of little else is an article (pageLayouts.ts, chooseLayout). */
42
+ export const isLongText = (column) => LONG_TEXT.test(column);
43
+ const MAX_FACTS = 4;
44
+ const MAX_SUMMARY = 4;
45
+ const MAX_RELATED = 4;
46
+ const MAX_LIST_COLUMNS = 4;
47
+ /** A rail's worth of fields. */
48
+ export const MAX_PROPERTIES = 12;
49
+ /* A child state that is still in play: the one a parent's page wants beside it. */
50
+ const OPEN = /^(open|new|active|pending|scheduled|planned|upcoming|booked|confirmed|due|ready|in[ _-]?progress|working|in[ _-]?review|on[ _-]?hold|awaiting\b.*|requested|submitted|current|live)$/i;
51
+ /* Of those, the ones still ahead: their card is the next, soonest first. */
52
+ const AHEAD = /^(scheduled|planned|upcoming|booked|confirmed|due|requested)$/i;
53
+ const LONG_OR_KEY = (column) => LONG_TEXT.test(column.name) || column.primaryKey || Boolean(column.references);
54
+ const moneyBy = (hints) => (table, column) => hints.money?.(table, column) ?? MONEY.test(column.name);
55
+ /** A key the database handed out: one integer or uuid primary key, which no reader quotes. */
56
+ function surrogate(table, column) {
57
+ return (column.primaryKey &&
58
+ primaryKey(table).length === 1 &&
59
+ (/^(id|uuid|guid)$/i.test(column.name) || /int|serial|uuid/i.test(column.type ?? '')));
60
+ }
61
+ /** A column a person reads on a record: not a handed-out key, a version, a secret or bytes. */
62
+ function readable(table, column) {
63
+ return !surrogate(table, column) && !VERSION.test(column.name) && !SECRET.test(column.name) && !OPAQUE.test(column.type ?? '');
64
+ }
65
+ /** The status column: one the caller says carries meaning (its tones), else one named like a state. A
66
+ vocabulary alone is not a status: a region or a kind would stand beside the name saying nothing. */
67
+ function statusColumn(table, hints = {}) {
68
+ const texts = table.columns.filter((column) => columnKind(column.type ?? '') === 'text' || /enum/i.test(column.type ?? ''));
69
+ return (texts.find((column) => STATE.test(column.name) && hints.status?.(table, column) !== false) ??
70
+ texts.find((column) => hints.status?.(table, column) === true));
71
+ }
72
+ /** The date a record is read by: due, closing, ending, starting — the stamps last. */
73
+ function dateColumns(table, taken) {
74
+ const dated = table.columns.filter((column) => columnKind(column.type ?? '') === 'date' && !taken.has(column.name));
75
+ const ranked = [
76
+ ...DATE_PICK.flatMap((pick) => dated.filter((column) => pick.test(column.name) && !HOUSEKEEPING.test(column.name))),
77
+ ...dated.filter((column) => !HOUSEKEEPING.test(column.name)),
78
+ ...dated,
79
+ ];
80
+ return [...new Set(ranked)];
81
+ }
82
+ /** A related list's columns: the row's name, its state, then what it says, never the reference it is found by. */
83
+ function listColumns(child, fk, hints) {
84
+ const name = hints.label?.(child) ?? labelColumn(child);
85
+ const state = statusColumn(child, hints)?.name;
86
+ const skip = new Set(fk.from.columns);
87
+ const plain = child.columns.filter((column) => readable(child, column) &&
88
+ !skip.has(column.name) &&
89
+ !HOUSEKEEPING.test(column.name) &&
90
+ !(LONG_TEXT.test(column.name) && column.name !== name) &&
91
+ !(column.primaryKey && primaryKey(child).length === 1));
92
+ const money = moneyBy(hints);
93
+ const ordered = [
94
+ ...(name && plain.some((column) => column.name === name) ? [name] : []),
95
+ ...plain.filter((column) => columnKind(column.type ?? '') === 'number' && money(child, column)).map((column) => column.name),
96
+ ...dateColumns(child, skip)
97
+ .filter((column) => plain.includes(column))
98
+ .slice(0, 1)
99
+ .map((column) => column.name),
100
+ ...plain.map((column) => column.name),
101
+ ].filter((column) => column !== state);
102
+ /* State last: where the list is cut, the chip still stands at its end. */
103
+ const picked = [...new Set(ordered)].slice(0, state ? MAX_LIST_COLUMNS - 1 : MAX_LIST_COLUMNS);
104
+ return state ? [...picked, state] : picked;
105
+ }
106
+ /** The rail's fields in reading order: long text last, at most a rail's worth. */
107
+ function railOf(rest) {
108
+ return [...rest.filter((column) => !LONG_TEXT.test(column.name)), ...rest.filter((column) => LONG_TEXT.test(column.name))]
109
+ .map((column) => column.name)
110
+ .slice(0, MAX_PROPERTIES);
111
+ }
112
+ /** Which of a table's columns go where on its record's page, or nothing where a record has no key to open it by. */
113
+ export function recordAnatomy(schema, baseId, hints = {}) {
114
+ const base = findTable(schema, baseId);
115
+ if (!base || !primaryKey(base).length)
116
+ return null;
117
+ const money = moneyBy(hints);
118
+ const name = hints.label?.(base) ?? labelColumn(base);
119
+ const own = base.columns.filter((column) => readable(base, column) && column.name !== name);
120
+ const refs = referencesFrom(schema, base.id).filter((fk) => fk.from.columns.length === 1 && !fk.stitched);
121
+ const refColumns = refs.map((fk) => fk.from.columns[0]).filter((column) => own.some((c) => c.name === column));
122
+ const status = statusColumn(base, hints)?.name;
123
+ const taken = new Set(status ? [status] : []);
124
+ const take = (column) => {
125
+ if (column && !taken.has(column)) {
126
+ taken.add(column);
127
+ return [column];
128
+ }
129
+ return [];
130
+ };
131
+ const figures = own.filter((column) => columnKind(column.type ?? '') === 'number' && !column.primaryKey && !refColumns.includes(column.name));
132
+ const moneyColumns = figures.filter((column) => money(base, column)).map((column) => column.name);
133
+ const counted = figures.filter((column) => COUNTED.test(column.name)).map((column) => column.name);
134
+ /* The header says what the record belongs to, what it is worth and when. */
135
+ const facts = [
136
+ ...take(refColumns[0]),
137
+ ...take(moneyColumns[0]),
138
+ ...take(dateColumns(base, taken).map((column) => column.name)[0]),
139
+ ...take(counted[0]),
140
+ ...take(refColumns[1]),
141
+ ].slice(0, MAX_FACTS);
142
+ /* A record that belongs to nothing and holds no figure or date (a provider:
143
+ a specialty, a phone, an email) still opens on a line of what it is,
144
+ never on its title alone: its first short words. */
145
+ if (!facts.length) {
146
+ for (const column of own) {
147
+ if (facts.length >= 3)
148
+ break;
149
+ if (columnKind(column.type ?? '') !== 'text' || LONG_OR_KEY(column) || HOUSEKEEPING.test(column.name) || column.flag)
150
+ continue;
151
+ facts.push(...take(column.name));
152
+ }
153
+ }
154
+ /* The summary is the record's figures: what the catalog counts about it, then its money. */
155
+ const rollups = Object.keys(base.rollups ?? {});
156
+ const summary = [
157
+ ...rollups,
158
+ ...moneyColumns.filter((column) => !taken.has(column)),
159
+ ...counted.filter((column) => !taken.has(column)),
160
+ ].slice(0, MAX_SUMMARY);
161
+ for (const column of summary)
162
+ taken.add(column);
163
+ const incoming = referencesTo(schema, base.id).filter((fk) => !fk.stitched &&
164
+ pageHop(schema, fk) !== undefined &&
165
+ findTable(schema, fk.from.table) &&
166
+ (hints.includes?.(findTable(schema, fk.from.table)) ?? true));
167
+ const related = incoming.slice(0, MAX_RELATED).map((fk) => {
168
+ const child = findTable(schema, fk.from.table);
169
+ const ambiguous = incoming.filter((other) => other.from.table === fk.from.table).length > 1 || child.id === base.id;
170
+ const title = hints.title?.(fk, child, ambiguous) ?? (ambiguous ? `${child.name} via ${fk.from.columns.join(', ')}` : undefined);
171
+ const date = dateColumns(child, new Set(fk.from.columns))[0];
172
+ return {
173
+ ...(title ? { title } : {}),
174
+ from: child.id,
175
+ whose: pageHop(schema, fk),
176
+ show: listColumns(child, fk, hints),
177
+ ...(date ? { sort: `${date.name} desc` } : {}),
178
+ };
179
+ });
180
+ const noun = (table) => hints.noun?.(table) ?? recordNoun(undefined, table.name);
181
+ /* The parent, as a card of its name and two of its own fields: the first
182
+ reference, required ones first, whose record has two to say (a patient's
183
+ insurer is a name alone; their provider has a specialty and a phone). */
184
+ let parent;
185
+ const required = (column) => base.columns.find((c) => c.name === column)?.nullable === false;
186
+ for (const column of related.length ? [...refColumns].sort((a, b) => Number(required(b)) - Number(required(a))) : []) {
187
+ const up = refs.find((fk) => fk.from.columns[0] === column);
188
+ const upTable = findTable(schema, up.to.table);
189
+ if (!upTable)
190
+ continue;
191
+ const upName = hints.label?.(upTable) ?? labelColumn(upTable);
192
+ const upState = statusColumn(upTable, hints);
193
+ const glance = [
194
+ ...(upState ? [upState] : []),
195
+ ...upTable.columns.filter((c) => c !== upState && readable(upTable, c) && c.name !== upName && !LONG_OR_KEY(c) && !HOUSEKEEPING.test(c.name) && !c.flag),
196
+ ].slice(0, 2);
197
+ if (glance.length < 2)
198
+ continue;
199
+ parent = {
200
+ title: headingOf(humanName(column.replace(/_id$/i, '')) || noun(upTable)),
201
+ paths: [column, ...glance.map((c) => `${column}.${c.name}`)],
202
+ };
203
+ // Said on its card, the reference is not said again in the rail.
204
+ taken.add(column);
205
+ break;
206
+ }
207
+ /* The child that is current: one whose state is still in play — the next
208
+ visit first, one booked ahead, then the open claim — else the latest by
209
+ its date. */
210
+ let current;
211
+ const ahead = (pick) => (statusColumn(findTable(schema, pick.from), hints)?.allowed ?? []).some((value) => AHEAD.test(value));
212
+ for (const pick of [...related.filter(ahead), ...related.filter((pick) => !ahead(pick))]) {
213
+ const child = findTable(schema, pick.from);
214
+ const state = statusColumn(child, hints);
215
+ const open = (state?.allowed ?? []).filter((value) => OPEN.test(value));
216
+ if (!state || !open.length || open.length === state.allowed.length)
217
+ continue;
218
+ const next = open.every((value) => AHEAD.test(value));
219
+ const date = dateColumns(child, new Set(pick.whose.split('.').slice(0, 1)))[0];
220
+ const said = (value) => (/^\w+$/.test(value) ? value : `"${value}"`);
221
+ current = {
222
+ title: `${next ? 'Next' : 'Current'} ${noun(child)}`,
223
+ from: pick.from,
224
+ whose: pick.whose,
225
+ show: pick.show.filter((column) => column !== state.name && column !== (hints.label?.(child) ?? labelColumn(child))).slice(0, 3),
226
+ query: open.length === 1 ? `${state.name} = ${said(open[0])}` : `${state.name} in (${open.map(said).join(', ')})`,
227
+ ...(date ? { sort: `${date.name} ${next ? 'asc' : 'desc'}` } : {}),
228
+ };
229
+ break;
230
+ }
231
+ if (!current) {
232
+ const dated = related.find((pick) => pick.sort && !HOUSEKEEPING.test(pick.sort));
233
+ if (dated) {
234
+ const child = findTable(schema, dated.from);
235
+ current = {
236
+ title: `Latest ${noun(child)}`,
237
+ from: dated.from,
238
+ whose: dated.whose,
239
+ show: dated.show.filter((column) => column !== (hints.label?.(child) ?? labelColumn(child))).slice(0, 3),
240
+ sort: dated.sort,
241
+ };
242
+ }
243
+ }
244
+ /* Everything else the record says, long text last; the name is the head's. */
245
+ const properties = railOf(own.filter((column) => !taken.has(column.name)));
246
+ return {
247
+ ...(status ? { status } : {}),
248
+ facts,
249
+ summary,
250
+ related,
251
+ ...(parent ? { parent } : {}),
252
+ ...(current ? { current } : {}),
253
+ properties,
254
+ noun: headingOf(noun(base)),
255
+ history: Boolean(hints.history),
256
+ };
257
+ }
258
+ /** The anatomy as a page: header, summary, the lists as tabs, and the aside's parent, current child and rail over the history. */
259
+ export function anatomySections(anatomy) {
260
+ const sections = [];
261
+ if (anatomy.status || anatomy.facts.length) {
262
+ sections.push({ kind: 'fields', presentation: 'header', paths: anatomy.facts, ...(anatomy.status ? { status: anatomy.status } : {}) });
263
+ }
264
+ if (anatomy.summary.length)
265
+ sections.push({ kind: 'fields', presentation: 'summary', paths: anatomy.summary });
266
+ for (const list of anatomy.related) {
267
+ sections.push({
268
+ kind: 'list',
269
+ ...(list.title ? { title: list.title } : {}),
270
+ from: list.from,
271
+ path: list.whose,
272
+ columns: list.show,
273
+ limit: DEFAULT_PAGE_LIST_LIMIT,
274
+ ...(list.sort ? { orderBy: [{ column: list.sort.split(' ')[0], direction: 'desc' }] } : {}),
275
+ });
276
+ }
277
+ /* With no children to list, the fields are the page, not a rail beside nothing. */
278
+ const aside = anatomy.related.length > 0;
279
+ if (anatomy.parent)
280
+ sections.push({ kind: 'fields', title: anatomy.parent.title, presentation: 'card', region: 'aside', paths: anatomy.parent.paths });
281
+ const now = anatomy.current;
282
+ if (now) {
283
+ sections.push({
284
+ kind: 'list',
285
+ title: now.title,
286
+ from: now.from,
287
+ path: now.whose,
288
+ columns: now.show,
289
+ limit: 1,
290
+ presentation: 'card',
291
+ region: 'aside',
292
+ ...(now.query ? { filter: now.query } : {}),
293
+ ...(now.sort
294
+ ? { orderBy: [{ column: now.sort.split(' ')[0], direction: now.sort.endsWith(' asc') ? 'asc' : 'desc' }] }
295
+ : {}),
296
+ });
297
+ }
298
+ /* Titled by what the rail holds, the record's own fields: "Patient", never "Details". */
299
+ if (anatomy.properties.length) {
300
+ sections.push(aside
301
+ ? { kind: 'fields', title: anatomy.noun, presentation: 'properties', region: 'aside', paths: anatomy.properties }
302
+ : { kind: 'fields', title: anatomy.noun, columns: 2, paths: anatomy.properties });
303
+ }
304
+ if (anatomy.history)
305
+ sections.push({ kind: 'history', ...(aside ? { region: 'aside' } : {}) });
306
+ /* The head says the name, and offers its editor, only for a fields section
307
+ that owns it (Page.tsx, titleOwner). A record that is nothing but its
308
+ name (a tag, a note) has no other field, so a header of no facts holds
309
+ it: it draws nothing of its own, and the name stays editable in the head. */
310
+ if (!sections.some((section) => section.kind === 'fields'))
311
+ sections.unshift({ kind: 'fields', presentation: 'header', paths: [] });
312
+ return sections;
313
+ }
314
+ /** The page an App draws for a resource it declared none for (appProjection.ts, /api/pages/suggested). */
315
+ export function anatomyPage(schema, baseId, hints = {}) {
316
+ const anatomy = recordAnatomy(schema, baseId, hints);
317
+ const base = findTable(schema, baseId);
318
+ if (!anatomy || !base)
319
+ return null;
320
+ return {
321
+ id: `suggested:${base.id}`,
322
+ name: base.name,
323
+ base: base.id,
324
+ sections: anatomySections(anatomy),
325
+ listTabs: true,
326
+ source: 'suggested',
327
+ };
328
+ }
329
+ /**
330
+ * An App's record page that declares no aside gets the generated page's: the
331
+ * record's remaining fields as a property rail, titled by its noun ("Bike").
332
+ * Five pages of one App wrote `fields([...the rest], { title: 'Bike', region:
333
+ * 'aside' })` by hand; the rule is the anatomy's, so the two cannot drift.
334
+ * Remaining is judged against the reader's own catalog (so a column they cannot
335
+ * read is not offered) and against what the page already says: any fields
336
+ * section's path, a header's status, a card's reference. A fields section with
337
+ * no paths is the whole record, so nothing remains. An empty remainder draws
338
+ * no aside.
339
+ */
340
+ export function withDefaultAside(schema, page) {
341
+ if (!page.defaultAside || page.aside === false || page.error || page.document)
342
+ return page;
343
+ if (page.sections.some((section) => section.region === 'aside'))
344
+ return page;
345
+ const base = findTable(schema, page.base);
346
+ if (!base)
347
+ return page;
348
+ const shown = new Set();
349
+ for (const section of page.sections) {
350
+ if (section.kind === 'custom')
351
+ section.record?.forEach((path) => shown.add(path.split('.')[0]));
352
+ if (section.kind !== 'fields')
353
+ continue;
354
+ if (!section.paths?.length && section.presentation !== 'header')
355
+ return page;
356
+ section.paths?.forEach((path) => shown.add(path.split('.')[0]));
357
+ if (section.status)
358
+ shown.add(section.status);
359
+ if (section.was)
360
+ shown.add(section.was.split('.')[0]);
361
+ }
362
+ const name = labelColumn(base);
363
+ const paths = railOf(base.columns.filter((column) => readable(base, column) && column.name !== name && !shown.has(column.name)));
364
+ if (!paths.length)
365
+ return page;
366
+ return {
367
+ ...page,
368
+ sections: [...page.sections, { kind: 'fields', title: page.name, presentation: 'properties', region: 'aside', paths }],
369
+ };
370
+ }
@@ -0,0 +1,25 @@
1
+ import { type PageSection, type PageDef } from './pageModel.js';
2
+ /**
3
+ * Read the `pages` section of a tablewalk.json.
4
+ *
5
+ * Throws on a malformed file rather than skipping the bad entry: a page that
6
+ * silently did not appear is a bug report that starts "I definitely wrote
7
+ * it". Everything a config file can get wrong is named with the page it is
8
+ * in and, where there is one, the fix.
9
+ */
10
+ export declare function parsePagesConfig(raw: unknown, where: string): PageDef[];
11
+ /** The keys a page takes. A tablewalk.json page also names its `id`; an App page is keyed by it. */
12
+ export declare const PAGE_KEYS: readonly ['label', 'base', 'connection', 'listTabs', 'empty', 'sections', 'aside', 'layout'];
13
+ /** An App page has no `connection`: the App names its one connection, and a page scoped to another would never show. Nor a `label`: it is called its resource's `noun`. */
14
+ export declare const APP_PAGE_KEYS: ("aside" | "base" | "empty" | "layout" | "listTabs" | "sections")[];
15
+ /** The keys each page section kind takes. Anything else is refused by name. A `segment` is read before the
16
+ section is (appSegments.ts unfoldSegments), as its word in `query`. */
17
+ export declare const PAGE_SECTION_KEYS: Record<PageSection['kind'] | 'view' | 'header' | 'current' | 'card' | 'headline', readonly string[]>;
18
+ export declare const STREAM_KEYS: readonly ['from', 'whose', 'at', 'show', 'detail', 'author', 'query', 'about', 'side', 'tone', 'compact'];
19
+ /**
20
+ * One page body: a tablewalk.json page, whose `id` is its own or derives
21
+ * from the name, or an App page, whose id is its key. The body is the same
22
+ * either way, so the page builder, the scaffold and mistri check emit one
23
+ * shape. Every key is checked: an unknown one is refused with the list.
24
+ */
25
+ export declare function parsePageBody(p: Record<string, unknown>, at: string, id: string, withId?: boolean, noun?: string, keys?: readonly string[]): PageDef;