@pithy-sh/core 0.1.2 → 0.1.3

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 (393) hide show
  1. package/dist/address/address.d.ts +57 -0
  2. package/dist/address/address.d.ts.map +1 -0
  3. package/dist/address/address.js +71 -0
  4. package/dist/audit/auditEvent.d.ts +89 -0
  5. package/dist/audit/auditEvent.d.ts.map +1 -0
  6. package/dist/audit/auditEvent.js +69 -0
  7. package/dist/audit/recorder.d.ts +18 -0
  8. package/dist/audit/recorder.d.ts.map +1 -0
  9. package/dist/audit/recorder.js +8 -0
  10. package/dist/capability/bindings.d.ts +62 -0
  11. package/dist/capability/bindings.d.ts.map +1 -0
  12. package/dist/capability/bindings.js +97 -0
  13. package/dist/capability/capability.d.ts +501 -0
  14. package/dist/capability/capability.d.ts.map +1 -0
  15. package/dist/capability/capability.js +16 -0
  16. package/dist/capability/client.d.ts +70 -0
  17. package/dist/capability/client.d.ts.map +1 -0
  18. package/dist/capability/client.js +86 -0
  19. package/dist/capability/compose.d.ts +25 -0
  20. package/dist/capability/compose.d.ts.map +1 -0
  21. package/dist/capability/compose.js +54 -0
  22. package/dist/capability/composition.d.ts +26 -0
  23. package/dist/capability/composition.d.ts.map +1 -0
  24. package/dist/capability/composition.js +84 -0
  25. package/dist/capability/config.d.ts +7 -0
  26. package/dist/capability/config.d.ts.map +1 -0
  27. package/dist/capability/config.js +14 -0
  28. package/dist/capability/devSecret.d.ts +32 -0
  29. package/dist/capability/devSecret.d.ts.map +1 -0
  30. package/dist/capability/devSecret.js +28 -0
  31. package/dist/capability/manifest.d.ts +298 -0
  32. package/dist/capability/manifest.d.ts.map +1 -0
  33. package/dist/capability/manifest.js +356 -0
  34. package/dist/capability/secretOrigin.d.ts +121 -0
  35. package/dist/capability/secretOrigin.d.ts.map +1 -0
  36. package/dist/capability/secretOrigin.js +134 -0
  37. package/dist/capability/settings.d.ts +119 -0
  38. package/dist/capability/settings.d.ts.map +1 -0
  39. package/dist/capability/settings.js +66 -0
  40. package/dist/capability/validateBindings.d.ts +4 -0
  41. package/dist/capability/validateBindings.d.ts.map +1 -0
  42. package/dist/capability/validateBindings.js +34 -0
  43. package/dist/capability/vanishingKey.d.ts +31 -0
  44. package/dist/capability/vanishingKey.d.ts.map +1 -0
  45. package/dist/capability/vanishingKey.js +79 -0
  46. package/dist/controlPlane/audit/actions.d.ts +70 -0
  47. package/dist/controlPlane/audit/actions.d.ts.map +1 -0
  48. package/dist/controlPlane/audit/actions.js +76 -0
  49. package/dist/controlPlane/capability.d.ts +47 -0
  50. package/dist/controlPlane/capability.d.ts.map +1 -0
  51. package/dist/controlPlane/capability.js +138 -0
  52. package/dist/controlPlane/config/config.d.ts +19 -0
  53. package/dist/controlPlane/config/config.d.ts.map +1 -0
  54. package/dist/controlPlane/config/config.js +85 -0
  55. package/dist/controlPlane/context.d.ts +27 -0
  56. package/dist/controlPlane/context.d.ts.map +1 -0
  57. package/dist/controlPlane/context.js +29 -0
  58. package/dist/controlPlane/data/connection.d.ts +79 -0
  59. package/dist/controlPlane/data/connection.d.ts.map +1 -0
  60. package/dist/controlPlane/data/connection.js +55 -0
  61. package/dist/controlPlane/data/keyLifecycle.d.ts +62 -0
  62. package/dist/controlPlane/data/keyLifecycle.d.ts.map +1 -0
  63. package/dist/controlPlane/data/keyLifecycle.js +126 -0
  64. package/dist/controlPlane/data/replay.d.ts +18 -0
  65. package/dist/controlPlane/data/replay.d.ts.map +1 -0
  66. package/dist/controlPlane/data/replay.js +20 -0
  67. package/dist/controlPlane/data/tables.d.ts +34 -0
  68. package/dist/controlPlane/data/tables.d.ts.map +1 -0
  69. package/dist/controlPlane/data/tables.js +37 -0
  70. package/dist/controlPlane/discovery/adminRoute.d.ts +313 -0
  71. package/dist/controlPlane/discovery/adminRoute.d.ts.map +1 -0
  72. package/dist/controlPlane/discovery/adminRoute.js +136 -0
  73. package/dist/controlPlane/discovery/configuration.d.ts +108 -0
  74. package/dist/controlPlane/discovery/configuration.d.ts.map +1 -0
  75. package/dist/controlPlane/discovery/configuration.js +187 -0
  76. package/dist/controlPlane/discovery/drift.d.ts +64 -0
  77. package/dist/controlPlane/discovery/drift.d.ts.map +1 -0
  78. package/dist/controlPlane/discovery/drift.js +58 -0
  79. package/dist/controlPlane/discovery/health.d.ts +99 -0
  80. package/dist/controlPlane/discovery/health.d.ts.map +1 -0
  81. package/dist/controlPlane/discovery/health.js +151 -0
  82. package/dist/controlPlane/discovery/healthSummary.d.ts +236 -0
  83. package/dist/controlPlane/discovery/healthSummary.d.ts.map +1 -0
  84. package/dist/controlPlane/discovery/healthSummary.js +278 -0
  85. package/dist/controlPlane/error/errors.d.ts +67 -0
  86. package/dist/controlPlane/error/errors.d.ts.map +1 -0
  87. package/dist/controlPlane/error/errors.js +79 -0
  88. package/dist/controlPlane/http/cors.d.ts +112 -0
  89. package/dist/controlPlane/http/cors.d.ts.map +1 -0
  90. package/dist/controlPlane/http/cors.js +192 -0
  91. package/dist/controlPlane/http/guard.d.ts +77 -0
  92. package/dist/controlPlane/http/guard.d.ts.map +1 -0
  93. package/dist/controlPlane/http/guard.js +142 -0
  94. package/dist/controlPlane/http/handlers.d.ts +179 -0
  95. package/dist/controlPlane/http/handlers.d.ts.map +1 -0
  96. package/dist/controlPlane/http/handlers.js +245 -0
  97. package/dist/controlPlane/http/responses.d.ts +99 -0
  98. package/dist/controlPlane/http/responses.d.ts.map +1 -0
  99. package/dist/controlPlane/http/responses.js +63 -0
  100. package/dist/controlPlane/http/routes.d.ts +40 -0
  101. package/dist/controlPlane/http/routes.d.ts.map +1 -0
  102. package/dist/controlPlane/http/routes.js +83 -0
  103. package/dist/controlPlane/http/schemas.d.ts +39 -0
  104. package/dist/controlPlane/http/schemas.d.ts.map +1 -0
  105. package/dist/controlPlane/http/schemas.js +31 -0
  106. package/dist/controlPlane/http/verify.d.ts +84 -0
  107. package/dist/controlPlane/http/verify.d.ts.map +1 -0
  108. package/dist/controlPlane/http/verify.js +65 -0
  109. package/dist/controlPlane/migrations/0001_init.d.ts +51 -0
  110. package/dist/controlPlane/migrations/0001_init.d.ts.map +1 -0
  111. package/dist/controlPlane/migrations/0001_init.js +65 -0
  112. package/dist/controlPlane/replay/d1Guard.d.ts +29 -0
  113. package/dist/controlPlane/replay/d1Guard.d.ts.map +1 -0
  114. package/dist/controlPlane/replay/d1Guard.js +39 -0
  115. package/dist/controlPlane/replay/guard.d.ts +52 -0
  116. package/dist/controlPlane/replay/guard.d.ts.map +1 -0
  117. package/dist/controlPlane/replay/guard.js +0 -0
  118. package/dist/controlPlane/replay/kvGuard.d.ts +99 -0
  119. package/dist/controlPlane/replay/kvGuard.d.ts.map +1 -0
  120. package/dist/controlPlane/replay/kvGuard.js +101 -0
  121. package/dist/controlPlane/scope/scope.d.ts +68 -0
  122. package/dist/controlPlane/scope/scope.d.ts.map +1 -0
  123. package/dist/controlPlane/scope/scope.js +63 -0
  124. package/dist/controlPlane/token/base64url.d.ts +10 -0
  125. package/dist/controlPlane/token/base64url.d.ts.map +1 -0
  126. package/dist/controlPlane/token/base64url.js +48 -0
  127. package/dist/controlPlane/token/claims.d.ts +83 -0
  128. package/dist/controlPlane/token/claims.d.ts.map +1 -0
  129. package/dist/controlPlane/token/claims.js +86 -0
  130. package/dist/controlPlane/token/digest.d.ts +44 -0
  131. package/dist/controlPlane/token/digest.d.ts.map +1 -0
  132. package/dist/controlPlane/token/digest.js +56 -0
  133. package/dist/controlPlane/token/jws.d.ts +52 -0
  134. package/dist/controlPlane/token/jws.d.ts.map +1 -0
  135. package/dist/controlPlane/token/jws.js +65 -0
  136. package/dist/controlPlane/token/mint.d.ts +56 -0
  137. package/dist/controlPlane/token/mint.d.ts.map +1 -0
  138. package/dist/controlPlane/token/mint.js +55 -0
  139. package/dist/controlPlane/wire.d.ts +122 -0
  140. package/dist/controlPlane/wire.d.ts.map +1 -0
  141. package/dist/controlPlane/wire.js +123 -0
  142. package/dist/createBackend.d.ts +58 -0
  143. package/dist/createBackend.d.ts.map +1 -0
  144. package/dist/createBackend.js +170 -0
  145. package/dist/createEntrypoint.d.ts +53 -0
  146. package/dist/createEntrypoint.d.ts.map +1 -0
  147. package/dist/createEntrypoint.js +52 -0
  148. package/dist/data/boundParameters.d.ts +83 -0
  149. package/dist/data/boundParameters.d.ts.map +1 -0
  150. package/dist/data/boundParameters.js +162 -0
  151. package/dist/data/codecs.d.ts +34 -0
  152. package/dist/data/codecs.d.ts.map +1 -0
  153. package/dist/data/codecs.js +135 -0
  154. package/dist/data/cursor.d.ts +81 -0
  155. package/dist/data/cursor.d.ts.map +1 -0
  156. package/dist/data/cursor.js +104 -0
  157. package/dist/data/databases.d.ts +55 -0
  158. package/dist/data/databases.d.ts.map +1 -0
  159. package/dist/data/databases.js +32 -0
  160. package/dist/data/db.d.ts +42 -0
  161. package/dist/data/db.d.ts.map +1 -0
  162. package/dist/data/db.js +24 -0
  163. package/dist/data/withD1Retry.d.ts +91 -0
  164. package/dist/data/withD1Retry.d.ts.map +1 -0
  165. package/dist/data/withD1Retry.js +152 -0
  166. package/dist/entitlement/entitlement.d.ts +118 -0
  167. package/dist/entitlement/entitlement.d.ts.map +1 -0
  168. package/dist/entitlement/entitlement.js +59 -0
  169. package/dist/entitlement/gateScan.d.ts +26 -0
  170. package/dist/entitlement/gateScan.d.ts.map +1 -0
  171. package/dist/entitlement/gateScan.js +96 -0
  172. package/dist/entitlement/require.d.ts +12 -0
  173. package/dist/entitlement/require.d.ts.map +1 -0
  174. package/dist/entitlement/require.js +123 -0
  175. package/dist/env/ambient.d.ts +52 -0
  176. package/dist/env/ambient.d.ts.map +1 -0
  177. package/dist/env/ambient.js +35 -0
  178. package/dist/env/ci.d.ts +36 -0
  179. package/dist/env/ci.d.ts.map +1 -0
  180. package/dist/env/ci.js +40 -0
  181. package/dist/env/stem.d.ts +23 -0
  182. package/dist/env/stem.d.ts.map +1 -0
  183. package/dist/env/stem.js +29 -0
  184. package/dist/error/cause.d.ts +143 -0
  185. package/dist/error/cause.d.ts.map +1 -0
  186. package/dist/error/cause.js +192 -0
  187. package/dist/error/client.d.ts +35 -0
  188. package/dist/error/client.d.ts.map +1 -0
  189. package/dist/error/client.js +38 -0
  190. package/dist/error/extend.d.ts +101 -0
  191. package/dist/error/extend.d.ts.map +1 -0
  192. package/dist/error/extend.js +76 -0
  193. package/dist/error/http.d.ts +1516 -0
  194. package/dist/error/http.d.ts.map +1 -0
  195. package/dist/error/http.js +72 -0
  196. package/dist/error/payload.d.ts +3034 -0
  197. package/dist/error/payload.d.ts.map +1 -0
  198. package/dist/error/payload.js +1110 -0
  199. package/dist/error/pithyError.d.ts +154 -0
  200. package/dist/error/pithyError.d.ts.map +1 -0
  201. package/dist/error/pithyError.js +197 -0
  202. package/dist/error/terminal.d.ts +28 -0
  203. package/dist/error/terminal.d.ts.map +1 -0
  204. package/dist/error/terminal.js +33 -0
  205. package/dist/http/authContext.d.ts +21 -0
  206. package/dist/http/authContext.d.ts.map +1 -0
  207. package/dist/http/authContext.js +23 -0
  208. package/dist/http/routeContract.d.ts +39 -0
  209. package/dist/http/routeContract.d.ts.map +1 -0
  210. package/dist/http/routeContract.js +82 -0
  211. package/dist/http/sameOrigin.d.ts +47 -0
  212. package/dist/http/sameOrigin.d.ts.map +1 -0
  213. package/dist/http/sameOrigin.js +24 -0
  214. package/dist/http/signedWebhook.d.ts +225 -0
  215. package/dist/http/signedWebhook.d.ts.map +1 -0
  216. package/dist/http/signedWebhook.js +247 -0
  217. package/dist/http/validation.d.ts +37 -0
  218. package/dist/http/validation.d.ts.map +1 -0
  219. package/dist/http/validation.js +14 -0
  220. package/dist/http/verification.d.ts +10 -0
  221. package/dist/http/verification.d.ts.map +1 -0
  222. package/dist/http/verification.js +17 -0
  223. package/dist/i18n/acceptLanguage.d.ts +22 -0
  224. package/dist/i18n/acceptLanguage.d.ts.map +1 -0
  225. package/dist/i18n/acceptLanguage.js +55 -0
  226. package/dist/i18n/catalog.d.ts +39 -0
  227. package/dist/i18n/catalog.d.ts.map +1 -0
  228. package/dist/i18n/catalog.js +57 -0
  229. package/dist/i18n/locale.d.ts +74 -0
  230. package/dist/i18n/locale.d.ts.map +1 -0
  231. package/dist/i18n/locale.js +109 -0
  232. package/dist/i18n/localeMarker.d.ts +29 -0
  233. package/dist/i18n/localeMarker.d.ts.map +1 -0
  234. package/dist/i18n/localeMarker.js +112 -0
  235. package/dist/i18n/match.d.ts +26 -0
  236. package/dist/i18n/match.d.ts.map +1 -0
  237. package/dist/i18n/match.js +88 -0
  238. package/dist/i18n/registry.d.ts +25 -0
  239. package/dist/i18n/registry.d.ts.map +1 -0
  240. package/dist/i18n/registry.js +51 -0
  241. package/dist/i18n/translator.d.ts +107 -0
  242. package/dist/i18n/translator.d.ts.map +1 -0
  243. package/dist/i18n/translator.js +80 -0
  244. package/dist/index.d.ts +32 -0
  245. package/dist/index.d.ts.map +1 -0
  246. package/dist/index.js +17 -0
  247. package/dist/kv/kv.d.ts +166 -0
  248. package/dist/kv/kv.d.ts.map +1 -0
  249. package/dist/kv/kv.js +261 -0
  250. package/dist/kv/namespaces.d.ts +58 -0
  251. package/dist/kv/namespaces.d.ts.map +1 -0
  252. package/dist/kv/namespaces.js +40 -0
  253. package/dist/logger/local.d.ts +41 -0
  254. package/dist/logger/local.d.ts.map +1 -0
  255. package/dist/logger/local.js +45 -0
  256. package/dist/logger/logger.d.ts +56 -0
  257. package/dist/logger/logger.d.ts.map +1 -0
  258. package/dist/logger/logger.js +83 -0
  259. package/dist/logger/record.d.ts +919 -0
  260. package/dist/logger/record.d.ts.map +1 -0
  261. package/dist/logger/record.js +79 -0
  262. package/dist/logger/worker.d.ts +74 -0
  263. package/dist/logger/worker.d.ts.map +1 -0
  264. package/dist/logger/worker.js +54 -0
  265. package/dist/migrations/batch.d.ts +10 -0
  266. package/dist/migrations/batch.d.ts.map +1 -0
  267. package/dist/migrations/batch.js +193 -0
  268. package/dist/migrations/bookkeeping.d.ts +24 -0
  269. package/dist/migrations/bookkeeping.d.ts.map +1 -0
  270. package/dist/migrations/bookkeeping.js +57 -0
  271. package/dist/migrations/owner.d.ts +41 -0
  272. package/dist/migrations/owner.d.ts.map +1 -0
  273. package/dist/migrations/owner.js +105 -0
  274. package/dist/migrations/registry.d.ts +36 -0
  275. package/dist/migrations/registry.d.ts.map +1 -0
  276. package/dist/migrations/registry.js +70 -0
  277. package/dist/migrations/runner.d.ts +67 -0
  278. package/dist/migrations/runner.d.ts.map +1 -0
  279. package/dist/migrations/runner.js +218 -0
  280. package/dist/naming/domains.d.ts +108 -0
  281. package/dist/naming/domains.d.ts.map +1 -0
  282. package/dist/naming/domains.js +156 -0
  283. package/dist/naming/environment.d.ts +118 -0
  284. package/dist/naming/environment.d.ts.map +1 -0
  285. package/dist/naming/environment.js +190 -0
  286. package/dist/naming/feature.d.ts +68 -0
  287. package/dist/naming/feature.d.ts.map +1 -0
  288. package/dist/naming/feature.js +106 -0
  289. package/dist/naming/limits.d.ts +229 -0
  290. package/dist/naming/limits.d.ts.map +1 -0
  291. package/dist/naming/limits.js +187 -0
  292. package/dist/naming/provisionScope.d.ts +91 -0
  293. package/dist/naming/provisionScope.d.ts.map +1 -0
  294. package/dist/naming/provisionScope.js +65 -0
  295. package/dist/naming/resource.d.ts +169 -0
  296. package/dist/naming/resource.d.ts.map +1 -0
  297. package/dist/naming/resource.js +220 -0
  298. package/dist/naming/resourceNames.d.ts +83 -0
  299. package/dist/naming/resourceNames.d.ts.map +1 -0
  300. package/dist/naming/resourceNames.js +102 -0
  301. package/dist/naming/segment.d.ts +29 -0
  302. package/dist/naming/segment.d.ts.map +1 -0
  303. package/dist/naming/segment.js +31 -0
  304. package/dist/projection/asRead.d.ts +72 -0
  305. package/dist/projection/asRead.d.ts.map +1 -0
  306. package/dist/projection/asRead.js +169 -0
  307. package/dist/projection/published.d.ts +95 -0
  308. package/dist/projection/published.d.ts.map +1 -0
  309. package/dist/projection/published.js +114 -0
  310. package/dist/schema/describedness.d.ts +55 -0
  311. package/dist/schema/describedness.d.ts.map +1 -0
  312. package/dist/schema/describedness.js +180 -0
  313. package/dist/seed/compose.d.ts +41 -0
  314. package/dist/seed/compose.d.ts.map +1 -0
  315. package/dist/seed/compose.js +51 -0
  316. package/dist/seed/devLogin.d.ts +50 -0
  317. package/dist/seed/devLogin.d.ts.map +1 -0
  318. package/dist/seed/devLogin.js +52 -0
  319. package/dist/seed/exampleIdentities.d.ts +58 -0
  320. package/dist/seed/exampleIdentities.d.ts.map +1 -0
  321. package/dist/seed/exampleIdentities.js +26 -0
  322. package/dist/seed/metadata.d.ts +20 -0
  323. package/dist/seed/metadata.d.ts.map +1 -0
  324. package/dist/seed/metadata.js +27 -0
  325. package/dist/seed/seed.d.ts +264 -0
  326. package/dist/seed/seed.d.ts.map +1 -0
  327. package/dist/seed/seed.js +37 -0
  328. package/dist/seed/seededRows.d.ts +26 -0
  329. package/dist/seed/seededRows.d.ts.map +1 -0
  330. package/dist/seed/seededRows.js +20 -0
  331. package/dist/seed/writeD1.d.ts +43 -0
  332. package/dist/seed/writeD1.d.ts.map +1 -0
  333. package/dist/seed/writeD1.js +73 -0
  334. package/dist/seed/writeKv.d.ts +29 -0
  335. package/dist/seed/writeKv.d.ts.map +1 -0
  336. package/dist/seed/writeKv.js +63 -0
  337. package/dist/semver/semver.d.ts +62 -0
  338. package/dist/semver/semver.d.ts.map +1 -0
  339. package/dist/semver/semver.js +137 -0
  340. package/dist/text/comments.d.ts +62 -0
  341. package/dist/text/comments.d.ts.map +1 -0
  342. package/dist/text/comments.js +161 -0
  343. package/dist/version.generated.d.ts +5 -0
  344. package/dist/version.generated.d.ts.map +1 -0
  345. package/dist/version.generated.js +7 -0
  346. package/dist/worker/health.d.ts +39 -0
  347. package/dist/worker/health.d.ts.map +1 -0
  348. package/dist/worker/health.js +41 -0
  349. package/dist/worker/identity.d.ts +191 -0
  350. package/dist/worker/identity.d.ts.map +1 -0
  351. package/dist/worker/identity.js +162 -0
  352. package/dist/workflow/bindings.d.ts +41 -0
  353. package/dist/workflow/bindings.d.ts.map +1 -0
  354. package/dist/workflow/bindings.js +53 -0
  355. package/dist/workflow/dispatch.d.ts +98 -0
  356. package/dist/workflow/dispatch.d.ts.map +1 -0
  357. package/dist/workflow/dispatch.js +148 -0
  358. package/dist/workflow/dispatchRoute.d.ts +80 -0
  359. package/dist/workflow/dispatchRoute.d.ts.map +1 -0
  360. package/dist/workflow/dispatchRoute.js +134 -0
  361. package/dist/workflow/faults.d.ts +97 -0
  362. package/dist/workflow/faults.d.ts.map +1 -0
  363. package/dist/workflow/faults.js +111 -0
  364. package/dist/workflow/host.d.ts +176 -0
  365. package/dist/workflow/host.d.ts.map +1 -0
  366. package/dist/workflow/host.js +116 -0
  367. package/dist/workflow/hostEntry.d.ts +50 -0
  368. package/dist/workflow/hostEntry.d.ts.map +1 -0
  369. package/dist/workflow/hostEntry.js +24 -0
  370. package/dist/workflow/hostEnv.d.ts +143 -0
  371. package/dist/workflow/hostEnv.d.ts.map +1 -0
  372. package/dist/workflow/hostEnv.js +170 -0
  373. package/dist/workflow/loopback.d.ts +52 -0
  374. package/dist/workflow/loopback.d.ts.map +1 -0
  375. package/dist/workflow/loopback.js +76 -0
  376. package/dist/workflow/naming.d.ts +79 -0
  377. package/dist/workflow/naming.d.ts.map +1 -0
  378. package/dist/workflow/naming.js +138 -0
  379. package/dist/workflow/register.d.ts +19 -0
  380. package/dist/workflow/register.d.ts.map +1 -0
  381. package/dist/workflow/register.js +40 -0
  382. package/dist/workflow/schemas.d.ts +44 -0
  383. package/dist/workflow/schemas.d.ts.map +1 -0
  384. package/dist/workflow/schemas.js +43 -0
  385. package/dist/workflow/spec.d.ts +81 -0
  386. package/dist/workflow/spec.d.ts.map +1 -0
  387. package/dist/workflow/spec.js +0 -0
  388. package/dist/workflow/stepMessage.d.ts +122 -0
  389. package/dist/workflow/stepMessage.d.ts.map +1 -0
  390. package/dist/workflow/stepMessage.js +152 -0
  391. package/package.json +20 -9
  392. package/src/capability/manifest.ts +21 -0
  393. package/src/version.generated.ts +1 -1
