polen 0.9.1-next.2 → 0.10.0-next.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 (460) hide show
  1. package/README.md +49 -364
  2. package/build/api/api.d.ts +1 -0
  3. package/build/api/api.d.ts.map +1 -1
  4. package/build/api/api.js +1 -0
  5. package/build/api/api.js.map +1 -1
  6. package/build/api/config/configurator.d.ts +9 -1
  7. package/build/api/config/configurator.d.ts.map +1 -1
  8. package/build/api/config/configurator.js +18 -6
  9. package/build/api/config/configurator.js.map +1 -1
  10. package/build/api/config/load.js +5 -5
  11. package/build/api/config/load.js.map +1 -1
  12. package/build/api/config-resolver/resolve.js +2 -2
  13. package/build/api/config-resolver/resolve.js.map +1 -1
  14. package/build/api/content/$$.d.ts +7 -0
  15. package/build/api/content/$$.d.ts.map +1 -0
  16. package/build/api/content/$$.js +7 -0
  17. package/build/api/content/$$.js.map +1 -0
  18. package/build/api/content/$.d.ts +2 -0
  19. package/build/api/content/$.d.ts.map +1 -0
  20. package/build/api/content/$.js +2 -0
  21. package/build/api/content/$.js.map +1 -0
  22. package/build/api/content/metadata.d.ts +10 -0
  23. package/build/api/content/metadata.d.ts.map +1 -0
  24. package/build/api/content/metadata.js +9 -0
  25. package/build/api/content/metadata.js.map +1 -0
  26. package/build/api/content/navbar.d.ts +10 -0
  27. package/build/api/content/navbar.d.ts.map +1 -0
  28. package/build/api/content/navbar.js +45 -0
  29. package/build/api/content/navbar.js.map +1 -0
  30. package/build/api/content/page.d.ts +11 -0
  31. package/build/api/content/page.d.ts.map +1 -0
  32. package/build/api/content/page.js +2 -0
  33. package/build/api/content/page.js.map +1 -0
  34. package/build/api/content/scan.d.ts +19 -0
  35. package/build/api/content/scan.d.ts.map +1 -0
  36. package/build/api/content/scan.js +90 -0
  37. package/build/api/content/scan.js.map +1 -0
  38. package/build/api/content/sidebar.d.ts +104 -0
  39. package/build/api/content/sidebar.d.ts.map +1 -0
  40. package/build/api/content/sidebar.js +166 -0
  41. package/build/api/content/sidebar.js.map +1 -0
  42. package/build/api/content/utils.d.ts +5 -0
  43. package/build/api/content/utils.d.ts.map +1 -0
  44. package/build/api/content/utils.js +8 -0
  45. package/build/api/content/utils.js.map +1 -0
  46. package/build/api/schema/data-sources/schema-directory/schema-directory.js +1 -1
  47. package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
  48. package/build/api/static/index.d.ts +2 -0
  49. package/build/api/static/index.d.ts.map +1 -0
  50. package/build/api/static/index.js +2 -0
  51. package/build/api/static/index.js.map +1 -0
  52. package/build/api/static/manifest.d.ts +18 -0
  53. package/build/api/static/manifest.d.ts.map +1 -0
  54. package/build/api/static/manifest.js +13 -0
  55. package/build/api/static/manifest.js.map +1 -0
  56. package/build/api/static/rebase.d.ts +14 -0
  57. package/build/api/static/rebase.d.ts.map +1 -0
  58. package/build/api/static/rebase.js +110 -0
  59. package/build/api/static/rebase.js.map +1 -0
  60. package/build/api/static/static.d.ts +3 -0
  61. package/build/api/static/static.d.ts.map +1 -0
  62. package/build/api/static/static.js +3 -0
  63. package/build/api/static/static.js.map +1 -0
  64. package/build/api/vite/plugins/branding/index.d.ts +4 -0
  65. package/build/api/vite/plugins/branding/index.d.ts.map +1 -0
  66. package/build/api/vite/plugins/branding/index.js +80 -0
  67. package/build/api/vite/plugins/branding/index.js.map +1 -0
  68. package/build/api/vite/plugins/build.d.ts.map +1 -1
  69. package/build/api/vite/plugins/build.js +22 -1
  70. package/build/api/vite/plugins/build.js.map +1 -1
  71. package/build/api/vite/plugins/core.d.ts +2 -2
  72. package/build/api/vite/plugins/core.d.ts.map +1 -1
  73. package/build/api/vite/plugins/core.js +4 -5
  74. package/build/api/vite/plugins/core.js.map +1 -1
  75. package/build/api/vite/plugins/main.d.ts.map +1 -1
  76. package/build/api/vite/plugins/main.js +2 -1
  77. package/build/api/vite/plugins/main.js.map +1 -1
  78. package/build/api/vite/plugins/pages.d.ts +8 -14
  79. package/build/api/vite/plugins/pages.d.ts.map +1 -1
  80. package/build/api/vite/plugins/pages.js +110 -183
  81. package/build/api/vite/plugins/pages.js.map +1 -1
  82. package/build/api/vite/plugins/serve.js +5 -5
  83. package/build/api/vite/plugins/serve.js.map +1 -1
  84. package/build/cli/_/self-contained-mode.js +5 -5
  85. package/build/cli/_/self-contained-mode.js.map +1 -1
  86. package/build/cli/commands/static/$default.d.ts +3 -0
  87. package/build/cli/commands/static/$default.d.ts.map +1 -0
  88. package/build/cli/commands/static/$default.js +38 -0
  89. package/build/cli/commands/static/$default.js.map +1 -0
  90. package/build/cli/commands/static/rebase.d.ts +2 -0
  91. package/build/cli/commands/static/rebase.d.ts.map +1 -0
  92. package/build/cli/commands/static/rebase.js +26 -0
  93. package/build/cli/commands/static/rebase.js.map +1 -0
  94. package/build/cli/commands/static.d.ts +3 -0
  95. package/build/cli/commands/static.d.ts.map +1 -0
  96. package/build/cli/commands/static.js +5 -0
  97. package/build/cli/commands/static.js.map +1 -0
  98. package/build/exports/components.d.ts +2 -0
  99. package/build/exports/components.d.ts.map +1 -0
  100. package/build/exports/components.js +2 -0
  101. package/build/exports/components.js.map +1 -0
  102. package/build/lib/demos/builder.d.ts +83 -0
  103. package/build/lib/demos/builder.d.ts.map +1 -0
  104. package/build/lib/demos/builder.js +237 -0
  105. package/build/lib/demos/builder.js.map +1 -0
  106. package/build/lib/demos/config-schema.d.ts +243 -0
  107. package/build/lib/demos/config-schema.d.ts.map +1 -0
  108. package/build/lib/demos/config-schema.js +52 -0
  109. package/build/lib/demos/config-schema.js.map +1 -0
  110. package/build/lib/demos/config.d.ts +40 -0
  111. package/build/lib/demos/config.d.ts.map +1 -0
  112. package/build/lib/demos/config.js +180 -0
  113. package/build/lib/demos/config.js.map +1 -0
  114. package/build/lib/demos/index.d.ts +9 -0
  115. package/build/lib/demos/index.d.ts.map +1 -0
  116. package/build/lib/demos/index.js +8 -0
  117. package/build/lib/demos/index.js.map +1 -0
  118. package/build/lib/demos/ui/components.d.ts +33 -0
  119. package/build/lib/demos/ui/components.d.ts.map +1 -0
  120. package/build/lib/demos/ui/components.js +699 -0
  121. package/build/lib/demos/ui/components.js.map +1 -0
  122. package/build/lib/demos/ui/data-collector.d.ts +88 -0
  123. package/build/lib/demos/ui/data-collector.d.ts.map +1 -0
  124. package/build/lib/demos/ui/data-collector.js +174 -0
  125. package/build/lib/demos/ui/data-collector.js.map +1 -0
  126. package/build/lib/demos/ui/landing-page-cli.d.ts +3 -0
  127. package/build/lib/demos/ui/landing-page-cli.d.ts.map +1 -0
  128. package/build/lib/demos/ui/landing-page-cli.js +21 -0
  129. package/build/lib/demos/ui/landing-page-cli.js.map +1 -0
  130. package/build/lib/demos/ui/landing-page.d.ts +32 -0
  131. package/build/lib/demos/ui/landing-page.d.ts.map +1 -0
  132. package/build/lib/demos/ui/landing-page.js +83 -0
  133. package/build/lib/demos/ui/landing-page.js.map +1 -0
  134. package/build/lib/demos/ui/page-renderer.d.ts +26 -0
  135. package/build/lib/demos/ui/page-renderer.d.ts.map +1 -0
  136. package/build/lib/demos/ui/page-renderer.js +104 -0
  137. package/build/lib/demos/ui/page-renderer.js.map +1 -0
  138. package/build/lib/demos/utils.d.ts +14 -0
  139. package/build/lib/demos/utils.d.ts.map +1 -0
  140. package/build/lib/demos/utils.js +37 -0
  141. package/build/lib/demos/utils.js.map +1 -0
  142. package/build/lib/deployment/$$.d.ts +3 -0
  143. package/build/lib/deployment/$$.d.ts.map +1 -0
  144. package/build/lib/deployment/$$.js +3 -0
  145. package/build/lib/deployment/$$.js.map +1 -0
  146. package/build/lib/deployment/$.d.ts +2 -0
  147. package/build/lib/deployment/$.d.ts.map +1 -0
  148. package/build/lib/deployment/$.js +2 -0
  149. package/build/lib/deployment/$.js.map +1 -0
  150. package/build/lib/deployment/metadata.d.ts +32 -0
  151. package/build/lib/deployment/metadata.d.ts.map +1 -0
  152. package/build/lib/deployment/metadata.js +37 -0
  153. package/build/lib/deployment/metadata.js.map +1 -0
  154. package/build/lib/deployment/path-manager.d.ts +41 -0
  155. package/build/lib/deployment/path-manager.d.ts.map +1 -0
  156. package/build/lib/deployment/path-manager.js +157 -0
  157. package/build/lib/deployment/path-manager.js.map +1 -0
  158. package/build/lib/file-router/file-router.d.ts +0 -2
  159. package/build/lib/file-router/file-router.d.ts.map +1 -1
  160. package/build/lib/file-router/file-router.js +0 -2
  161. package/build/lib/file-router/file-router.js.map +1 -1
  162. package/build/lib/file-router/route.d.ts +2 -0
  163. package/build/lib/file-router/route.d.ts.map +1 -1
  164. package/build/lib/file-router/route.js.map +1 -1
  165. package/build/lib/file-router/scan.d.ts.map +1 -1
  166. package/build/lib/file-router/scan.js +22 -13
  167. package/build/lib/file-router/scan.js.map +1 -1
  168. package/build/lib/github-actions/git-controller.d.ts +50 -0
  169. package/build/lib/github-actions/git-controller.d.ts.map +1 -0
  170. package/build/lib/github-actions/git-controller.js +90 -0
  171. package/build/lib/github-actions/git-controller.js.map +1 -0
  172. package/build/lib/github-actions/github-actions.d.ts +7 -0
  173. package/build/lib/github-actions/github-actions.d.ts.map +1 -0
  174. package/build/lib/github-actions/github-actions.js +7 -0
  175. package/build/lib/github-actions/github-actions.js.map +1 -0
  176. package/build/lib/github-actions/index.d.ts +2 -0
  177. package/build/lib/github-actions/index.d.ts.map +1 -0
  178. package/build/lib/github-actions/index.js +2 -0
  179. package/build/lib/github-actions/index.js.map +1 -0
  180. package/build/lib/github-actions/lib/get-pr-deployments.d.ts +12 -0
  181. package/build/lib/github-actions/lib/get-pr-deployments.d.ts.map +1 -0
  182. package/build/lib/github-actions/lib/get-pr-deployments.js +51 -0
  183. package/build/lib/github-actions/lib/get-pr-deployments.js.map +1 -0
  184. package/build/lib/github-actions/pr-controller.d.ts +39 -0
  185. package/build/lib/github-actions/pr-controller.d.ts.map +1 -0
  186. package/build/lib/github-actions/pr-controller.js +122 -0
  187. package/build/lib/github-actions/pr-controller.js.map +1 -0
  188. package/build/lib/github-actions/run-step-cli.d.ts +9 -0
  189. package/build/lib/github-actions/run-step-cli.d.ts.map +1 -0
  190. package/build/lib/github-actions/run-step-cli.js +71 -0
  191. package/build/lib/github-actions/run-step-cli.js.map +1 -0
  192. package/build/lib/github-actions/runner.d.ts +17 -0
  193. package/build/lib/github-actions/runner.d.ts.map +1 -0
  194. package/build/lib/github-actions/runner.js +195 -0
  195. package/build/lib/github-actions/runner.js.map +1 -0
  196. package/build/lib/github-actions/schemas/context.d.ts +933 -0
  197. package/build/lib/github-actions/schemas/context.d.ts.map +1 -0
  198. package/build/lib/github-actions/schemas/context.js +407 -0
  199. package/build/lib/github-actions/schemas/context.js.map +1 -0
  200. package/build/lib/github-actions/schemas/index.d.ts +5 -0
  201. package/build/lib/github-actions/schemas/index.d.ts.map +1 -0
  202. package/build/lib/github-actions/schemas/index.js +5 -0
  203. package/build/lib/github-actions/schemas/index.js.map +1 -0
  204. package/build/lib/github-actions/search-module.d.ts +38 -0
  205. package/build/lib/github-actions/search-module.d.ts.map +1 -0
  206. package/build/lib/github-actions/search-module.js +40 -0
  207. package/build/lib/github-actions/search-module.js.map +1 -0
  208. package/build/lib/github-actions/step.d.ts +163 -0
  209. package/build/lib/github-actions/step.d.ts.map +1 -0
  210. package/build/lib/github-actions/step.js +121 -0
  211. package/build/lib/github-actions/step.js.map +1 -0
  212. package/build/lib/helpers.d.ts.map +1 -1
  213. package/build/lib/helpers.js +5 -3
  214. package/build/lib/helpers.js.map +1 -1
  215. package/build/lib/kit-temp.d.ts +54 -0
  216. package/build/lib/kit-temp.d.ts.map +1 -1
  217. package/build/lib/kit-temp.js +82 -14
  218. package/build/lib/kit-temp.js.map +1 -1
  219. package/build/lib/kit-temp.test-d.d.ts +2 -0
  220. package/build/lib/kit-temp.test-d.d.ts.map +1 -0
  221. package/build/lib/kit-temp.test-d.js +75 -0
  222. package/build/lib/kit-temp.test-d.js.map +1 -0
  223. package/build/lib/mask/$$.d.ts +3 -0
  224. package/build/lib/mask/$$.d.ts.map +1 -0
  225. package/build/lib/mask/$$.js +3 -0
  226. package/build/lib/mask/$$.js.map +1 -0
  227. package/build/lib/mask/$.d.ts +2 -0
  228. package/build/lib/mask/$.d.ts.map +1 -0
  229. package/build/lib/mask/$.js +2 -0
  230. package/build/lib/mask/$.js.map +1 -0
  231. package/build/lib/mask/apply.d.ts +86 -0
  232. package/build/lib/mask/apply.d.ts.map +1 -0
  233. package/build/lib/mask/apply.js +86 -0
  234. package/build/lib/mask/apply.js.map +1 -0
  235. package/build/lib/mask/mask.d.ts +124 -0
  236. package/build/lib/mask/mask.d.ts.map +1 -0
  237. package/build/lib/mask/mask.js +137 -0
  238. package/build/lib/mask/mask.js.map +1 -0
  239. package/build/lib/mask/mask.test-d.d.ts +2 -0
  240. package/build/lib/mask/mask.test-d.d.ts.map +1 -0
  241. package/build/lib/mask/mask.test-d.js +102 -0
  242. package/build/lib/mask/mask.test-d.js.map +1 -0
  243. package/build/lib/mutation-type.d.ts +18 -0
  244. package/build/lib/mutation-type.d.ts.map +1 -0
  245. package/build/lib/mutation-type.js +16 -0
  246. package/build/lib/mutation-type.js.map +1 -0
  247. package/build/lib/task/$$.d.ts +3 -0
  248. package/build/lib/task/$$.d.ts.map +1 -0
  249. package/build/lib/task/$$.js +3 -0
  250. package/build/lib/task/$$.js.map +1 -0
  251. package/build/lib/task/$.d.ts +2 -0
  252. package/build/lib/task/$.d.ts.map +1 -0
  253. package/build/lib/task/$.js +2 -0
  254. package/build/lib/task/$.js.map +1 -0
  255. package/build/lib/task/report.d.ts +28 -0
  256. package/build/lib/task/report.d.ts.map +1 -0
  257. package/build/lib/task/report.js +33 -0
  258. package/build/lib/task/report.js.map +1 -0
  259. package/build/lib/task/task.d.ts +44 -0
  260. package/build/lib/task/task.d.ts.map +1 -0
  261. package/build/lib/task/task.js +63 -0
  262. package/build/lib/task/task.js.map +1 -0
  263. package/build/lib/version-history/index.d.ts +3 -0
  264. package/build/lib/version-history/index.d.ts.map +1 -0
  265. package/build/lib/version-history/index.js +2 -0
  266. package/build/lib/version-history/index.js.map +1 -0
  267. package/build/lib/version-history/types.d.ts +64 -0
  268. package/build/lib/version-history/types.d.ts.map +1 -0
  269. package/build/lib/version-history/types.js +5 -0
  270. package/build/lib/version-history/types.js.map +1 -0
  271. package/build/lib/version-history/version-history.d.ts +85 -0
  272. package/build/lib/version-history/version-history.d.ts.map +1 -0
  273. package/build/lib/version-history/version-history.js +248 -0
  274. package/build/lib/version-history/version-history.js.map +1 -0
  275. package/build/project-data.d.ts +0 -1
  276. package/build/project-data.d.ts.map +1 -1
  277. package/build/sandbox.d.ts +2 -0
  278. package/build/sandbox.d.ts.map +1 -0
  279. package/build/sandbox.js +18 -0
  280. package/build/sandbox.js.map +1 -0
  281. package/build/singletons/debug.d.ts +1 -1
  282. package/build/singletons/debug.d.ts.map +1 -1
  283. package/build/singletons/debug.js +1 -1
  284. package/build/singletons/debug.js.map +1 -1
  285. package/build/template/components/HamburgerMenu.d.ts +9 -0
  286. package/build/template/components/HamburgerMenu.d.ts.map +1 -0
  287. package/build/template/components/HamburgerMenu.jsx +53 -0
  288. package/build/template/components/HamburgerMenu.jsx.map +1 -0
  289. package/build/template/components/Link.jsx +1 -1
  290. package/build/template/components/Logo.d.ts +9 -0
  291. package/build/template/components/Logo.d.ts.map +1 -0
  292. package/build/template/components/Logo.jsx +29 -0
  293. package/build/template/components/Logo.jsx.map +1 -0
  294. package/build/template/components/NotFound.d.ts +2 -0
  295. package/build/template/components/NotFound.d.ts.map +1 -0
  296. package/build/template/components/NotFound.jsx +26 -0
  297. package/build/template/components/NotFound.jsx.map +1 -0
  298. package/build/template/components/ThemeToggle.d.ts +3 -0
  299. package/build/template/components/ThemeToggle.d.ts.map +1 -0
  300. package/build/template/components/ThemeToggle.jsx +10 -0
  301. package/build/template/components/ThemeToggle.jsx.map +1 -0
  302. package/build/template/components/content/$$.d.ts +2 -0
  303. package/build/template/components/content/$$.d.ts.map +1 -0
  304. package/build/template/components/content/$$.js +2 -0
  305. package/build/template/components/content/$$.js.map +1 -0
  306. package/build/template/components/sidebar/Sidebar.d.ts +2 -2
  307. package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
  308. package/build/template/components/sidebar/SidebarItem.d.ts +3 -3
  309. package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
  310. package/build/template/components/sidebar/SidebarItem.jsx +1 -1
  311. package/build/template/components/sidebar/SidebarItem.jsx.map +1 -1
  312. package/build/template/contexts/ThemeContext.d.ts +12 -0
  313. package/build/template/contexts/ThemeContext.d.ts.map +1 -0
  314. package/build/template/contexts/ThemeContext.jsx +41 -0
  315. package/build/template/contexts/ThemeContext.jsx.map +1 -0
  316. package/build/template/routes/root.d.ts.map +1 -1
  317. package/build/template/routes/root.jsx +66 -53
  318. package/build/template/routes/root.jsx.map +1 -1
  319. package/build/template/server/app.d.ts.map +1 -1
  320. package/build/template/server/app.js +2 -21
  321. package/build/template/server/app.js.map +1 -1
  322. package/package.json +27 -13
  323. package/src/api/api.ts +1 -0
  324. package/src/api/config/configurator.ts +28 -6
  325. package/src/api/config/load.ts +5 -5
  326. package/src/api/config-resolver/resolve.ts +2 -2
  327. package/src/api/content/$$.ts +6 -0
  328. package/src/api/content/$.test.ts +72 -0
  329. package/src/api/content/$.ts +1 -0
  330. package/src/api/content/metadata.ts +11 -0
  331. package/src/api/content/navbar.test.ts +55 -0
  332. package/src/api/content/navbar.ts +61 -0
  333. package/src/api/content/page.ts +12 -0
  334. package/src/api/content/scan.ts +117 -0
  335. package/src/api/content/sidebar.test.ts +297 -0
  336. package/src/api/content/sidebar.ts +283 -0
  337. package/src/api/content/utils.ts +7 -0
  338. package/src/api/schema/data-sources/schema-directory/schema-directory.ts +1 -1
  339. package/src/api/singletons/markdown/markdown.test.ts +1 -1
  340. package/src/api/static/index.ts +1 -0
  341. package/src/api/static/manifest.test.ts +106 -0
  342. package/src/api/static/manifest.ts +16 -0
  343. package/src/api/static/rebase.test.ts +229 -0
  344. package/src/api/static/rebase.ts +140 -0
  345. package/src/api/static/static.ts +2 -0
  346. package/src/api/utils/asset-url/asset-url.test.ts +4 -4
  347. package/src/api/vite/plugins/branding/index.ts +108 -0
  348. package/src/api/vite/plugins/build.ts +25 -1
  349. package/src/api/vite/plugins/core.ts +6 -7
  350. package/src/api/vite/plugins/main.ts +2 -0
  351. package/src/api/vite/plugins/pages.ts +131 -207
  352. package/src/api/vite/plugins/serve.ts +5 -5
  353. package/src/cli/_/self-contained-mode.ts +5 -5
  354. package/src/cli/commands/static/$default.ts +43 -0
  355. package/src/cli/commands/static/rebase.ts +37 -0
  356. package/src/cli/commands/static.ts +6 -0
  357. package/src/exports/components.ts +1 -0
  358. package/src/lib/demos/builder.ts +298 -0
  359. package/src/lib/demos/config-schema.ts +56 -0
  360. package/src/lib/demos/config.test.ts +193 -0
  361. package/src/lib/demos/config.ts +205 -0
  362. package/src/lib/demos/index.ts +9 -0
  363. package/src/lib/demos/ui/components.ts +739 -0
  364. package/src/lib/demos/ui/data-collector.ts +246 -0
  365. package/src/lib/demos/ui/landing-page-cli.ts +23 -0
  366. package/src/lib/demos/ui/landing-page.ts +126 -0
  367. package/src/lib/demos/ui/page-renderer.ts +124 -0
  368. package/src/lib/demos/utils.ts +43 -0
  369. package/src/lib/deployment/$$.ts +2 -0
  370. package/src/lib/deployment/$.test.ts +53 -0
  371. package/src/lib/deployment/$.ts +1 -0
  372. package/src/lib/deployment/metadata.ts +40 -0
  373. package/src/lib/deployment/path-manager.ts +186 -0
  374. package/src/lib/file-router/file-router.ts +0 -2
  375. package/src/lib/file-router/linter.test.ts +2 -0
  376. package/src/lib/file-router/route.ts +2 -0
  377. package/src/lib/file-router/scan.ts +26 -14
  378. package/src/lib/github-actions/git-controller.ts +151 -0
  379. package/src/lib/github-actions/github-actions.ts +6 -0
  380. package/src/lib/github-actions/index.ts +1 -0
  381. package/src/lib/github-actions/lib/get-pr-deployments.ts +76 -0
  382. package/src/lib/github-actions/pr-controller.test.ts +172 -0
  383. package/src/lib/github-actions/pr-controller.ts +183 -0
  384. package/src/lib/github-actions/run-step-cli.ts +84 -0
  385. package/src/lib/github-actions/runner.test.ts +192 -0
  386. package/src/lib/github-actions/runner.ts +226 -0
  387. package/src/lib/github-actions/schemas/context.ts +424 -0
  388. package/src/lib/github-actions/schemas/index.ts +5 -0
  389. package/src/lib/github-actions/search-module.test.ts +110 -0
  390. package/src/lib/github-actions/search-module.ts +76 -0
  391. package/src/lib/github-actions/step.test.ts +149 -0
  392. package/src/lib/github-actions/step.ts +232 -0
  393. package/src/lib/helpers.ts +4 -3
  394. package/src/lib/kit-temp.test-d.ts +115 -0
  395. package/src/lib/kit-temp.test.ts +127 -0
  396. package/src/lib/kit-temp.ts +128 -14
  397. package/src/lib/mask/$$.ts +2 -0
  398. package/src/lib/mask/$.test.ts +248 -0
  399. package/src/lib/mask/$.ts +1 -0
  400. package/src/lib/mask/apply.ts +134 -0
  401. package/src/lib/mask/mask.test-d.ts +144 -0
  402. package/src/lib/mask/mask.ts +244 -0
  403. package/src/lib/mutation-type.ts +20 -0
  404. package/src/lib/shiki/shiki.test.ts +1 -1
  405. package/src/lib/task/$$.ts +2 -0
  406. package/src/lib/task/$.test.ts +209 -0
  407. package/src/lib/task/$.ts +1 -0
  408. package/src/lib/task/report.ts +72 -0
  409. package/src/lib/task/task.ts +112 -0
  410. package/src/lib/version-history/index.test.ts +196 -0
  411. package/src/lib/version-history/index.ts +4 -0
  412. package/src/lib/version-history/types.ts +68 -0
  413. package/src/lib/version-history/version-history.ts +293 -0
  414. package/src/project-data.ts +0 -1
  415. package/src/sandbox.ts +20 -0
  416. package/src/singletons/debug.ts +1 -1
  417. package/src/template/components/HamburgerMenu.tsx +96 -0
  418. package/src/template/components/Link.tsx +1 -1
  419. package/src/template/components/Logo.tsx +46 -0
  420. package/src/template/components/NotFound.tsx +28 -0
  421. package/src/template/components/ThemeToggle.tsx +21 -0
  422. package/src/template/components/content/$$.ts +1 -0
  423. package/src/template/components/sidebar/Sidebar.tsx +2 -2
  424. package/src/template/components/sidebar/SidebarItem.tsx +8 -8
  425. package/src/template/contexts/ThemeContext.tsx +60 -0
  426. package/src/template/routes/root.tsx +85 -74
  427. package/src/template/server/app.ts +2 -27
  428. package/build/lib/file-router/scan-tree.d.ts +0 -20
  429. package/build/lib/file-router/scan-tree.d.ts.map +0 -1
  430. package/build/lib/file-router/scan-tree.js +0 -158
  431. package/build/lib/file-router/scan-tree.js.map +0 -1
  432. package/build/lib/file-router/sidebar/index.d.ts +0 -3
  433. package/build/lib/file-router/sidebar/index.d.ts.map +0 -1
  434. package/build/lib/file-router/sidebar/index.js +0 -4
  435. package/build/lib/file-router/sidebar/index.js.map +0 -1
  436. package/build/lib/file-router/sidebar/sidebar-tree.d.ts +0 -9
  437. package/build/lib/file-router/sidebar/sidebar-tree.d.ts.map +0 -1
  438. package/build/lib/file-router/sidebar/sidebar-tree.js +0 -85
  439. package/build/lib/file-router/sidebar/sidebar-tree.js.map +0 -1
  440. package/build/lib/file-router/sidebar/types.d.ts +0 -17
  441. package/build/lib/file-router/sidebar/types.d.ts.map +0 -1
  442. package/build/lib/file-router/sidebar/types.js +0 -2
  443. package/build/lib/file-router/sidebar/types.js.map +0 -1
  444. package/build/lib/tree/index.d.ts +0 -3
  445. package/build/lib/tree/index.d.ts.map +0 -1
  446. package/build/lib/tree/index.js +0 -2
  447. package/build/lib/tree/index.js.map +0 -1
  448. package/build/lib/tree/tree.d.ts +0 -62
  449. package/build/lib/tree/tree.d.ts.map +0 -1
  450. package/build/lib/tree/tree.js +0 -134
  451. package/build/lib/tree/tree.js.map +0 -1
  452. package/src/lib/file-router/scan-tree.test.ts +0 -189
  453. package/src/lib/file-router/scan-tree.ts +0 -205
  454. package/src/lib/file-router/sidebar/index.ts +0 -3
  455. package/src/lib/file-router/sidebar/sidebar-tree.test.ts +0 -123
  456. package/src/lib/file-router/sidebar/sidebar-tree.ts +0 -110
  457. package/src/lib/file-router/sidebar/types.ts +0 -19
  458. package/src/lib/tree/index.ts +0 -2
  459. package/src/lib/tree/tree.test.ts +0 -117
  460. package/src/lib/tree/tree.ts +0 -183