@@ -0,0 +1,264 @@
1
+ import type { z } from "zod";
2
+ import type { KvStoreSpec } from "../kv/namespaces";
3
+ import type { SeededRows } from "./seededRows";
4
+ /**
5
+ * The seed contract: the pure, schema-bound shapes a capability (or the app) contributes to
6
+ * `pithy seed`. A capability declares its fixtures as {@link SeedSet}s on `Capability.seeds`;
7
+ * `composeSeeds` merges every capability's sets library-before-app, and the CLI writes them,
8
+ * idempotently and non-destructively, into the environment named by `--env`.
9
+ *
10
+ * Rows and entries are authored as **app-shape values** (the decoded, `z.output` side). The
11
+ * write-time `schema.encode(row)` in `seedD1Group` is the single Zod validation boundary — a bad
12
+ * fixture fails there, before any write. Core defines only the types and the pure write/compose
13
+ * logic; filesystem work (media bytes, UUID write-back) lives in the CLI.
14
+ */
15
+ /**
16
+ * An environment name a set may be seeded into (`dev`, `staging`, `production`, or any custom
17
+ * environment). A set lists the environments it is allowed into on {@link SeedSet.environments};
18
+ * `production` is only ever seeded when a set lists it explicitly.
19
+ */
20
+ export type SeedEnv = string;
21
+ /**
22
+ * One D1 seed group: a batch of app-shape rows for a single table in a single named database.
23
+ * `database` and `table` match the names a capability declares in its `databases` map; the row
24
+ * schema is resolved from the composed databases registry at write time (the fixture never
25
+ * redeclares it). `rows` are `z.output` (app shape) values — re-encoded and validated on write.
26
+ */
27
+ export interface D1SeedGroup<Table extends z.ZodType = z.ZodType> {
28
+ /** The named database this table lives in (matches a `databases` key, e.g. "app", "analytics"). */
29
+ database: string;
30
+ /** The table name to seed (the un-prefixed logical name used in query code). */
31
+ table: string;
32
+ /** The rows to insert, as app-shape (`z.output`) values — encoded + validated at write time. */
33
+ rows: readonly z.output<Table>[];
34
+ }
35
+ /**
36
+ * One KV seed entry: an app-shape key/value (and optional metadata) for a store. The values are
37
+ * the store's input shapes; {@link TypedKv.put} validates each on write.
38
+ */
39
+ export interface KvSeedEntry<V extends z.ZodType = z.ZodType, K extends z.ZodObject = z.ZodObject, M extends z.ZodType = z.ZodType> {
40
+ /** The structured key segments, validated by the store's key schema. */
41
+ key: z.input<K>;
42
+ /** The value to store, validated by the store's value schema. */
43
+ value: z.input<V>;
44
+ /** Optional metadata, validated by the store's metadata schema. */
45
+ metadata?: z.input<M>;
46
+ }
47
+ /**
48
+ * One KV seed group: a batch of entries for a single named store within a named namespace.
49
+ * `namespace` and `store` match the names a capability declares in its `kvNamespaces` map.
50
+ */
51
+ export interface KvSeedGroup<V extends z.ZodType = z.ZodType, K extends z.ZodObject = z.ZodObject, M extends z.ZodType = z.ZodType> {
52
+ /** The named KV namespace this store lives in (matches a `kvNamespaces` key). */
53
+ namespace: string;
54
+ /** The store name within the namespace to seed. */
55
+ store: string;
56
+ /** The entries to write — each validated by the store on put. */
57
+ entries: readonly KvSeedEntry<V, K, M>[];
58
+ }
59
+ /**
60
+ * One R2 object to seed: raw bytes (or a string) under a key in a bound bucket. R2 has no schema
61
+ * layer, so the payload is opaque; the CLI writes it via the bucket manager for the target env.
62
+ */
63
+ export interface R2SeedItem {
64
+ /** The R2 binding name in the Worker env this object lives in. */
65
+ binding: string;
66
+ /** The object key. */
67
+ key: string;
68
+ /** The object bytes, or a string body. */
69
+ body: Uint8Array | string;
70
+ /** The object's content type (e.g. "image/png"). */
71
+ contentType: string;
72
+ /** Optional custom metadata stored alongside the object. */
73
+ metadata?: Record<string, string>;
74
+ }
75
+ /**
76
+ * One media asset to seed into the shared Cloudflare Images or Stream store. Core defines only the
77
+ * type — the filesystem read (`file`), the upload, and the UUID write-back (`ref`) run in the CLI.
78
+ *
79
+ * `once` (the default) uploads on the first run and records the minted UUID in the `ref` sidecar,
80
+ * so later runs skip the upload and reference the recorded id. `always` re-uploads every run,
81
+ * scoped by metadata, and never writes a UUID back.
82
+ */
83
+ export interface MediaSeedItem {
84
+ /** Which shared asset store to upload to. */
85
+ store: "images" | "stream";
86
+ /** Upload policy: `once` (upload + record the UUID) or `always` (re-upload each run). */
87
+ mode: "once" | "always";
88
+ /**
89
+ * Path to the asset bytes. Resolved against the set's {@link SeedSet.baseDir} (the seed module's own
90
+ * directory, set with `import.meta.dirname`), or the project root when the set declares none. Read by
91
+ * the CLI. An absolute path is used as-is.
92
+ */
93
+ file: string;
94
+ /**
95
+ * Path to the JSON sidecar that records the minted UUID (for `once`). Resolved the same way as
96
+ * {@link MediaSeedItem.file} — against the set's {@link SeedSet.baseDir} or the project root.
97
+ * Read/written by the CLI. An absolute path is used as-is.
98
+ */
99
+ ref: string;
100
+ /** Optional custom metadata merged with the standard asset metadata block on upload. */
101
+ metadata?: Record<string, string>;
102
+ /**
103
+ * Optional D1 asset row (in `database`.`table`) that references the minted UUID. Only valid with
104
+ * `mode: "once"`: the row is keyed by the stable, recorded UUID, so an `always` asset — which mints
105
+ * a fresh UUID every run — cannot own a stable record. The CLI rejects `always` + `record`.
106
+ */
107
+ record?: {
108
+ /** The named database the asset row lives in. */
109
+ database: string;
110
+ /** The table the asset row is written to. */
111
+ table: string;
112
+ /** The app-shape row — the CLI fills in the minted UUID before writing it. */
113
+ row: unknown;
114
+ };
115
+ }
116
+ /**
117
+ * A transient file a prepared set asks the CLI to write, under the project's gitignored `logs/`.
118
+ *
119
+ * The path is not the author's choice: a set names the file, never the directory, so a fixture can never
120
+ * put a run artifact somewhere committable. The one artifact that exists today is the dev login
121
+ * (`DEV_LOGIN_PATH`), which holds a live session cookie — hence both halves of that rule.
122
+ */
123
+ export interface SeedArtifact {
124
+ /** The file name within the project's `logs/` directory (no directory separators). */
125
+ file: string;
126
+ /** The file's contents, written verbatim after the set's rows land. */
127
+ contents: string;
128
+ }
129
+ /**
130
+ * What a run gives {@link SeedSet.prepare} so it can compute the fixtures it cannot state statically.
131
+ *
132
+ * Deliberately narrow. `secret` is the only I/O the set performs, and it is the reason the hook exists: a
133
+ * fixture that must
134
+ * agree with what the running app will verify — a signed cookie, a derived id — needs the same secret the
135
+ * app reads, and a static row cannot hold one. Everything else is passed in already-read, so a capability
136
+ * never touches the filesystem: a capability module is bundled into the Worker, and `node:fs` there is a
137
+ * build error rather than a possibility. For the same reason `seeded` is the composed plan rather than a
138
+ * database handle — a prepared set answers "does this row exist" from the run, never from a query.
139
+ */
140
+ export interface SeedPrepareContext {
141
+ /** The environment being seeded — the same value the set's `environments` allowed. */
142
+ env: string;
143
+ /** The project name (the root `pithy.config.ts` `name`), for messages and per-project lookups. */
144
+ project: string;
145
+ /**
146
+ * Where this Worker answers locally — `http://localhost:8807` and the like. `null` outside `dev`, and
147
+ * `null` in a checkout that was never allocated a port block.
148
+ *
149
+ * The one address a fixture cannot write down. A dev port is *allocated*, not configured: a checkout
150
+ * reserves a block and pins one port per Worker into `.dev.config.json`, so `http://localhost:8787` is
151
+ * right in the first checkout on a machine and wrong in every other one. A set that has to register a
152
+ * self-connection had nothing to ask, so it hard-coded that literal and every second checkout addressed
153
+ * the first one's Worker. This is the string the run was actually allocated — the same one `pithy dev`
154
+ * exports to this Worker's siblings as `<STEM>_ORIGIN`, read back verbatim and never recomposed from
155
+ * the port.
156
+ *
157
+ * **An address, not an identity.** It says where to reach this Worker, on this machine, now. Anything a
158
+ * later check compares against a stored value — an issuer, an audience, a signing scope — must not be
159
+ * built from it: the same project answers on a different port in every checkout and a different origin
160
+ * in every environment, so a row minted against one is unverifiable against the next. Reachability
161
+ * moves. Identity must not.
162
+ *
163
+ * **`null` is an answer, never a guess.** A plain clone that has never run `pithy dev`, a Worker added
164
+ * after the block was pinned, or any environment but `dev` — a deployed environment's address is
165
+ * declared rather than allocated, and `pithy env` is what answers it. An invented origin would be
166
+ * indistinguishable from a real one, so a set that cannot work without one refuses and says so.
167
+ */
168
+ origin: string | null;
169
+ /**
170
+ * Read one of this environment's secrets by name, or `undefined` when it is not set. Local dev resolves
171
+ * every secret from `.dev.vars`, so this answers there; a deployed environment's secrets are not on the
172
+ * operator's disk, and a set that needs one must therefore be `dev`-only.
173
+ */
174
+ secret: (name: string) => Promise<string | undefined>;
175
+ /**
176
+ * The developer's machine-local preferences for this project, read from the Pithy config directory
177
+ * (`~/.config/pithy/<project>/dev.json`, or `%APPDATA%\pithy\<project>\dev.json` on Windows), parsed but
178
+ * unvalidated — `undefined` when the file is absent or unreadable. It is a per-machine opt-in, outside
179
+ * the repo, so two developers on one checkout can differ and neither has to commit anything. The set
180
+ * validates the shape it expects.
181
+ */
182
+ preferences: unknown;
183
+ /**
184
+ * The rows this run declares for one `database`.`table`, from every composed set — this one included, and
185
+ * every other capability's and the app's. It is how a fixture that must reference a row it does not own
186
+ * (a session for a seeded user) finds that row without hard-coding a roster or opening D1. Statically
187
+ * declared rows only; see {@link SeededRows}.
188
+ */
189
+ seeded: SeededRows;
190
+ }
191
+ /**
192
+ * What {@link SeedSet.prepare} contributes: more of the same groups a static set declares, plus any
193
+ * transient artifacts. The groups are appended to the set's static ones and written through the identical
194
+ * validated path; the artifacts are written afterwards, so a file never claims a row that failed to land.
195
+ */
196
+ export interface SeedPreparation {
197
+ /** D1 row groups computed for this run. */
198
+ d1?: readonly D1SeedGroup[];
199
+ /** KV entry groups computed for this run. */
200
+ kv?: readonly KvSeedGroup[];
201
+ /** Transient files to write under the project's `logs/` once the rows are in. */
202
+ artifacts?: readonly SeedArtifact[];
203
+ }
204
+ /**
205
+ * One named, ordered batch of fixtures a capability contributes to `pithy seed`. Sets are composed
206
+ * library-before-app by `order` (like migrations) and each declares the environments it may be
207
+ * seeded into — the first layer of the env-safety model. `production` is seeded only when a set
208
+ * lists it explicitly.
209
+ */
210
+ export interface SeedSet {
211
+ /** Stable, unique-per-capability name. Namespaced by capability name when composed. */
212
+ name: string;
213
+ /** Sort order across capabilities (libraries low, app high). Ties break on the namespaced key. */
214
+ order: number;
215
+ /** The environments this set may be seeded into. A set is skipped for any env it does not list. */
216
+ environments: readonly SeedEnv[];
217
+ /**
218
+ * The directory the set's relative media paths (`MediaSeedItem.file` / `.ref`) resolve against —
219
+ * the seed module's own directory, so fixture bytes sit next to the module that declares them.
220
+ * Author it as `baseDir: import.meta.dirname`. When omitted, media paths resolve against the
221
+ * project root instead (a legacy fallback, rarely what you want once a set ships media).
222
+ */
223
+ baseDir?: string;
224
+ /** Whether this is an example/demo set — composed only when the project enables `includeExamples`. */
225
+ example?: boolean;
226
+ /** D1 row groups. */
227
+ d1?: readonly D1SeedGroup[];
228
+ /** KV entry groups. */
229
+ kv?: readonly KvSeedGroup[];
230
+ /** R2 objects. */
231
+ r2?: readonly R2SeedItem[];
232
+ /** Media assets (Images/Stream), uploaded by the CLI. */
233
+ media?: readonly MediaSeedItem[];
234
+ /**
235
+ * Late-bound fixtures: run once per Worker, just before this set's rows are written, to compute what a
236
+ * static literal cannot hold. Its groups are appended to the static ones and go through the same
237
+ * `schema.encode` validation; its artifacts are written after.
238
+ *
239
+ * A dry run never calls it. A plan touches no backend and needs no credentials, so a prepared set
240
+ * reports nothing there rather than reading a secret to describe work it is not going to do.
241
+ */
242
+ prepare?: (context: SeedPrepareContext) => Promise<SeedPreparation>;
243
+ }
244
+ /**
245
+ * Author a seed set. A pass-through that anchors the {@link SeedSet} type at the author site (the
246
+ * peer of `defineCapability`); the real invariant checks (namespacing, ordering, env filtering)
247
+ * run in `composeSeeds`, and the write-time validation runs in `seedD1Group`. Use {@link d1SeedGroup}
248
+ * and {@link kvSeedGroup} to bind rows/entries to their schemas at compile time.
249
+ */
250
+ export declare function defineSeed(input: SeedSet): SeedSet;
251
+ /**
252
+ * Author a typed D1 seed group. `schema` is a compile-time carrier only — it binds `rows` to the
253
+ * table's `z.output` (app) shape so a mistyped fixture fails to compile; it is not stored on the
254
+ * group (the writer resolves the schema from the composed databases registry). Mirrors
255
+ * `createDatabase`'s type-only `map` argument.
256
+ */
257
+ export declare function d1SeedGroup<Table extends z.ZodType>(database: string, table: string, schema: Table, rows: readonly z.output<Table>[]): D1SeedGroup<Table>;
258
+ /**
259
+ * Author a typed KV seed group. `spec` is a compile-time carrier only — it binds each entry's
260
+ * `key`/`value`/`metadata` to the store's schemas so a mistyped fixture fails to compile; it is not
261
+ * stored on the group (the writer supplies the live store).
262
+ */
263
+ export declare function kvSeedGroup<V extends z.ZodType, K extends z.ZodObject, M extends z.ZodType>(namespace: string, store: string, spec: KvStoreSpec<V, K, M>, entries: readonly KvSeedEntry<V, K, M>[]): KvSeedGroup<V, K, M>;
264
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/seed/seed.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,37 @@
1
+ //#region src/seed/seed.ts
2
+ /**
3
+ * Author a seed set. A pass-through that anchors the {@link SeedSet} type at the author site (the
4
+ * peer of `defineCapability`); the real invariant checks (namespacing, ordering, env filtering)
5
+ * run in `composeSeeds`, and the write-time validation runs in `seedD1Group`. Use {@link d1SeedGroup}
6
+ * and {@link kvSeedGroup} to bind rows/entries to their schemas at compile time.
7
+ */
8
+ function defineSeed(input) {
9
+ return input;
10
+ }
11
+ /**
12
+ * Author a typed D1 seed group. `schema` is a compile-time carrier only — it binds `rows` to the
13
+ * table's `z.output` (app) shape so a mistyped fixture fails to compile; it is not stored on the
14
+ * group (the writer resolves the schema from the composed databases registry). Mirrors
15
+ * `createDatabase`'s type-only `map` argument.
16
+ */
17
+ function d1SeedGroup(database, table, schema, rows) {
18
+ return {
19
+ database,
20
+ table,
21
+ rows
22
+ };
23
+ }
24
+ /**
25
+ * Author a typed KV seed group. `spec` is a compile-time carrier only — it binds each entry's
26
+ * `key`/`value`/`metadata` to the store's schemas so a mistyped fixture fails to compile; it is not
27
+ * stored on the group (the writer supplies the live store).
28
+ */
29
+ function kvSeedGroup(namespace, store, spec, entries) {
30
+ return {
31
+ namespace,
32
+ store,
33
+ entries
34
+ };
35
+ }
36
+ //#endregion
37
+ export { d1SeedGroup, defineSeed, kvSeedGroup };
@@ -0,0 +1,26 @@
1
+ import type { SeedSet } from "./seed";
2
+ /**
3
+ * The run's own inventory: which rows a seed run declares, per table, before it writes any of them.
4
+ *
5
+ * It exists for the one class of fixture that has to agree with a row another set owns — a dev session for a
6
+ * seeded user, say. Such a set cannot hard-code the roster (the users may be an adopter's, not a library's)
7
+ * and must not read the database (a capability module is bundled into the Worker, where D1 is a binding it
8
+ * has no business opening during a seed). So the CLI hands it the composed registry it already holds in
9
+ * memory. It is a *plan*, not a query: no I/O, no credentials, and the same answer in a dry run.
10
+ */
11
+ /**
12
+ * Read the app-shape rows this run declares for one `database`.`table`, across every composed set. Empty
13
+ * when nothing seeds that table. Values are `unknown` on purpose — they cross into a capability that does
14
+ * not own the table, so the reader validates them with the schema it expects.
15
+ */
16
+ export type SeededRows = (database: string, table: string) => readonly unknown[];
17
+ /**
18
+ * Index every set's statically declared D1 rows into one lookup, in composed order.
19
+ *
20
+ * Statically declared, and only that. A prepared set's rows do not exist until its own `prepare` runs, and a
21
+ * media record's row has no id until the CLI mints one — reporting either would promise a row that may never
22
+ * land. A set that needs to be *seen* must therefore declare its rows as literals, which every user fixture
23
+ * does.
24
+ */
25
+ export declare function collectSeededRows(sets: readonly SeedSet[]): SeededRows;
26
+ //# sourceMappingURL=seededRows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seededRows.d.ts","sourceRoot":"","sources":["../../src/seed/seededRows.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,OAAO,EAAE,CAAC;AAEjF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,UAAU,CAUtE"}
@@ -0,0 +1,20 @@
1
+ //#region src/seed/seededRows.ts
2
+ /**
3
+ * Index every set's statically declared D1 rows into one lookup, in composed order.
4
+ *
5
+ * Statically declared, and only that. A prepared set's rows do not exist until its own `prepare` runs, and a
6
+ * media record's row has no id until the CLI mints one — reporting either would promise a row that may never
7
+ * land. A set that needs to be *seen* must therefore declare its rows as literals, which every user fixture
8
+ * does.
9
+ */
10
+ function collectSeededRows(sets) {
11
+ const index = /* @__PURE__ */ new Map();
12
+ for (const set of sets) for (const group of set.d1 ?? []) {
13
+ const tables = index.get(group.database) ?? /* @__PURE__ */ new Map();
14
+ index.set(group.database, tables);
15
+ tables.set(group.table, [...tables.get(group.table) ?? [], ...group.rows]);
16
+ }
17
+ return (database, table) => index.get(database)?.get(table) ?? [];
18
+ }
19
+ //#endregion
20
+ export { collectSeededRows };
@@ -0,0 +1,43 @@
1
+ import type { Kysely } from "kysely";
2
+ import { z } from "zod";
3
+ import type { D1SeedGroup } from "./seed";
4
+ /** Options for {@link seedD1Group}. */
5
+ export interface SeedD1Options {
6
+ /** Validate + count only; perform no write. */
7
+ dryRun?: boolean;
8
+ }
9
+ /** The outcome of seeding one D1 group. */
10
+ export interface SeedD1Result {
11
+ /** The table seeded. */
12
+ table: string;
13
+ /** The number of rows validated (and, unless `dryRun`, written). */
14
+ rows: number;
15
+ }
16
+ /**
17
+ * Seed one D1 group, idempotently and non-destructively.
18
+ *
19
+ * Every row is `schema.encode(row)`d first — this IS the write-time Zod validation boundary. An
20
+ * invalid fixture throws a `ValidationError` (a `ZodError` mapped via `fromZodError`) **before any
21
+ * write for this group**, so a partial group never lands. The insert is `INSERT OR IGNORE`
22
+ * (`orIgnore`), so re-running seeds writes no duplicate rows and never overwrites existing data. The
23
+ * table's row schema is resolved by the caller from the composed databases registry and passed in —
24
+ * the fixture never redeclares it.
25
+ *
26
+ * **The group is written in chunks sized against D1's bound-parameter ceiling, and that belongs here
27
+ * rather than at any call site.** An insert binds one parameter per column per row, so a group's real
28
+ * limit is `100 / columns` — around fifteen rows for a seven-column table — and it moves with the
29
+ * table. Every fixture the kit ships is 2–6 rows, which is why the single unbatched insert survived: it
30
+ * only breaks on a fixture big enough to do the job fixtures exist for, and `DEFAULT_PAGE_SIZE` is 25,
31
+ * so anything proving a paged list crosses the limit by construction. `pithy-sh/dashboard` hit it on
32
+ * its first realistic seed and worked around it by splitting fourteen tables into twenty-nine groups by
33
+ * hand. A rule that every adopter re-derives after a confusing `too many SQL variables` is a rule in
34
+ * the wrong place; the size is derived from the row's own column count, never guessed.
35
+ *
36
+ * Chunks are written in sequence, and a group is deliberately not atomic across them. `INSERT OR
37
+ * IGNORE` makes a partial run safe to re-run — the landed chunks collide and are ignored — which is the
38
+ * same property that makes seeding re-runnable at all.
39
+ *
40
+ * `dryRun` validates and counts but writes nothing.
41
+ */
42
+ export declare function seedD1Group(db: Kysely<any>, group: D1SeedGroup, schema: z.ZodType, options?: SeedD1Options): Promise<SeedD1Result>;
43
+ //# sourceMappingURL=writeD1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeD1.d.ts","sourceRoot":"","sources":["../../src/seed/writeD1.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;CACd;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,WAAW,CAE/B,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EACf,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,CAAC,CAAC,OAAO,EACjB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA4BvB"}
@@ -0,0 +1,73 @@
1
+ import { fromZodError } from "../error/pithyError.js";
2
+ import { chunkRowsByBoundParameters } from "../data/boundParameters.js";
3
+ import { z } from "zod";
4
+ //#region src/seed/writeD1.ts
5
+ /**
6
+ * How many parameters one encoded row will bind.
7
+ *
8
+ * The **union** of every row's keys, not the first row's count: Kysely builds one column list for a
9
+ * multi-row insert from every object it was given, so a group whose rows differ binds against the wider
10
+ * list. Over-counting only makes the chunks smaller, which is always safe; under-counting is the bug.
11
+ *
12
+ * A row that is not an object cannot be an insert record at all, and Kysely will say so far more
13
+ * usefully than an arithmetic helper would — so it is counted as one parameter and left to fail there.
14
+ */
15
+ function columnsPerRow(encoded) {
16
+ const columns = /* @__PURE__ */ new Set();
17
+ for (const row of encoded) {
18
+ if (typeof row !== "object" || row === null) return 1;
19
+ for (const key of Object.keys(row)) columns.add(key);
20
+ }
21
+ return Math.max(columns.size, 1);
22
+ }
23
+ /**
24
+ * Seed one D1 group, idempotently and non-destructively.
25
+ *
26
+ * Every row is `schema.encode(row)`d first — this IS the write-time Zod validation boundary. An
27
+ * invalid fixture throws a `ValidationError` (a `ZodError` mapped via `fromZodError`) **before any
28
+ * write for this group**, so a partial group never lands. The insert is `INSERT OR IGNORE`
29
+ * (`orIgnore`), so re-running seeds writes no duplicate rows and never overwrites existing data. The
30
+ * table's row schema is resolved by the caller from the composed databases registry and passed in —
31
+ * the fixture never redeclares it.
32
+ *
33
+ * **The group is written in chunks sized against D1's bound-parameter ceiling, and that belongs here
34
+ * rather than at any call site.** An insert binds one parameter per column per row, so a group's real
35
+ * limit is `100 / columns` — around fifteen rows for a seven-column table — and it moves with the
36
+ * table. Every fixture the kit ships is 2–6 rows, which is why the single unbatched insert survived: it
37
+ * only breaks on a fixture big enough to do the job fixtures exist for, and `DEFAULT_PAGE_SIZE` is 25,
38
+ * so anything proving a paged list crosses the limit by construction. `pithy-sh/dashboard` hit it on
39
+ * its first realistic seed and worked around it by splitting fourteen tables into twenty-nine groups by
40
+ * hand. A rule that every adopter re-derives after a confusing `too many SQL variables` is a rule in
41
+ * the wrong place; the size is derived from the row's own column count, never guessed.
42
+ *
43
+ * Chunks are written in sequence, and a group is deliberately not atomic across them. `INSERT OR
44
+ * IGNORE` makes a partial run safe to re-run — the landed chunks collide and are ignored — which is the
45
+ * same property that makes seeding re-runnable at all.
46
+ *
47
+ * `dryRun` validates and counts but writes nothing.
48
+ */
49
+ async function seedD1Group(db, group, schema, options = {}) {
50
+ const encoded = group.rows.map((row, index) => {
51
+ try {
52
+ return schema.encode(row);
53
+ } catch (error) {
54
+ if (error instanceof z.ZodError) throw fromZodError(error, {
55
+ message: `Invalid seed row for table "${group.table}".`,
56
+ action: "Fix the fixture so every field matches the table schema.",
57
+ detail: `Row ${index} for database "${group.database}" table "${group.table}" failed encode validation.`
58
+ });
59
+ throw error;
60
+ }
61
+ });
62
+ if (options.dryRun || encoded.length === 0) return {
63
+ table: group.table,
64
+ rows: encoded.length
65
+ };
66
+ for (const chunk of chunkRowsByBoundParameters(encoded, columnsPerRow(encoded))) await db.insertInto(group.table).orIgnore().values(chunk).execute();
67
+ return {
68
+ table: group.table,
69
+ rows: encoded.length
70
+ };
71
+ }
72
+ //#endregion
73
+ export { seedD1Group };
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import type { TypedKv } from "../kv/kv";
3
+ import type { KvStoreSpec } from "../kv/namespaces";
4
+ import type { KvSeedGroup } from "./seed";
5
+ /** Options for {@link seedKvGroup}. */
6
+ export interface SeedKvOptions {
7
+ /** Count only; perform no write. */
8
+ dryRun?: boolean;
9
+ }
10
+ /** The outcome of seeding one KV group. */
11
+ export interface SeedKvResult {
12
+ /** The store seeded. */
13
+ store: string;
14
+ /** The number of entries validated (and, unless `dryRun`, considered for writing). */
15
+ entries: number;
16
+ }
17
+ /**
18
+ * Seed one KV group, idempotently and non-destructively.
19
+ *
20
+ * **Every entry is validated against the store spec before any write** — mirroring `seedD1Group`, an
21
+ * invalid fixture throws a `ValidationError` (a `ZodError` mapped via `fromZodError`) before the first
22
+ * `put`, so a partial group never lands. The write itself is non-destructive: an existing key is left
23
+ * untouched (KV's analog of D1's `INSERT OR IGNORE`), so re-running a seed never overwrites real data
24
+ * that happens to share a key, and re-establishes only the keys it owns.
25
+ *
26
+ * `dryRun` validates and counts but writes nothing.
27
+ */
28
+ export declare function seedKvGroup<V extends z.ZodType, K extends z.ZodObject, M extends z.ZodType>(store: TypedKv<V, K, M>, group: KvSeedGroup<V, K, M>, spec: KvStoreSpec<V, K, M>, options?: SeedKvOptions): Promise<SeedKvResult>;
29
+ //# sourceMappingURL=writeKv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeKv.d.ts","sourceRoot":"","sources":["../../src/seed/writeKv.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;CACjB;AA4CD;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC,OAAO,EAC/F,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACvB,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC3B,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC1B,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAiBvB"}
@@ -0,0 +1,63 @@
1
+ import { fromZodError } from "../error/pithyError.js";
2
+ import { z } from "zod";
3
+ //#region src/seed/writeKv.ts
4
+ /**
5
+ * Validate one entry's key, value, and (present) metadata against the store spec, mapping a
6
+ * `ZodError` into an actionable `ValidationError`. Pure — never writes.
7
+ */
8
+ function validateEntry(spec, group, entry, index) {
9
+ try {
10
+ spec.key.parse(entry.key);
11
+ spec.value.parse(entry.value);
12
+ if (entry.metadata !== void 0 && spec.metadata !== void 0) spec.metadata.parse(entry.metadata);
13
+ } catch (error) {
14
+ if (error instanceof z.ZodError) throw fromZodError(error, {
15
+ message: `Invalid seed entry for KV store "${group.store}".`,
16
+ action: "Fix the fixture so every entry matches the store's key, value, and metadata schemas.",
17
+ detail: `Entry ${index} for namespace "${group.namespace}" store "${group.store}" failed validation.`
18
+ });
19
+ throw error;
20
+ }
21
+ }
22
+ /**
23
+ * Whether `key` already holds a value — used to make the write non-destructive. A value that exists but
24
+ * no longer parses against the store schema (foreign or older data at a colliding key) still counts as
25
+ * present: existence, not readability, is what the "never overwrite" guarantee turns on.
26
+ */
27
+ async function keyExists(store, key) {
28
+ try {
29
+ return await store.get(key) !== null;
30
+ } catch {
31
+ return true;
32
+ }
33
+ }
34
+ /**
35
+ * Seed one KV group, idempotently and non-destructively.
36
+ *
37
+ * **Every entry is validated against the store spec before any write** — mirroring `seedD1Group`, an
38
+ * invalid fixture throws a `ValidationError` (a `ZodError` mapped via `fromZodError`) before the first
39
+ * `put`, so a partial group never lands. The write itself is non-destructive: an existing key is left
40
+ * untouched (KV's analog of D1's `INSERT OR IGNORE`), so re-running a seed never overwrites real data
41
+ * that happens to share a key, and re-establishes only the keys it owns.
42
+ *
43
+ * `dryRun` validates and counts but writes nothing.
44
+ */
45
+ async function seedKvGroup(store, group, spec, options = {}) {
46
+ group.entries.forEach((entry, index) => {
47
+ validateEntry(spec, group, entry, index);
48
+ });
49
+ if (options.dryRun) return {
50
+ store: group.store,
51
+ entries: group.entries.length
52
+ };
53
+ for (const entry of group.entries) {
54
+ if (await keyExists(store, entry.key)) continue;
55
+ await store.put(entry.key, entry.value, entry.metadata !== void 0 ? { metadata: entry.metadata } : {});
56
+ }
57
+ return {
58
+ store: group.store,
59
+ entries: group.entries.length
60
+ };
61
+ }
62
+ //#endregion
63
+ export { seedKvGroup };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Semantic versions: one parse, one format, one order.
3
+ *
4
+ * Anything that has to *rank* versions needs semver §11.4 — order a release feed, decide what sits
5
+ * between installed and latest, sort a prerelease against the stable it precedes. §11.4 is short and
6
+ * every clause of it is a trap: numeric identifiers compare numerically and alphanumerics compare
7
+ * lexically, a numeric identifier ranks *below* an alphanumeric one, a longer identifier set wins when
8
+ * every shared identifier is equal, and a stable outranks every prerelease of the same core. Each of
9
+ * those is one line to get wrong, and getting one wrong shows up as a feed in the wrong order rather
10
+ * than as an error.
11
+ *
12
+ * So it lives here once. The kit's update notifier uses it and ignores the prerelease field, which is
13
+ * the narrowness it wants rather than a second implementation.
14
+ *
15
+ * **The parse is a split, not a string.** A version held as one string compares as text, and text puts
16
+ * `1.10.0` below `1.9.0`. Split into numbers, the core comparison is three integer comparisons — and
17
+ * for an adopter storing versions in SQLite, three integer columns are a row-value predicate
18
+ * (`(major, minor, patch) > (?, ?, ?)`) that the database orders correctly on its own. SQL cannot
19
+ * express prerelease precedence in that predicate, so a query built that way over-selects a stable
20
+ * against a prerelease of the same core and {@link compareSemver} settles it in app code.
21
+ */
22
+ import { z } from "zod";
23
+ export declare const Semver: z.ZodObject<{
24
+ major: z.ZodNumber;
25
+ minor: z.ZodNumber;
26
+ patch: z.ZodNumber;
27
+ prerelease: z.ZodNullable<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ export type Semver = z.output<typeof Semver>;
30
+ /** How far behind a version is, in each place. */
31
+ export declare const SemverGap: z.ZodObject<{
32
+ major: z.ZodNumber;
33
+ minor: z.ZodNumber;
34
+ patch: z.ZodNumber;
35
+ }, z.core.$strip>;
36
+ export type SemverGap = z.output<typeof SemverGap>;
37
+ /** Parse a version string into its parts. Returns null for anything that is not a version. */
38
+ export declare function parseSemver(value: string): Semver | null;
39
+ /** Render a parsed version back to its canonical string. */
40
+ export declare function formatSemver(version: Semver): string;
41
+ /**
42
+ * Compare two versions by semver precedence. Negative when `a` precedes `b`. Suitable as an
43
+ * `Array.prototype.sort` comparator, so it accepts the nulls {@link parseSemver} returns — an
44
+ * unparseable version sorts below every real one rather than throwing mid-sort.
45
+ */
46
+ export declare function compareSemver(a: Semver | null, b: Semver | null): number;
47
+ /**
48
+ * How far `installed` is behind `latest`, per place.
49
+ *
50
+ * Each place counts only what accrued while the places above it stayed put, which is what makes the
51
+ * number mean something: `1.2.3` against `1.6.1` is four minors and one patch behind, not four minors
52
+ * and *negative two* patches. Somebody running something newer than we know about is ahead, not behind,
53
+ * so the gap floors at zero rather than going negative.
54
+ *
55
+ * **A zero gap is not a claim of being current.** Two versions with the same core sit zero places apart
56
+ * whatever their prereleases say, so `1.2.3-rc.1` against `1.2.3` measures zero even though it precedes
57
+ * it. That is the shape being honest about its limits rather than a bug to paper over: counting places
58
+ * cannot express a prerelease, {@link compareSemver} is what ranks them, and inventing a phantom patch
59
+ * here would put a number on screen that no release actually carries.
60
+ */
61
+ export declare function semverGap(installed: Semver, latest: Semver): SemverGap;
62
+ //# sourceMappingURL=semver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../src/semver/semver.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,MAAM;;;;;iBAchB,CAAC;AACJ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC;AAE7C,kDAAkD;AAClD,eAAO,MAAM,SAAS;;;;iBAQnB,CAAC;AACJ,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEnD,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASxD;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAmCD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAUxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAMtE"}