@@ -0,0 +1,244 @@
1
+ //
2
+ //
3
+ //
4
+ //
5
+ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • Mask
6
+ //
7
+ //
8
+
9
+ /**
10
+ * A mask that can either hide/show data entirely (BinaryMask) or
11
+ * selectively hide/show object properties (PropertiesMask).
12
+ *
13
+ * @template $Data - The data type being masked
14
+ */
15
+ export type Mask<$Data = any> = BinaryMask<$Data> | PropertiesMask<$Data extends object ? $Data : object>
16
+
17
+ /**
18
+ * Create a mask based on the provided options.
19
+ *
20
+ * @param options - Mask configuration:
21
+ * - `boolean`: Creates a binary mask (true = show, false = hide)
22
+ * - `string[]`: Creates a properties mask that allows only the specified keys
23
+ * - `object`: Creates a properties mask based on true/false values per key
24
+ *
25
+ * @returns A mask that can be applied to data
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // Binary mask
30
+ * const showAll = create(true)
31
+ * const hideAll = create(false)
32
+ *
33
+ * // Properties mask with array
34
+ * const allowMask = create<User>(['name', 'email'])
35
+ *
36
+ * // Properties mask with object
37
+ * const objectMask = create<User>({
38
+ * name: true,
39
+ * email: true,
40
+ * password: false
41
+ * })
42
+ * ```
43
+ */
44
+ export const create = <$Data = unknown>(
45
+ options: InferOptions<$Data>,
46
+ ): Mask<$Data> => {
47
+ if (typeof options === 'boolean') {
48
+ return createBinary(options) as any
49
+ }
50
+
51
+ // Array input -> PropertiesMask with 'allow' mode
52
+ if (Array.isArray(options)) {
53
+ return createProperties('allow', options as any) as any
54
+ }
55
+
56
+ // Object input -> PropertiesMask based on true/false values
57
+ const entries = Object.entries(options)
58
+
59
+ const allowedKeys = entries
60
+ .filter(([_, include]) => include === true)
61
+ .map(([key]) => key)
62
+
63
+ const deniedKeys = entries
64
+ .filter(([_, include]) => include === false)
65
+ .map(([key]) => key)
66
+
67
+ // If we have denied keys, use deny mode
68
+ if (deniedKeys.length > 0 && allowedKeys.length === 0) {
69
+ return createProperties('deny', deniedKeys) as any
70
+ }
71
+
72
+ // Default to allow mode with allowed keys
73
+ return createProperties('allow', allowedKeys) as any
74
+ }
75
+
76
+ /**
77
+ * Valid options for creating a mask for the given data type.
78
+ *
79
+ * @template $Data - The data type to be masked
80
+ */
81
+ export type InferOptions<$Data> = unknown extends $Data ? boolean | string[] | Record<string, boolean>
82
+ : $Data extends object ? (
83
+ | boolean
84
+ | (keyof $Data)[]
85
+ | Partial<
86
+ {
87
+ [K in keyof $Data]: boolean
88
+ }
89
+ >
90
+ )
91
+ : boolean
92
+
93
+ //
94
+ //
95
+ //
96
+ //
97
+ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • PropertiesMask
98
+ //
99
+ //
100
+
101
+ /**
102
+ * A mask that selectively shows or hides object properties.
103
+ *
104
+ * @template $Data - The object type being masked
105
+ */
106
+ export interface PropertiesMask<$Data extends object = object> {
107
+ type: 'properties'
108
+ /** Whether to allow only specified properties or deny them */
109
+ mode: 'allow' | 'deny'
110
+ /** The list of property keys to allow or deny */
111
+ properties: (keyof $Data)[]
112
+ }
113
+
114
+ /**
115
+ * Create a properties mask.
116
+ *
117
+ * @param mode - 'allow' to show only specified properties, 'deny' to hide them
118
+ * @param properties - Array of property keys to allow or deny
119
+ * @returns A PropertiesMask
120
+ */
121
+ export const createProperties = <$Data extends object = object>(
122
+ mode: 'allow' | 'deny',
123
+ properties: (keyof $Data)[],
124
+ ): PropertiesMask<$Data> => ({
125
+ type: 'properties',
126
+ mode,
127
+ properties,
128
+ })
129
+
130
+ //
131
+ //
132
+ //
133
+ //
134
+ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • BinaryMask
135
+ //
136
+ //
137
+
138
+ /**
139
+ * A mask that either shows or hides data entirely.
140
+ *
141
+ * @template _$Data - The data type being masked (used for type inference)
142
+ */
143
+ export type BinaryMask<_$Data = any> = {
144
+ type: 'binary'
145
+ /** Whether to show (true) or hide (false) the data */
146
+ show: boolean
147
+ }
148
+
149
+ /**
150
+ * Create a binary mask.
151
+ *
152
+ * @param show - Whether to show (true) or hide (false) the data
153
+ * @returns A BinaryMask
154
+ */
155
+ export const createBinary = <$Data = any>(show: boolean): BinaryMask<$Data> => ({
156
+ type: 'binary',
157
+ show,
158
+ })
159
+
160
+ //
161
+ //
162
+ //
163
+ //
164
+ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • Convenience Constructors with Semantic Names
165
+ //
166
+ //
167
+
168
+ /**
169
+ * Create a mask that shows all data.
170
+ * @returns A BinaryMask with show=true
171
+ */
172
+ export const show = (): BinaryMask => ({
173
+ type: 'binary',
174
+ show: true,
175
+ })
176
+
177
+ /**
178
+ * Create a mask that hides all data.
179
+ * @returns A BinaryMask with show=false
180
+ */
181
+ export const hide = (): BinaryMask => ({
182
+ type: 'binary',
183
+ show: false,
184
+ })
185
+
186
+ /**
187
+ * Create a mask that shows only the specified properties.
188
+ *
189
+ * @param properties - Array of property keys to show
190
+ * @returns A PropertiesMask in 'allow' mode
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * const userMask = pick<User>(['name', 'email'])
195
+ * // Only 'name' and 'email' will be shown
196
+ * ```
197
+ */
198
+ export const pick = <$Data extends object = object>(
199
+ properties: (keyof $Data)[],
200
+ ): PropertiesMask<$Data> => ({
201
+ type: 'properties',
202
+ mode: 'allow',
203
+ properties,
204
+ })
205
+
206
+ /**
207
+ * Create a mask that hides the specified properties.
208
+ *
209
+ * @param properties - Array of property keys to hide
210
+ * @returns A PropertiesMask in 'deny' mode
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * const userMask = omit<User>(['password', 'ssn'])
215
+ * // Everything except 'password' and 'ssn' will be shown
216
+ * ```
217
+ */
218
+ export const omit = <$Data extends object = object>(
219
+ properties: (keyof $Data)[],
220
+ ): PropertiesMask<$Data> => ({
221
+ type: 'properties',
222
+ mode: 'deny',
223
+ properties,
224
+ })
225
+
226
+ //
227
+ //
228
+ //
229
+ //
230
+ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • Utilities
231
+ //
232
+ //
233
+
234
+ /**
235
+ * Extract the data type from a mask.
236
+ *
237
+ * @template $Mask - The mask type
238
+ * @returns The data type the mask is designed for
239
+ */
240
+ // dprint-ignore
241
+ export type GetDataType<$Mask extends Mask<any>> =
242
+ $Mask extends BinaryMask<infer $Data> ? $Data :
243
+ $Mask extends PropertiesMask<infer $Data> ? $Data
244
+ : never
@@ -0,0 +1,20 @@
1
+ export const MutationType = {
2
+ Create: 'create',
3
+ Update: 'update',
4
+ Delete: 'delete',
5
+ } as const
6
+
7
+ export type MutationType = typeof MutationType[keyof typeof MutationType]
8
+
9
+ export type ExistenceDiff =
10
+ | { before: false; after: true } // Create
11
+ | { before: true; after: true } // Update
12
+ | { before: true; after: false } // Delete
13
+
14
+ export const getMutationType = (diff: ExistenceDiff): MutationType => {
15
+ if (!diff.before && diff.after) return MutationType.Create
16
+ if (diff.before && diff.after) return MutationType.Update
17
+ if (diff.before && !diff.after) return MutationType.Delete
18
+ // TypeScript ensures we handle all cases exhaustively
19
+ throw new Error(`Invalid existence diff: ${JSON.stringify(diff)}`)
20
+ }
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from 'vitest'
2
- import { getHighlighter, highlightCode } from './shiki.js'
2
+ import { getHighlighter, highlightCode } from './shiki.ts'
3
3
 
4
4
  test(`getHighlighter returns singleton instance`, async () => {
5
5
  const highlighter1 = await getHighlighter()
@@ -0,0 +1,2 @@
1
+ export * from './report.ts'
2
+ export * from './task.ts'
@@ -0,0 +1,209 @@
1
+ import * as fc from 'fast-check'
2
+ import { describe, expect, test, vi } from 'vitest'
3
+ import { Task } from './$.ts'
4
+
5
+ describe('create', () => {
6
+ test('executes async function and captures timing', async () => {
7
+ const double = Task.create(
8
+ async (x: number) => x * 2,
9
+ { name: 'double' },
10
+ )
11
+
12
+ const report = await double(5)
13
+
14
+ expect(report.task.name).toBe('double')
15
+ expect(report.execution.input).toBe(5)
16
+ expect(report.execution.output).toBe(10)
17
+ expect(report.execution.timings.duration).toBeGreaterThan(0)
18
+ })
19
+
20
+ test('captures errors', async () => {
21
+ const failing = Task.create(
22
+ async () => {
23
+ throw new Error('Failed')
24
+ },
25
+ { name: 'failing' },
26
+ )
27
+
28
+ const report = await failing(null)
29
+
30
+ expect(report.execution.output).toBeInstanceOf(Error)
31
+ expect((report.execution.output as Error).message).toBe('Failed')
32
+ })
33
+ })
34
+
35
+ describe('formatReport', () => {
36
+ test('masks sensitive data', async () => {
37
+ const createUser = Task.create(
38
+ async (data: any) => ({
39
+ email: data.email,
40
+ token: 'abc123',
41
+ }),
42
+ {
43
+ name: 'create-user',
44
+ mask: {
45
+ input: { password: false }, // Hide password
46
+ output: { token: false }, // Hide token
47
+ },
48
+ },
49
+ )
50
+
51
+ const report = await createUser({
52
+ email: 'user@example.com',
53
+ password: 'secret',
54
+ })
55
+
56
+ // Uses mask from task definition by default
57
+ const formatted = Task.formatReport(report)
58
+
59
+ expect(formatted).toContain('create-user')
60
+ expect(formatted).toContain('user@example.com')
61
+ expect(formatted).not.toContain('secret')
62
+ expect(formatted).not.toContain('abc123')
63
+ })
64
+
65
+ test('debug mode reveals all data', async () => {
66
+ const createUser = Task.create(
67
+ async (data: any) => ({
68
+ email: data.email,
69
+ token: 'abc123',
70
+ }),
71
+ {
72
+ name: 'create-user',
73
+ mask: {
74
+ input: { password: false }, // Hide password
75
+ output: { token: false }, // Hide token
76
+ },
77
+ },
78
+ )
79
+
80
+ const report = await createUser({
81
+ email: 'user@example.com',
82
+ password: 'secret',
83
+ })
84
+
85
+ const formatted = Task.formatReport(report, { debug: true })
86
+
87
+ expect(formatted).toContain('secret')
88
+ expect(formatted).toContain('abc123')
89
+ })
90
+ })
91
+
92
+ describe('exitWithReport', () => {
93
+ test('exits with code 0 on success', async () => {
94
+ const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
95
+ throw new Error('process.exit called')
96
+ })
97
+ const mockLog = vi.spyOn(console, 'log').mockImplementation(() => {})
98
+
99
+ const success = Task.create(async () => 'result')
100
+ const report = await success(null)
101
+
102
+ expect(() => Task.exitWithReport(report)).toThrow('process.exit called')
103
+ expect(mockExit).toHaveBeenCalledWith(0)
104
+ expect(mockLog).toHaveBeenCalled()
105
+
106
+ mockExit.mockRestore()
107
+ mockLog.mockRestore()
108
+ })
109
+
110
+ test('exits with code 1 on error', async () => {
111
+ const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
112
+ throw new Error('process.exit called')
113
+ })
114
+ const mockLog = vi.spyOn(console, 'log').mockImplementation(() => {})
115
+
116
+ const failing = Task.create(async () => {
117
+ throw new Error('Failed')
118
+ })
119
+ const report = await failing(null)
120
+
121
+ expect(() => Task.exitWithReport(report)).toThrow('process.exit called')
122
+ expect(mockExit).toHaveBeenCalledWith(1)
123
+ expect(mockLog).toHaveBeenCalled()
124
+
125
+ mockExit.mockRestore()
126
+ mockLog.mockRestore()
127
+ })
128
+ })
129
+
130
+ describe('runAndExit', () => {
131
+ test('combines create, execute, and exit into one call', async () => {
132
+ const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
133
+ throw new Error('process.exit called')
134
+ })
135
+ const mockLog = vi.spyOn(console, 'log').mockImplementation(() => {})
136
+
137
+ const double = async (x: number) => x * 2
138
+
139
+ await expect(() => Task.runAndExit(double, 5, { name: 'double' })).rejects.toThrow('process.exit called')
140
+
141
+ expect(mockExit).toHaveBeenCalledWith(0)
142
+ expect(mockLog).toHaveBeenCalled()
143
+
144
+ // Verify the logged output contains expected content
145
+ const loggedOutput = mockLog.mock.calls[0]?.[0]
146
+ expect(loggedOutput).toContain('double')
147
+ expect(loggedOutput).toContain('10') // Result of 5 * 2
148
+
149
+ mockExit.mockRestore()
150
+ mockLog.mockRestore()
151
+ })
152
+
153
+ test('exits with error code on failure', async () => {
154
+ const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
155
+ throw new Error('process.exit called')
156
+ })
157
+ const mockLog = vi.spyOn(console, 'log').mockImplementation(() => {})
158
+
159
+ const failing = async () => {
160
+ throw new Error('Task failed')
161
+ }
162
+
163
+ await expect(() => Task.runAndExit(failing, null, { name: 'failing' })).rejects.toThrow('process.exit called')
164
+
165
+ expect(mockExit).toHaveBeenCalledWith(1)
166
+ expect(mockLog).toHaveBeenCalled()
167
+
168
+ mockExit.mockRestore()
169
+ mockLog.mockRestore()
170
+ })
171
+ })
172
+
173
+ describe('property-based tests', () => {
174
+ test('duration is always positive', async () => {
175
+ await fc.assert(
176
+ fc.asyncProperty(
177
+ fc.integer(),
178
+ async (input) => {
179
+ const identity = Task.create(
180
+ async (x: any) => x,
181
+ { name: 'identity' },
182
+ )
183
+
184
+ const report = await identity(input)
185
+
186
+ expect(report.execution.timings.duration).toBeGreaterThanOrEqual(0)
187
+ expect(report.execution.output).toBe(input)
188
+ },
189
+ ),
190
+ )
191
+ })
192
+
193
+ test('timing fields are consistent', async () => {
194
+ await fc.assert(
195
+ fc.asyncProperty(
196
+ fc.anything(),
197
+ async (input) => {
198
+ const noop = Task.create(async (_: any) => null)
199
+ const report = await noop(input)
200
+
201
+ const { start, end, duration } = report.execution.timings
202
+
203
+ expect(end).toBeGreaterThanOrEqual(start)
204
+ expect(duration).toBeCloseTo(end - start, 5)
205
+ },
206
+ ),
207
+ )
208
+ })
209
+ })
@@ -0,0 +1 @@
1
+ export * as Task from './$$.ts'
@@ -0,0 +1,72 @@
1
+ import { Mask } from '#lib/mask'
2
+ import { Err, Str } from '@wollybeard/kit'
3
+ import type { Definition, MaskOptions } from './task.ts'
4
+
5
+ export interface Report<$Input, $Output> {
6
+ task: Definition<$Input, $Output>
7
+ execution: {
8
+ input: $Input
9
+ output: $Output | Error
10
+ timings: {
11
+ start: number
12
+ end: number
13
+ duration: number
14
+ }
15
+ }
16
+ }
17
+
18
+ export interface FormatOptions<$Input, $Output> {
19
+ /**
20
+ * Force masks to reveal all data
21
+ */
22
+ debug?: boolean
23
+ /**
24
+ * A mask to apply to the input (if any) and successful return (if any).
25
+ *
26
+ * @default Uses the mask bundled with the task, if any.
27
+ */
28
+ mask?: MaskOptions<$Input, $Output>
29
+ }
30
+
31
+ export const formatReport = <$Input, $Output>(
32
+ report: Report<$Input, $Output>,
33
+ options?: FormatOptions<$Input, $Output>,
34
+ ): string => {
35
+ const maskOptions = options?.debug
36
+ ? undefined
37
+ : (options?.mask ?? report.task.mask)
38
+
39
+ // Apply masks
40
+ const maskedInput = maskOptions?.input
41
+ ? Mask.apply(report.execution.input, Mask.create(maskOptions.input))
42
+ : report.execution.input
43
+
44
+ const maskedOutput = report.execution.output instanceof Error || !maskOptions?.output
45
+ ? report.execution.output
46
+ : Mask.apply(report.execution.output, Mask.create(maskOptions.output))
47
+
48
+ // Format report
49
+ const s = Str.Builder()
50
+
51
+ s`Task: ${report.task.name}`
52
+ s`Duration: ${report.execution.timings.duration.toFixed(2)}ms`
53
+ s`Input: ${JSON.stringify(maskedInput, null, 2)}`
54
+
55
+ if (report.execution.output instanceof Error) {
56
+ s(Err.inspect(report.execution.output))
57
+ } else {
58
+ s`Output: ${JSON.stringify(maskedOutput, null, 2)}`
59
+ }
60
+
61
+ return s.render()
62
+ }
63
+
64
+ export const exitWithReport = <$Input, $Output>(
65
+ report: Report<$Input, $Output>,
66
+ options?: FormatOptions<$Input, $Output>,
67
+ ): never => {
68
+ const isError = Err.is(report.execution.output)
69
+ const exitCode = isError ? 1 : 0
70
+ console.log(formatReport(report, options))
71
+ process.exit(exitCode)
72
+ }
@@ -0,0 +1,112 @@
1
+ import type { Mask } from '#lib/mask'
2
+ import type { Report } from './report.ts'
3
+ import { exitWithReport } from './report.ts'
4
+
5
+ export interface Definition<$Input = any, $Output = any> {
6
+ name: string
7
+ mask?: MaskOptions<$Input, $Output>
8
+ }
9
+
10
+ export interface Task<$Input, $Output> {
11
+ (input: $Input): Promise<Report<$Input, $Output>>
12
+ definition: Definition<$Input, $Output>
13
+ }
14
+
15
+ export interface MaskOptions<$Input, $Output> {
16
+ /**
17
+ * @default true
18
+ */
19
+ input?: Mask.InferOptions<$Input>
20
+ /**
21
+ * @default true
22
+ */
23
+ output?: Mask.InferOptions<$Output>
24
+ }
25
+
26
+ export const create = <$Input, $Output>(
27
+ fn: (input: $Input) => Promise<$Output>,
28
+ options?: {
29
+ /**
30
+ * @default the fn name
31
+ */
32
+ name?: string
33
+ /**
34
+ * An optional default mask to use for successfully returned values.
35
+ */
36
+ mask?: MaskOptions<$Input, $Output>
37
+ },
38
+ ): Task<$Input, $Output> => {
39
+ const definition: Definition<$Input, $Output> = {
40
+ name: options?.name ?? (fn.name || 'anonymous'),
41
+ mask: options?.mask,
42
+ }
43
+
44
+ const task = async (input: $Input): Promise<Report<$Input, $Output>> => {
45
+ const start = performance.now()
46
+
47
+ try {
48
+ const output = await fn(input)
49
+ const end = performance.now()
50
+
51
+ return {
52
+ task: definition,
53
+ execution: {
54
+ input,
55
+ output,
56
+ timings: {
57
+ start,
58
+ end,
59
+ duration: end - start,
60
+ },
61
+ },
62
+ }
63
+ } catch (error) {
64
+ const end = performance.now()
65
+
66
+ return {
67
+ task: definition,
68
+ execution: {
69
+ input,
70
+ output: error as Error,
71
+ timings: {
72
+ start,
73
+ end,
74
+ duration: end - start,
75
+ },
76
+ },
77
+ }
78
+ }
79
+ }
80
+
81
+ task.definition = definition
82
+
83
+ return task
84
+ }
85
+
86
+ /**
87
+ * Sugar method that creates a task, executes it, and exits with the report.
88
+ * Equivalent to: create(fn, options) -> task(input) -> exitWithReport(report)
89
+ *
90
+ * @param fn - The function to wrap as a task
91
+ * @param input - Input to pass to the task
92
+ * @param options - Combined task creation and format options
93
+ */
94
+ export const runAndExit = async <$Input, $Output>(
95
+ fn: (input: $Input) => Promise<$Output>,
96
+ input: $Input,
97
+ options?: {
98
+ name?: string
99
+ mask?: MaskOptions<$Input, $Output>
100
+ debug?: boolean
101
+ },
102
+ ): Promise<never> => {
103
+ const task = create(fn, {
104
+ name: options?.name,
105
+ mask: options?.mask,
106
+ })
107
+ const report = await task(input)
108
+ return exitWithReport(report, {
109
+ debug: options?.debug,
110
+ mask: options?.mask,
111
+ })
112
+ }