cvx-kit 0.2.0 → 2.0.0-beta.0

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 (372) hide show
  1. package/README.md +556 -99
  2. package/dist/agent-tools.d.mts +39 -26
  3. package/dist/agent-tools.mjs +1 -1
  4. package/dist/agent-tools.mjs.map +1 -1
  5. package/dist/auth.d.mts +120 -308
  6. package/dist/auth.mjs +1 -1
  7. package/dist/auth.mjs.map +1 -1
  8. package/dist/components/approvals/_generated/api.d.mts +7 -9
  9. package/dist/components/approvals/_generated/api.mjs.map +1 -1
  10. package/dist/components/approvals/_generated/component.d.mts +1 -4
  11. package/dist/components/approvals/_generated/dataModel.d.mts +5 -8
  12. package/dist/components/approvals/_generated/server.d.mts +12 -15
  13. package/dist/components/approvals/_generated/server.mjs.map +1 -1
  14. package/dist/components/approvals/audit.d.mts +8 -9
  15. package/dist/components/approvals/audit.mjs +1 -1
  16. package/dist/components/approvals/audit.mjs.map +1 -1
  17. package/dist/components/approvals/client.d.mts +11 -12
  18. package/dist/components/approvals/client.mjs +1 -1
  19. package/dist/components/approvals/client.mjs.map +1 -1
  20. package/dist/components/approvals/constants.d.mts +30 -31
  21. package/dist/components/approvals/constants.mjs.map +1 -1
  22. package/dist/components/approvals/convex.config.d.mts +0 -2
  23. package/dist/components/approvals/convex.config.mjs.map +1 -1
  24. package/dist/components/approvals/decisions.d.mts +13 -17
  25. package/dist/components/approvals/decisions.mjs +1 -1
  26. package/dist/components/approvals/decisions.mjs.map +1 -1
  27. package/dist/components/approvals/functions.d.mts +3 -4
  28. package/dist/components/approvals/functions.mjs +1 -1
  29. package/dist/components/approvals/functions.mjs.map +1 -1
  30. package/dist/components/approvals/health.d.mts +2 -3
  31. package/dist/components/approvals/health.mjs.map +1 -1
  32. package/dist/components/approvals/requests.d.mts +114 -131
  33. package/dist/components/approvals/requests.mjs +1 -1
  34. package/dist/components/approvals/requests.mjs.map +1 -1
  35. package/dist/components/approvals/schema.d.ts +106 -315
  36. package/dist/components/approvals/schema.js +1 -1
  37. package/dist/components/approvals/validators.d.mts +323 -395
  38. package/dist/components/approvals/validators.mjs +1 -1
  39. package/dist/components/approvals/validators.mjs.map +1 -1
  40. package/dist/components/approvals/workflow.d.mts +4 -5
  41. package/dist/components/approvals/workflow.mjs +1 -1
  42. package/dist/components/approvals/workflow.mjs.map +1 -1
  43. package/dist/components/approvals/workflow_steps.d.mts +16 -17
  44. package/dist/components/approvals/workflow_steps.mjs +1 -1
  45. package/dist/components/approvals/workflow_steps.mjs.map +1 -1
  46. package/dist/components/foundation/_generated/api.d.mts +6 -8
  47. package/dist/components/foundation/_generated/api.mjs.map +1 -1
  48. package/dist/components/foundation/_generated/component.d.mts +1 -4
  49. package/dist/components/foundation/_generated/dataModel.d.mts +5 -8
  50. package/dist/components/foundation/_generated/server.d.mts +12 -15
  51. package/dist/components/foundation/_generated/server.mjs.map +1 -1
  52. package/dist/components/foundation/client.d.mts +45 -38
  53. package/dist/components/foundation/client.mjs +1 -1
  54. package/dist/components/foundation/client.mjs.map +1 -1
  55. package/dist/components/foundation/convex.config.d.mts +0 -2
  56. package/dist/components/foundation/convex.config.mjs.map +1 -1
  57. package/dist/components/foundation/functions.d.mts +2 -3
  58. package/dist/components/foundation/functions.mjs.map +1 -1
  59. package/dist/components/foundation/modules/command/command.d.mts +65 -17
  60. package/dist/components/foundation/modules/command/command.mjs +1 -1
  61. package/dist/components/foundation/modules/command/command.mjs.map +1 -1
  62. package/dist/components/foundation/modules/command/lifecycle.d.mts +78 -0
  63. package/dist/components/foundation/modules/command/lifecycle.mjs +2 -0
  64. package/dist/components/foundation/modules/command/lifecycle.mjs.map +1 -0
  65. package/dist/components/foundation/modules/observability/observability.d.mts +13 -6
  66. package/dist/components/foundation/modules/observability/observability.mjs +1 -1
  67. package/dist/components/foundation/modules/observability/observability.mjs.map +1 -1
  68. package/dist/components/foundation/modules/query/query.d.mts +11 -12
  69. package/dist/components/foundation/modules/query/query.mjs +1 -1
  70. package/dist/components/foundation/modules/query/query.mjs.map +1 -1
  71. package/dist/components/foundation/operation.d.mts +72 -0
  72. package/dist/components/foundation/operation.mjs +2 -0
  73. package/dist/components/foundation/operation.mjs.map +1 -0
  74. package/dist/components/foundation/result.d.mts +7 -8
  75. package/dist/components/foundation/result.mjs.map +1 -1
  76. package/dist/components/foundation/schema.d.ts +0 -2
  77. package/dist/components/foundation/telemetry.d.mts +2 -3
  78. package/dist/components/foundation/telemetry.mjs +1 -1
  79. package/dist/components/foundation/telemetry.mjs.map +1 -1
  80. package/dist/contracts.d.mts +5 -0
  81. package/dist/contracts.mjs +1 -0
  82. package/dist/crud.d.mts +185 -27
  83. package/dist/crud.mjs +1 -1
  84. package/dist/crud.mjs.map +1 -1
  85. package/dist/effect.d.mts +16 -0
  86. package/dist/effect.mjs +1 -0
  87. package/dist/errors.d.mts +6 -6
  88. package/dist/errors.mjs +1 -1
  89. package/dist/errors.mjs.map +1 -1
  90. package/dist/filters.d.mts +4 -0
  91. package/dist/filters.mjs +1 -0
  92. package/dist/idempotency.d.mts +2 -0
  93. package/dist/idempotency.mjs +1 -0
  94. package/dist/index.d.mts +14 -7
  95. package/dist/index.mjs +1 -1
  96. package/dist/json-schema.d.mts +40 -0
  97. package/dist/json-schema.mjs +2 -0
  98. package/dist/json-schema.mjs.map +1 -0
  99. package/dist/k/compile.d.mts +17 -0
  100. package/dist/k/compile.mjs +2 -0
  101. package/dist/k/compile.mjs.map +1 -0
  102. package/dist/k/dates.d.mts +23 -0
  103. package/dist/k/dates.mjs +2 -0
  104. package/dist/k/dates.mjs.map +1 -0
  105. package/dist/k/formats.d.mts +24 -0
  106. package/dist/k/formats.mjs +2 -0
  107. package/dist/k/formats.mjs.map +1 -0
  108. package/dist/k/index.d.mts +32 -0
  109. package/dist/k/index.mjs +2 -0
  110. package/dist/k/index.mjs.map +1 -0
  111. package/dist/k/issues.d.mts +31 -0
  112. package/dist/k/issues.mjs +2 -0
  113. package/dist/k/issues.mjs.map +1 -0
  114. package/dist/k/kinds.d.mts +81 -0
  115. package/dist/k/kinds.mjs +2 -0
  116. package/dist/k/kinds.mjs.map +1 -0
  117. package/dist/k/object.d.mts +43 -0
  118. package/dist/k/object.mjs +2 -0
  119. package/dist/k/object.mjs.map +1 -0
  120. package/dist/k/parse.d.mts +29 -0
  121. package/dist/k/parse.mjs +2 -0
  122. package/dist/k/parse.mjs.map +1 -0
  123. package/dist/k/schema.d.mts +100 -0
  124. package/dist/k/schema.mjs +2 -0
  125. package/dist/k/schema.mjs.map +1 -0
  126. package/dist/k/standard.d.mts +8 -0
  127. package/dist/k/standard.mjs +2 -0
  128. package/dist/k/standard.mjs.map +1 -0
  129. package/dist/k/types.d.mts +64 -0
  130. package/dist/k/types.mjs +1 -0
  131. package/dist/k.d.mts +8 -0
  132. package/dist/k.mjs +1 -0
  133. package/dist/middleware.d.mts +8 -11
  134. package/dist/middleware.mjs +1 -1
  135. package/dist/middleware.mjs.map +1 -1
  136. package/dist/modules/contracts/binding.d.mts +23 -0
  137. package/dist/modules/contracts/binding.mjs +2 -0
  138. package/dist/modules/contracts/binding.mjs.map +1 -0
  139. package/dist/modules/contracts/contract.d.mts +67 -0
  140. package/dist/modules/contracts/contract.mjs +2 -0
  141. package/dist/modules/contracts/contract.mjs.map +1 -0
  142. package/dist/modules/contracts/convex.d.mts +18 -0
  143. package/dist/modules/contracts/convex.mjs +2 -0
  144. package/dist/modules/contracts/convex.mjs.map +1 -0
  145. package/dist/modules/contracts/domain.d.mts +62 -0
  146. package/dist/modules/contracts/domain.mjs +2 -0
  147. package/dist/modules/contracts/domain.mjs.map +1 -0
  148. package/dist/modules/contracts/errors.d.mts +737 -0
  149. package/dist/modules/contracts/errors.mjs +2 -0
  150. package/dist/modules/contracts/errors.mjs.map +1 -0
  151. package/dist/modules/contracts/exposure.d.mts +103 -0
  152. package/dist/modules/contracts/exposure.mjs +2 -0
  153. package/dist/modules/contracts/exposure.mjs.map +1 -0
  154. package/dist/modules/contracts/idempotency.d.mts +85 -0
  155. package/dist/modules/contracts/idempotency.mjs +2 -0
  156. package/dist/modules/contracts/idempotency.mjs.map +1 -0
  157. package/dist/modules/contracts/lazy.d.mts +6 -0
  158. package/dist/modules/contracts/lazy.mjs +2 -0
  159. package/dist/modules/contracts/lazy.mjs.map +1 -0
  160. package/dist/modules/contracts/standard.d.mts +17 -0
  161. package/dist/modules/contracts/standard.mjs +2 -0
  162. package/dist/modules/contracts/standard.mjs.map +1 -0
  163. package/dist/modules/contracts/workflow.d.mts +165 -0
  164. package/dist/modules/contracts/workflow.mjs +2 -0
  165. package/dist/modules/contracts/workflow.mjs.map +1 -0
  166. package/dist/modules/effect/action.d.mts +63 -0
  167. package/dist/modules/effect/action.mjs +2 -0
  168. package/dist/modules/effect/action.mjs.map +1 -0
  169. package/dist/modules/effect/agent-tools.d.mts +2 -0
  170. package/dist/modules/effect/agent-tools.mjs +1 -0
  171. package/dist/modules/effect/api-runtime.d.mts +36 -0
  172. package/dist/modules/effect/api-runtime.mjs +2 -0
  173. package/dist/modules/effect/api-runtime.mjs.map +1 -0
  174. package/dist/modules/effect/api.d.mts +46 -0
  175. package/dist/modules/effect/api.mjs +2 -0
  176. package/dist/modules/effect/api.mjs.map +1 -0
  177. package/dist/modules/effect/auth.d.mts +46 -0
  178. package/dist/modules/effect/auth.mjs +2 -0
  179. package/dist/modules/effect/auth.mjs.map +1 -0
  180. package/dist/modules/effect/client.d.mts +15 -0
  181. package/dist/modules/effect/client.mjs +1 -0
  182. package/dist/modules/effect/command.d.mts +108 -0
  183. package/dist/modules/effect/command.mjs +2 -0
  184. package/dist/modules/effect/command.mjs.map +1 -0
  185. package/dist/modules/effect/crud.d.mts +885 -0
  186. package/dist/modules/effect/crud.mjs +2 -0
  187. package/dist/modules/effect/crud.mjs.map +1 -0
  188. package/dist/modules/effect/domain.d.mts +82 -0
  189. package/dist/modules/effect/domain.mjs +2 -0
  190. package/dist/modules/effect/domain.mjs.map +1 -0
  191. package/dist/modules/effect/errors.d.mts +13 -0
  192. package/dist/modules/effect/errors.mjs +2 -0
  193. package/dist/modules/effect/errors.mjs.map +1 -0
  194. package/dist/modules/effect/failure-audit.d.mts +48 -0
  195. package/dist/modules/effect/failure-audit.mjs +2 -0
  196. package/dist/modules/effect/failure-audit.mjs.map +1 -0
  197. package/dist/modules/effect/failures.d.mts +21 -0
  198. package/dist/modules/effect/failures.mjs +2 -0
  199. package/dist/modules/effect/failures.mjs.map +1 -0
  200. package/dist/modules/effect/foundation.d.mts +23 -0
  201. package/dist/modules/effect/foundation.mjs +2 -0
  202. package/dist/modules/effect/foundation.mjs.map +1 -0
  203. package/dist/modules/effect/idempotency.d.mts +29 -0
  204. package/dist/modules/effect/idempotency.mjs +2 -0
  205. package/dist/modules/effect/idempotency.mjs.map +1 -0
  206. package/dist/modules/effect/input.d.mts +10 -0
  207. package/dist/modules/effect/input.mjs +2 -0
  208. package/dist/modules/effect/input.mjs.map +1 -0
  209. package/dist/modules/effect/normalize.d.mts +7 -0
  210. package/dist/modules/effect/normalize.mjs +2 -0
  211. package/dist/modules/effect/normalize.mjs.map +1 -0
  212. package/dist/modules/effect/operation.d.mts +148 -0
  213. package/dist/modules/effect/operation.mjs +2 -0
  214. package/dist/modules/effect/operation.mjs.map +1 -0
  215. package/dist/modules/effect/query.d.mts +90 -0
  216. package/dist/modules/effect/query.mjs +2 -0
  217. package/dist/modules/effect/query.mjs.map +1 -0
  218. package/dist/modules/effect/schema.d.mts +30 -0
  219. package/dist/modules/effect/schema.mjs +2 -0
  220. package/dist/modules/effect/schema.mjs.map +1 -0
  221. package/dist/modules/effect/scope.d.mts +25 -0
  222. package/dist/modules/effect/scope.mjs +2 -0
  223. package/dist/modules/effect/scope.mjs.map +1 -0
  224. package/dist/modules/effect/workflow.d.mts +75 -0
  225. package/dist/modules/effect/workflow.mjs +2 -0
  226. package/dist/modules/effect/workflow.mjs.map +1 -0
  227. package/dist/modules/foundation/foundation.d.mts +108 -0
  228. package/dist/modules/foundation/foundation.mjs +2 -0
  229. package/dist/modules/foundation/foundation.mjs.map +1 -0
  230. package/dist/modules/foundation/operation.d.mts +139 -0
  231. package/dist/modules/foundation/operation.mjs +2 -0
  232. package/dist/modules/foundation/operation.mjs.map +1 -0
  233. package/dist/namespace.d.mts +104 -0
  234. package/dist/namespace.mjs +2 -0
  235. package/dist/namespace.mjs.map +1 -0
  236. package/dist/oxlint/architecture.d.mts +23 -0
  237. package/dist/oxlint/architecture.mjs +2 -0
  238. package/dist/oxlint/architecture.mjs.map +1 -0
  239. package/dist/oxlint/ast.d.mts +51 -0
  240. package/dist/oxlint/ast.mjs +2 -0
  241. package/dist/oxlint/ast.mjs.map +1 -0
  242. package/dist/oxlint/components.d.mts +4 -0
  243. package/dist/oxlint/components.mjs +2 -0
  244. package/dist/oxlint/components.mjs.map +1 -0
  245. package/dist/oxlint/ownership.d.mts +59 -0
  246. package/dist/oxlint/ownership.mjs +2 -0
  247. package/dist/oxlint/ownership.mjs.map +1 -0
  248. package/dist/oxlint/reserved-files.d.mts +4 -0
  249. package/dist/oxlint/reserved-files.mjs +2 -0
  250. package/dist/oxlint/reserved-files.mjs.map +1 -0
  251. package/dist/oxlint.d.mts +9 -0
  252. package/dist/oxlint.mjs +2 -0
  253. package/dist/oxlint.mjs.map +1 -0
  254. package/dist/querying/cursors.d.mts +94 -0
  255. package/dist/querying/cursors.mjs +2 -0
  256. package/dist/querying/cursors.mjs.map +1 -0
  257. package/dist/querying/execution.d.mts +40 -0
  258. package/dist/querying/execution.mjs +2 -0
  259. package/dist/querying/execution.mjs.map +1 -0
  260. package/dist/querying/failures.d.mts +11 -0
  261. package/dist/querying/failures.mjs +2 -0
  262. package/dist/querying/failures.mjs.map +1 -0
  263. package/dist/querying/filter-boundary.d.mts +25 -0
  264. package/dist/querying/filter-boundary.mjs +2 -0
  265. package/dist/querying/filter-boundary.mjs.map +1 -0
  266. package/dist/querying/filters.d.mts +180 -0
  267. package/dist/querying/filters.mjs +2 -0
  268. package/dist/querying/filters.mjs.map +1 -0
  269. package/dist/querying/planner.d.mts +61 -0
  270. package/dist/querying/planner.mjs +2 -0
  271. package/dist/querying/planner.mjs.map +1 -0
  272. package/dist/querying/relationships.d.mts +58 -0
  273. package/dist/querying/relationships.mjs +2 -0
  274. package/dist/querying/relationships.mjs.map +1 -0
  275. package/dist/querying/search.d.mts +69 -0
  276. package/dist/querying/search.mjs +2 -0
  277. package/dist/querying/search.mjs.map +1 -0
  278. package/dist/querying/security.d.mts +123 -0
  279. package/dist/querying/security.mjs +2 -0
  280. package/dist/querying/security.mjs.map +1 -0
  281. package/dist/querying/shared/ast.d.mts +26 -0
  282. package/dist/querying/shared/ast.mjs +2 -0
  283. package/dist/querying/shared/ast.mjs.map +1 -0
  284. package/dist/querying/shared/contract.d.mts +98 -0
  285. package/dist/querying/shared/contract.mjs +2 -0
  286. package/dist/querying/shared/contract.mjs.map +1 -0
  287. package/dist/querying/shared/evaluate.d.mts +5 -0
  288. package/dist/querying/shared/evaluate.mjs +2 -0
  289. package/dist/querying/shared/evaluate.mjs.map +1 -0
  290. package/dist/querying/shared/filters.d.mts +65 -0
  291. package/dist/querying/shared/filters.mjs +2 -0
  292. package/dist/querying/shared/filters.mjs.map +1 -0
  293. package/dist/querying/shared/native-json.d.mts +7 -0
  294. package/dist/querying/shared/native-json.mjs +2 -0
  295. package/dist/querying/shared/native-json.mjs.map +1 -0
  296. package/dist/querying/shared/page.d.mts +20 -0
  297. package/dist/querying/shared/page.mjs +2 -0
  298. package/dist/querying/shared/page.mjs.map +1 -0
  299. package/dist/querying.d.mts +82 -0
  300. package/dist/querying.mjs +2 -0
  301. package/dist/querying.mjs.map +1 -0
  302. package/dist/react/failures.d.mts +24 -0
  303. package/dist/react/failures.mjs +2 -0
  304. package/dist/react/failures.mjs.map +1 -0
  305. package/dist/react/optimistic.d.mts +46 -0
  306. package/dist/react/optimistic.mjs +2 -0
  307. package/dist/react/optimistic.mjs.map +1 -0
  308. package/dist/react/pagination-state.d.mts +39 -0
  309. package/dist/react/pagination-state.mjs +2 -0
  310. package/dist/react/pagination-state.mjs.map +1 -0
  311. package/dist/react/use-command.d.mts +22 -0
  312. package/dist/react/use-command.mjs +2 -0
  313. package/dist/react/use-command.mjs.map +1 -0
  314. package/dist/react/use-paginated-list.d.mts +34 -0
  315. package/dist/react/use-paginated-list.mjs +2 -0
  316. package/dist/react/use-paginated-list.mjs.map +1 -0
  317. package/dist/react.d.mts +6 -0
  318. package/dist/react.mjs +1 -0
  319. package/dist/registration.d.mts +65 -0
  320. package/dist/registration.mjs +2 -0
  321. package/dist/registration.mjs.map +1 -0
  322. package/dist/relations-public.d.mts +2 -0
  323. package/dist/relations-public.mjs +1 -0
  324. package/dist/relations.d.mts +274 -0
  325. package/dist/relations.mjs +2 -0
  326. package/dist/relations.mjs.map +1 -0
  327. package/dist/state-machine.d.mts +1 -4
  328. package/dist/state-machine.mjs.map +1 -1
  329. package/dist/table.d.mts +222 -0
  330. package/dist/table.mjs +2 -0
  331. package/dist/table.mjs.map +1 -0
  332. package/dist/tenancy.d.mts +6 -8
  333. package/dist/tenancy.mjs +1 -1
  334. package/dist/tenancy.mjs.map +1 -1
  335. package/dist/triggers.d.mts +12 -10
  336. package/dist/triggers.mjs +1 -1
  337. package/dist/triggers.mjs.map +1 -1
  338. package/dist/webhooks.d.mts +22 -112
  339. package/dist/webhooks.mjs +1 -1
  340. package/dist/webhooks.mjs.map +1 -1
  341. package/dist/workflow.d.mts +2 -0
  342. package/dist/workflow.mjs +1 -0
  343. package/dist/zod.d.mts +30 -0
  344. package/dist/zod.mjs +2 -0
  345. package/dist/zod.mjs.map +1 -0
  346. package/package.json +145 -33
  347. package/src/test.ts +9 -17
  348. package/CHANGELOG.md +0 -145
  349. package/ROADMAP.md +0 -126
  350. package/dist/zod-table.d.mts +0 -175
  351. package/dist/zod-table.mjs +0 -2
  352. package/dist/zod-table.mjs.map +0 -1
  353. package/docs/agent-tools.md +0 -41
  354. package/docs/approvals.md +0 -200
  355. package/docs/architecture.md +0 -124
  356. package/docs/auth.md +0 -218
  357. package/docs/commands.md +0 -278
  358. package/docs/conventions.md +0 -291
  359. package/docs/crud.md +0 -62
  360. package/docs/llms.md +0 -220
  361. package/docs/maintainability.md +0 -124
  362. package/docs/migration.md +0 -351
  363. package/docs/plans/2026-08-14-001-feat-v0.1.0-feature-set-plan.md +0 -461
  364. package/docs/plans/2026-08-21-0930-feat-resolve-organization-hook-plan.md +0 -178
  365. package/docs/tenancy.md +0 -179
  366. package/docs/triggers.md +0 -75
  367. package/docs/upgrading.md +0 -175
  368. package/docs/webhooks.md +0 -58
  369. package/docs/zod-table.md +0 -173
  370. package/scripts/convex-config-bridge.mjs +0 -55
  371. package/scripts/extract-changelog.mjs +0 -29
  372. package/scripts/smoke-packed-components.mjs +0 -374
@@ -1,6 +1,8 @@
1
+ import { KNumber, KString } from "./k/kinds.mjs";
2
+ import "./k.mjs";
3
+ import { KTableBoundary } from "./table.mjs";
1
4
  import { ErrorFactory } from "./errors.mjs";
2
- import { z } from "zod";
3
- //#region src/webhooks.d.ts
5
+ import { FunctionReference, GenericDataModel, GenericMutationCtx } from "convex/server";
4
6
  /**
5
7
  * The host-owned dedup table (the kit gains no tables). Register it in the
6
8
  * schema with the by_eventKey index:
@@ -11,122 +13,26 @@ import { z } from "zod";
11
13
  * longer than the provider's redelivery horizon (a cleanup cron over
12
14
  * `receivedAt` — see docs/webhooks.md).
13
15
  */
14
- declare function webhookEventsTable(): {
15
- tableName: "webhookEvents";
16
- schema: z.ZodObject<{
17
- createdAt: z.ZodOptional<z.ZodNumber>;
18
- updatedAt: z.ZodOptional<z.ZodNumber>;
19
- archivedAt: z.ZodOptional<z.ZodNumber>;
20
- _id: import("convex-helpers/server/zod4").Zid<"webhookEvents">;
21
- _creationTime: z.ZodNumber;
22
- eventKey: z.ZodString;
23
- source: z.ZodString;
24
- receivedAt: z.ZodNumber;
25
- }, z.core.$strict>;
26
- storage: z.ZodObject<{
27
- createdAt: z.ZodOptional<z.ZodNumber>;
28
- updatedAt: z.ZodOptional<z.ZodNumber>;
29
- archivedAt: z.ZodOptional<z.ZodNumber>;
30
- eventKey: z.ZodString;
31
- source: z.ZodString;
32
- receivedAt: z.ZodNumber;
33
- }, z.core.$strict>;
34
- insertSchema: z.ZodObject<Omit<{
35
- eventKey: z.ZodString;
36
- source: z.ZodString;
37
- receivedAt: z.ZodNumber;
38
- }, "archivedAt" | "createdAt" | "updatedAt">, z.core.$strip>;
39
- updateSchema: z.ZodObject<{
40
- eventKey: z.ZodOptional<z.ZodString>;
41
- source: z.ZodOptional<z.ZodString>;
42
- receivedAt: z.ZodOptional<z.ZodNumber>;
43
- }, z.core.$strip>;
44
- commandInput: z.ZodObject<{}, z.core.$strict>;
45
- publicDto: z.ZodObject<{}, z.core.$strict>;
46
- toPublicDto: (row: {
47
- createdAt?: number | undefined;
48
- updatedAt?: number | undefined;
49
- archivedAt?: number | undefined;
50
- eventKey: string;
51
- source: string;
52
- receivedAt: number;
53
- }) => Record<string, never>;
54
- table: import("convex/server").TableDefinition<import("convex/values").VObject<{
55
- createdAt?: number | undefined;
56
- updatedAt?: number | undefined;
57
- archivedAt?: number | undefined;
58
- eventKey: string;
59
- source: string;
60
- receivedAt: number;
61
- }, {
62
- createdAt: import("convex/values").VFloat64<number | undefined, "optional">;
63
- updatedAt: import("convex/values").VFloat64<number | undefined, "optional">;
64
- archivedAt: import("convex/values").VFloat64<number | undefined, "optional">;
65
- eventKey: import("convex/values").VString<string, "required">;
66
- source: import("convex/values").VString<string, "required">;
67
- receivedAt: import("convex/values").VFloat64<number, "required">;
68
- }, "required", "archivedAt" | "createdAt" | "eventKey" | "receivedAt" | "source" | "updatedAt">, {}, {}, {}>;
69
- insert: {
70
- (): z.ZodObject<Omit<{
71
- eventKey: z.ZodString;
72
- source: z.ZodString;
73
- receivedAt: z.ZodNumber;
74
- }, "archivedAt" | "createdAt" | "updatedAt">, z.core.$strip>;
75
- <OmitMask extends z.util.Mask<"eventKey" | "receivedAt" | "source">>(omit: OmitMask): z.ZodObject<Omit<Omit<{
76
- eventKey: z.ZodString;
77
- source: z.ZodString;
78
- receivedAt: z.ZodNumber;
79
- }, "archivedAt" | "createdAt" | "updatedAt">, Extract<"eventKey", keyof OmitMask> | Extract<"receivedAt", keyof OmitMask> | Extract<"source", keyof OmitMask>> extends (infer T) ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
80
- };
81
- update: {
82
- (): z.ZodObject<{
83
- eventKey: z.ZodOptional<z.ZodString>;
84
- source: z.ZodOptional<z.ZodString>;
85
- receivedAt: z.ZodOptional<z.ZodNumber>;
86
- }, z.core.$strip>;
87
- <OmitMask extends z.util.Mask<"eventKey" | "receivedAt" | "source">>(omit: OmitMask): z.ZodObject<Omit<{
88
- eventKey: z.ZodOptional<z.ZodString>;
89
- source: z.ZodOptional<z.ZodString>;
90
- receivedAt: z.ZodOptional<z.ZodNumber>;
91
- }, Extract<"eventKey", keyof OmitMask> | Extract<"receivedAt", keyof OmitMask> | Extract<"source", keyof OmitMask>> extends (infer T) ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
92
- };
93
- tools: {
94
- insert: z.ZodObject<{}, z.core.$strict>;
95
- update: z.ZodObject<{
96
- data: z.ZodObject<{}, z.core.$strict>;
97
- id: z.ZodType<import("convex/values").GenericId<"webhookEvents">, string, z.core.$ZodTypeInternals<import("convex/values").GenericId<"webhookEvents">, string>>;
98
- }, z.core.$strict>;
99
- id: z.ZodObject<{
100
- id: z.ZodType<import("convex/values").GenericId<"webhookEvents">, string, z.core.$ZodTypeInternals<import("convex/values").GenericId<"webhookEvents">, string>>;
101
- }, z.core.$strict>;
102
- };
103
- };
104
- type DedupContext = {
105
- db: {
106
- query: (table: never) => {
107
- withIndex: (index: never, range: (builder: {
108
- eq: (field: never, value: never) => unknown;
109
- }) => unknown) => {
110
- first: () => Promise<unknown | null>;
111
- };
112
- };
113
- insert: (table: never, value: never) => Promise<unknown>;
114
- };
115
- };
16
+ export declare function webhookEventsTable(): KTableBoundary<"webhookEvents", {
17
+ eventKey: KString;
18
+ source: KString;
19
+ receivedAt: KNumber;
20
+ }, never, never, never>;
21
+ type DedupContext = Pick<GenericMutationCtx<GenericDataModel>, 'db'>;
116
22
  /**
117
23
  * Transactional insert-if-absent dedup guard. Call this FIRST inside the
118
24
  * internal mutation the boundary delegates to — dedup must live in the
119
25
  * mutation (transactional), never in the action. Returns duplicate: true
120
26
  * when the natural key was already recorded; the caller then no-ops.
121
27
  */
122
- declare function recordWebhookEvent(ctx: DedupContext, input: {
28
+ export declare function recordWebhookEvent(ctx: DedupContext, input: {
123
29
  key: string;
124
30
  source?: string;
125
31
  table?: string;
126
32
  }): Promise<{
127
33
  duplicate: boolean;
128
34
  }>;
129
- type WebhookBoundaryConfig = {
35
+ export type WebhookBoundaryConfig = {
130
36
  /**
131
37
  * Verifies the provider signature over the RAW body bytes — the helper
132
38
  * hands it `request.text()` BEFORE any parsing. Implementations must use
@@ -154,11 +60,15 @@ type WebhookBoundaryConfig = {
154
60
  * handler: httpAction((ctx, request) =>
155
61
  * boundary.handle(ctx, request, internal.domain.vendor.functions.applyEvent)) })
156
62
  */
157
- declare function createWebhookBoundary(config: WebhookBoundaryConfig): {
158
- handle: (ctx: {
159
- runMutation: (target: never, args: never) => Promise<unknown>;
160
- }, request: Request, target: unknown) => Promise<Response>;
63
+ export declare function createWebhookBoundary(config: WebhookBoundaryConfig): {
64
+ handle: <Result>(ctx: {
65
+ runMutation: (target: FunctionReference<'mutation', 'internal', WebhookDelivery, Result>, args: WebhookDelivery) => Promise<Result>;
66
+ }, request: Request, target: FunctionReference<'mutation', 'internal', WebhookDelivery, Result>) => Promise<Response>;
67
+ };
68
+ export type WebhookDelivery = {
69
+ eventKey: string;
70
+ payload: string;
71
+ source: string;
161
72
  };
162
- //#endregion
163
- export { WebhookBoundaryConfig, createWebhookBoundary, recordWebhookEvent, webhookEventsTable };
73
+ export {};
164
74
  //# sourceMappingURL=webhooks.d.mts.map
package/dist/webhooks.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{defaultErrors as e}from"./errors.mjs";import{zodTable as t}from"./zod-table.mjs";import{z as n}from"zod";function r(){return t(`webhookEvents`,()=>({eventKey:n.string(),source:n.string(),receivedAt:n.number()}))}async function i(e,t){let n=t.table??`webhookEvents`;return await e.db.query(n).withIndex(`by_eventKey`,e=>e.eq(`eventKey`,t.key)).first()?{duplicate:!0}:(await e.db.insert(n,{eventKey:t.key,source:t.source??`unknown`,receivedAt:Date.now()}),{duplicate:!1})}function a(t){let n=t.errors??e;async function r(e,r,i){let a=await r.text(),o=!1;try{o=await t.verify(a,r)}catch{o=!1}o||n.throw({code:`WEBHOOK_SIGNATURE_INVALID`,message:`Webhook signature verification failed`});let s=await t.eventKey(a,r);return await e.runMutation(i,{eventKey:s,payload:a,source:t.source??`unknown`}),new Response(null,{status:200})}return{handle:r}}export{a as createWebhookBoundary,i as recordWebhookEvent,r as webhookEventsTable};
1
+ import{defaultErrors as e}from"./errors.mjs";import{k as t}from"./k/index.mjs";import{kTable as n}from"./table.mjs";function r(){return n(`webhookEvents`,{eventKey:t.string(),source:t.string(),receivedAt:t.number()})}async function i(e,t){let n=t.table??`webhookEvents`;return await e.db.query(n).withIndex(`by_eventKey`,e=>e.eq(`eventKey`,t.key)).first()?{duplicate:!0}:(await e.db.insert(n,{eventKey:t.key,source:t.source??`unknown`,receivedAt:Date.now()}),{duplicate:!1})}function a(t){let n=t.errors??e;async function r(e,r,i){let a=await r.text(),o=!1;try{o=await t.verify(a,r)}catch{o=!1}o||n.throw({code:`WEBHOOK_SIGNATURE_INVALID`,message:`Webhook signature verification failed`});let s=await t.eventKey(a,r);return await e.runMutation(i,{eventKey:s,payload:a,source:t.source??`unknown`}),new Response(null,{status:200})}return{handle:r}}export{a as createWebhookBoundary,i as recordWebhookEvent,r as webhookEventsTable};
2
2
  //# sourceMappingURL=webhooks.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.mjs","names":[],"sources":["../src/webhooks.ts"],"sourcesContent":["import { z } from 'zod'\nimport { defaultErrors, type ErrorFactory } from './errors'\nimport { zodTable } from './zod-table'\n\n/**\n * The host-owned dedup table (the kit gains no tables). Register it in the\n * schema with the by_eventKey index:\n *\n * webhookEvents: webhookEventsTable().table.index('by_eventKey', ['eventKey'])\n *\n * Rows are host-owned data: prune them on a retention window comfortably\n * longer than the provider's redelivery horizon (a cleanup cron over\n * `receivedAt` — see docs/webhooks.md).\n */\nexport function webhookEventsTable() {\n\treturn zodTable('webhookEvents', () => ({\n\t\teventKey: z.string(),\n\t\tsource: z.string(),\n\t\treceivedAt: z.number(),\n\t}))\n}\n\ntype DedupContext = {\n\tdb: {\n\t\tquery: (table: never) => {\n\t\t\twithIndex: (\n\t\t\t\tindex: never,\n\t\t\t\trange: (builder: { eq: (field: never, value: never) => unknown }) => unknown,\n\t\t\t) => { first: () => Promise<unknown | null> }\n\t\t}\n\t\tinsert: (table: never, value: never) => Promise<unknown>\n\t}\n}\n\n/**\n * Transactional insert-if-absent dedup guard. Call this FIRST inside the\n * internal mutation the boundary delegates to — dedup must live in the\n * mutation (transactional), never in the action. Returns duplicate: true\n * when the natural key was already recorded; the caller then no-ops.\n */\nexport async function recordWebhookEvent(\n\tctx: DedupContext,\n\tinput: { key: string; source?: string; table?: string },\n): Promise<{ duplicate: boolean }> {\n\tconst table = (input.table ?? 'webhookEvents') as never\n\tconst existing = await ctx.db\n\t\t.query(table)\n\t\t.withIndex('by_eventKey' as never, (builder) =>\n\t\t\tbuilder.eq('eventKey' as never, input.key as never),\n\t\t)\n\t\t.first()\n\tif (existing) return { duplicate: true }\n\tawait ctx.db.insert(table, {\n\t\teventKey: input.key,\n\t\tsource: input.source ?? 'unknown',\n\t\treceivedAt: Date.now(),\n\t} as never)\n\treturn { duplicate: false }\n}\n\nexport type WebhookBoundaryConfig = {\n\t/**\n\t * Verifies the provider signature over the RAW body bytes — the helper\n\t * hands it `request.text()` BEFORE any parsing. Implementations must use\n\t * a constant-time comparison (e.g. crypto.subtle HMAC verify) and read\n\t * the secret from a Convex environment variable. Return false or throw\n\t * to reject.\n\t */\n\tverify: (raw: string, request: Request) => boolean | Promise<boolean>\n\t/**\n\t * Derives the natural dedup key — the `${event}:${id}:${updatedAt}`\n\t * pattern. Receives the raw body and the request; parse inside if needed.\n\t */\n\teventKey: (raw: string, request: Request) => string | Promise<string>\n\tsource?: string\n\terrors?: ErrorFactory\n}\n\n/**\n * The sanctioned webhook pattern as code: verify (raw body, fail closed) →\n * derive natural key → delegate to a host internal mutation whose FIRST act\n * is recordWebhookEvent (transactional dedup). Use inside the host's\n * httpAction:\n *\n * const boundary = createWebhookBoundary({ verify, eventKey })\n * http.route({ path: '/webhooks/vendor', method: 'POST',\n * handler: httpAction((ctx, request) =>\n * boundary.handle(ctx, request, internal.domain.vendor.functions.applyEvent)) })\n */\nexport function createWebhookBoundary(config: WebhookBoundaryConfig) {\n\tconst errors = config.errors ?? defaultErrors\n\n\tasync function handle(\n\t\tctx: {\n\t\t\trunMutation: (target: never, args: never) => Promise<unknown>\n\t\t},\n\t\trequest: Request,\n\t\ttarget: unknown,\n\t): Promise<Response> {\n\t\tconst raw = await request.text()\n\t\tlet verified = false\n\t\ttry {\n\t\t\tverified = await config.verify(raw, request)\n\t\t} catch {\n\t\t\tverified = false\n\t\t}\n\t\tif (!verified) {\n\t\t\terrors.throw({\n\t\t\t\tcode: 'WEBHOOK_SIGNATURE_INVALID',\n\t\t\t\tmessage: 'Webhook signature verification failed',\n\t\t\t})\n\t\t}\n\t\tconst key = await config.eventKey(raw, request)\n\t\tawait ctx.runMutation(target as never, {\n\t\t\teventKey: key,\n\t\t\tpayload: raw,\n\t\t\tsource: config.source ?? 'unknown',\n\t\t} as never)\n\t\treturn new Response(null, { status: 200 })\n\t}\n\n\treturn { handle }\n}\n"],"mappings":"gHAcA,SAAgB,GAAqB,CACpC,OAAO,EAAS,qBAAwB,CACvC,SAAU,EAAE,OAAO,EACnB,OAAQ,EAAE,OAAO,EACjB,WAAY,EAAE,OAAO,CACtB,EAAE,CACH,CAoBA,eAAsB,EACrB,EACA,EACkC,CAClC,IAAM,EAAS,EAAM,OAAS,gBAa9B,OANI,MANmB,EAAI,GACzB,MAAM,CAAK,CAAC,CACZ,UAAU,cAAyB,GACnC,EAAQ,GAAG,WAAqB,EAAM,GAAY,CACnD,CAAC,CACA,MAAM,EACa,CAAE,UAAW,EAAK,GACvC,MAAM,EAAI,GAAG,OAAO,EAAO,CAC1B,SAAU,EAAM,IAChB,OAAQ,EAAM,QAAU,UACxB,WAAY,KAAK,IAAI,CACtB,CAAU,EACH,CAAE,UAAW,EAAM,EAC3B,CA+BA,SAAgB,EAAsB,EAA+B,CACpE,IAAM,EAAS,EAAO,QAAU,EAEhC,eAAe,EACd,EAGA,EACA,EACoB,CACpB,IAAM,EAAM,MAAM,EAAQ,KAAK,EAC3B,EAAW,GACf,GAAI,CACH,EAAW,MAAM,EAAO,OAAO,EAAK,CAAO,CAC5C,MAAQ,CACP,EAAW,EACZ,CACK,GACJ,EAAO,MAAM,CACZ,KAAM,4BACN,QAAS,uCACV,CAAC,EAEF,IAAM,EAAM,MAAM,EAAO,SAAS,EAAK,CAAO,EAM9C,OALA,MAAM,EAAI,YAAY,EAAiB,CACtC,SAAU,EACV,QAAS,EACT,OAAQ,EAAO,QAAU,SAC1B,CAAU,EACH,IAAI,SAAS,KAAM,CAAE,OAAQ,GAAI,CAAC,CAC1C,CAEA,MAAO,CAAE,QAAO,CACjB"}
1
+ {"version":3,"file":"webhooks.mjs","names":["webhookEventsTable","kTable","k","recordWebhookEvent","table","input","ctx","builder","createWebhookBoundary","errors","config","defaultErrors","handle","raw","request","verified","key","target"],"sources":["../src/webhooks.ts"],"sourcesContent":["import type { GenericMutationCtx, GenericDataModel, FunctionReference } from 'convex/server'\nimport { defaultErrors, type ErrorFactory } from './errors'\nimport { k } from './k'\nimport { kTable } from './table'\n\n/**\n * The host-owned dedup table (the kit gains no tables). Register it in the\n * schema with the by_eventKey index:\n *\n * webhookEvents: webhookEventsTable().table.index('by_eventKey', ['eventKey'])\n *\n * Rows are host-owned data: prune them on a retention window comfortably\n * longer than the provider's redelivery horizon (a cleanup cron over\n * `receivedAt` — see docs/webhooks.md).\n */\nexport function webhookEventsTable() {\n\treturn kTable('webhookEvents', {\n\t\teventKey: k.string(),\n\t\tsource: k.string(),\n\t\treceivedAt: k.number(),\n\t})\n}\n\ntype DedupContext = Pick<GenericMutationCtx<GenericDataModel>, 'db'>\n\n/**\n * Transactional insert-if-absent dedup guard. Call this FIRST inside the\n * internal mutation the boundary delegates to — dedup must live in the\n * mutation (transactional), never in the action. Returns duplicate: true\n * when the natural key was already recorded; the caller then no-ops.\n */\nexport async function recordWebhookEvent(\n\tctx: DedupContext,\n\tinput: { key: string; source?: string; table?: string },\n): Promise<{ duplicate: boolean }> {\n\tconst table = input.table ?? 'webhookEvents'\n\tconst existing = await ctx.db\n\t\t.query(table)\n\t\t.withIndex('by_eventKey', (builder) => builder.eq('eventKey', input.key))\n\t\t.first()\n\tif (existing) return { duplicate: true }\n\tawait ctx.db.insert(table, {\n\t\teventKey: input.key,\n\t\tsource: input.source ?? 'unknown',\n\t\treceivedAt: Date.now(),\n\t})\n\treturn { duplicate: false }\n}\n\nexport type WebhookBoundaryConfig = {\n\t/**\n\t * Verifies the provider signature over the RAW body bytes — the helper\n\t * hands it `request.text()` BEFORE any parsing. Implementations must use\n\t * a constant-time comparison (e.g. crypto.subtle HMAC verify) and read\n\t * the secret from a Convex environment variable. Return false or throw\n\t * to reject.\n\t */\n\tverify: (raw: string, request: Request) => boolean | Promise<boolean>\n\t/**\n\t * Derives the natural dedup key — the `${event}:${id}:${updatedAt}`\n\t * pattern. Receives the raw body and the request; parse inside if needed.\n\t */\n\teventKey: (raw: string, request: Request) => string | Promise<string>\n\tsource?: string\n\terrors?: ErrorFactory\n}\n\n/**\n * The sanctioned webhook pattern as code: verify (raw body, fail closed) →\n * derive natural key → delegate to a host internal mutation whose FIRST act\n * is recordWebhookEvent (transactional dedup). Use inside the host's\n * httpAction:\n *\n * const boundary = createWebhookBoundary({ verify, eventKey })\n * http.route({ path: '/webhooks/vendor', method: 'POST',\n * handler: httpAction((ctx, request) =>\n * boundary.handle(ctx, request, internal.domain.vendor.functions.applyEvent)) })\n */\nexport function createWebhookBoundary(config: WebhookBoundaryConfig) {\n\tconst errors = config.errors ?? defaultErrors\n\n\tasync function handle<Result>(\n\t\tctx: {\n\t\t\trunMutation: (\n\t\t\t\ttarget: FunctionReference<'mutation', 'internal', WebhookDelivery, Result>,\n\t\t\t\targs: WebhookDelivery,\n\t\t\t) => Promise<Result>\n\t\t},\n\t\trequest: Request,\n\t\ttarget: FunctionReference<'mutation', 'internal', WebhookDelivery, Result>,\n\t): Promise<Response> {\n\t\tconst raw = await request.text()\n\t\tlet verified = false\n\t\ttry {\n\t\t\tverified = await config.verify(raw, request)\n\t\t} catch {\n\t\t\tverified = false\n\t\t}\n\t\tif (!verified) {\n\t\t\terrors.throw({\n\t\t\t\tcode: 'WEBHOOK_SIGNATURE_INVALID',\n\t\t\t\tmessage: 'Webhook signature verification failed',\n\t\t\t})\n\t\t}\n\t\tconst key = await config.eventKey(raw, request)\n\t\tawait ctx.runMutation(target, {\n\t\t\teventKey: key,\n\t\t\tpayload: raw,\n\t\t\tsource: config.source ?? 'unknown',\n\t\t})\n\t\treturn new Response(null, { status: 200 })\n\t}\n\n\treturn { handle }\n}\n\nexport type WebhookDelivery = { eventKey: string; payload: string; source: string }\n"],"mappings":"A,oHAeA,SAAgBA,GAAqB,CACpC,OAAOC,EAAO,gBAAiB,CAC9B,SAAUC,EAAE,OAAO,EACnB,OAAQA,EAAE,OAAO,EACjB,WAAYA,EAAE,OAAO,CACtB,CAAC,CACF,CAUA,eAAsBC,EACrB,EACA,EACkC,CAClC,IAAMC,EAAQC,EAAM,OAAS,gBAW7B,OANI,MAJmBC,EAAI,GACzB,MAAMF,CAAK,CAAC,CACZ,UAAU,cAAgB,GAAYG,EAAQ,GAAG,WAAYF,EAAM,GAAG,CAAC,CAAC,CACxE,MAAM,EACa,CAAE,UAAW,EAAK,GACvC,MAAMC,EAAI,GAAG,OAAOF,EAAO,CAC1B,SAAUC,EAAM,IAChB,OAAQA,EAAM,QAAU,UACxB,WAAY,KAAK,IAAI,CACtB,CAAC,EACM,CAAE,UAAW,EAAM,EAC3B,CA+BA,SAAgBG,EAAsB,EAA+B,CACpE,IAAMC,EAASC,EAAO,QAAUC,EAEhC,eAAeC,EACd,EAMA,EACA,EACoB,CACpB,IAAMC,EAAM,MAAMC,EAAQ,KAAK,EAC3BC,EAAW,GACf,GAAI,CACH,EAAW,MAAML,EAAO,OAAOG,EAAKC,CAAO,CAC5C,MAAQ,CACP,EAAW,EACZ,CACKC,GACJN,EAAO,MAAM,CACZ,KAAM,4BACN,QAAS,uCACV,CAAC,EAEF,IAAMO,EAAM,MAAMN,EAAO,SAASG,EAAKC,CAAO,EAM9C,OALA,MAAMR,EAAI,YAAYW,EAAQ,CAC7B,SAAUD,EACV,QAASH,EACT,OAAQH,EAAO,QAAU,SAC1B,CAAC,EACM,IAAI,SAAS,KAAM,CAAE,OAAQ,GAAI,CAAC,CAC1C,CAEA,MAAO,CAAE,QAAO,CACjB,C"}
@@ -0,0 +1,2 @@
1
+ import { ReceiptProtectedWorkflowMutation, WorkflowBinding, WorkflowBindingError, WorkflowExecution, WorkflowHostState, WorkflowHostUpdate, WorkflowNativeStatus, WorkflowOutcome, WorkflowReceiptAdapter, WorkflowStepArguments, WorkflowStepOptions, WorkflowStepRunner, WorkflowTransition, receiptWorkflowMutation, runWorkflowStep, terminalWorkflowAttempt, workflowAttempt, workflowBinding, workflowCancel, workflowExecution, workflowReceiptInvocation, workflowRestart, workflowStatusBindings, workflowTransition } from "./modules/contracts/workflow.mjs";
2
+ export { type ReceiptProtectedWorkflowMutation, type WorkflowBinding, WorkflowBindingError, type WorkflowExecution, type WorkflowHostState, type WorkflowHostUpdate, type WorkflowNativeStatus, type WorkflowOutcome, type WorkflowReceiptAdapter, type WorkflowStepArguments, type WorkflowStepOptions, type WorkflowStepRunner, type WorkflowTransition, receiptWorkflowMutation, runWorkflowStep, terminalWorkflowAttempt, workflowAttempt, workflowBinding, workflowCancel, workflowExecution, workflowReceiptInvocation, workflowRestart, workflowStatusBindings, workflowTransition };
@@ -0,0 +1 @@
1
+ export{WorkflowBindingError,receiptWorkflowMutation,runWorkflowStep,terminalWorkflowAttempt,workflowAttempt,workflowBinding,workflowCancel,workflowExecution,workflowReceiptInvocation,workflowRestart,workflowStatusBindings,workflowTransition}from"./modules/contracts/workflow.mjs";
package/dist/zod.d.mts ADDED
@@ -0,0 +1,30 @@
1
+ import { KType } from "./k/types.mjs";
2
+ import * as z from "zod/mini";
3
+ /** The Zod Mini schema `toZod` produces: the `k` schema's output and input, except that transforms are not carried. */
4
+ export type KZod<S extends KType> = z.ZodMiniType<S['_t'] extends true ? S['validator']['type'] : S['_output'], S['validator']['type']>;
5
+ /** Metadata `toZod` records on every converted `k.id`: the table the id belongs to. */
6
+ export type KZodIdMeta = {
7
+ tableName: string;
8
+ };
9
+ /**
10
+ * The registry holding {@link KZodIdMeta} for converted ids: `kZodIds.get(schema)?.tableName` reads
11
+ * which table an id schema belongs to. An id converts to a plain `z.string()` (it parses exactly as
12
+ * `k.id` does), so libraries that convert Zod to Convex validators see a string, not an id.
13
+ */
14
+ export declare const kZodIds: z.core.$ZodRegistry<KZodIdMeta, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
15
+ declare global {
16
+ interface CvxKitSchemaMethods {
17
+ /** Convert to Zod 4; see {@link toZod}. Installed by importing `cvx-kit/zod`. */
18
+ toZod<S extends KType>(this: S): KZod<S>;
19
+ }
20
+ }
21
+ /**
22
+ * Convert a `k` schema to a Zod 4 (`zod/mini`) schema, node by node. Ids keep their table typing in
23
+ * {@link KZod} and record their table name in {@link kZodIds}. Carried: structure, strict objects (`strip()` objects strip), `min`, `max`,
24
+ * `length`, `regex`, `int`, `trim`, case normalisers, defaults (as `prefault`, so a default runs through the chain like in `k`; a
25
+ * `partial()` field drops its default), ISO date and date-time formats,
26
+ * timestamps and `describe`. Not carried: `refine`, `check`, `overwrite`, `transform` and `pipe`; a
27
+ * transformed schema converts to its input schema, and checks declared after a transform are dropped.
28
+ */
29
+ export declare function toZod<S extends KType>(schema: S): KZod<S>;
30
+ //# sourceMappingURL=zod.d.mts.map
package/dist/zod.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{membersOf as e}from"./k/compile.mjs";import{maxTimestamp as t}from"./k/formats.mjs";import{KSchema as n}from"./k/schema.mjs";import*as r from"zod/mini";const i=r.registry();function a(e){return s(e)}Object.defineProperty(n.prototype,"toZod",{value:o,writable:!0,configurable:!0});function o(){return s(this)}function s(e){let t=[];for(let n=e;n!==null;n=n.prev)t.push(n);let n=c(t.pop(),t.some(v)),i=t.findIndex(_),a=!1,o,s=[];for(let e=t.length-1;e>=0;e--){let c=t[e];if(h(c))a||s.push(c);else if(c.op===`describe`)o=y(c);else switch(n=l(n,s),s=[],c.op){case`transform`:case`pipe`:a=!0;break;case`optional`:case`partial`:n=r.optional(n);break;case`nullable`:n=r.nullable(n);break;case`default`:!a&&!(i>=0&&e>i)&&(n=p(n,c))}}return n=l(n,s),o===void 0?n:n.check(r.describe(o))}function c(n,a){switch(n.op){case`string`:return r.string();case`isoDate`:return r.iso.date();case`isoDateTime`:return r.iso.datetime({offset:!0});case`id`:return r.string().register(i,{tableName:n.arg});case`number`:return r.number();case`int`:return r.int();case`timestamp`:return r.int().check(r.minimum(0),r.maximum(t));case`int64`:return r.bigint();case`boolean`:return r.boolean();case`null`:return r.null();case`bytes`:return r.instanceof(ArrayBuffer);case`any`:return r.any();case`json`:return r.json();case`literal`:return r.literal(n.arg);case`enum`:return r.enum(n.arg);case`array`:return r.array(s(n.arg));case`object`:{let e=n.arg,t={};for(let n in e)t[n]=s(e[n]);return a?r.object(t):r.strictObject(t)}case`record`:{let[e,t]=n.arg;return r.record(s(e),s(t))}case`union`:return r.union(e(n).map(s));case`discriminatedUnion`:{let{key:e,options:t}=n.arg,i=t.map(s);return r.discriminatedUnion(e,i)}default:throw Error(`toZod: '${n.op}' is not a root operation`)}}function l(e,t){let n=e;for(let e of t)g(e)&&(n=d(n,e));for(let e of t)g(e)||(n=f(n,e));return n}function u(e){return e._zod.def.type}function d(e,t){return u(e)===`string`?t.op===`trim`?e.check(r.trim()):t.op===`lower`?e.check(r.toLowerCase()):t.op===`upper`?e.check(r.toUpperCase()):e:e}function f(e,t){let n=m(t.message),i=u(e);if(t.op===`regex`){let a=t.arg;return i===`string`?e.check(r.regex(a,n)):e}if(t.op===`int`)return i===`number`?e.check(r.int(n)):e;if(t.op!==`min`&&t.op!==`max`&&t.op!==`length`)return e;let a=t.arg;if(i===`string`||i===`array`)return t.op===`min`?e.check(r.minLength(a,n)):t.op===`max`?e.check(r.maxLength(a,n)):e.check(r.length(a,n));if(i===`number`){if(t.op===`min`)return e.check(r.minimum(a,n));if(t.op===`max`)return e.check(r.maximum(a,n))}return e}function p(e,t){return r.prefault(e,t.arg)}function m(e){if(e!==void 0)return typeof e==`string`?e:e.message}function h(e){switch(e.op){case`min`:case`max`:case`length`:case`regex`:case`int`:case`trim`:case`lower`:case`upper`:case`refine`:case`check`:case`overwrite`:return!0;default:return!1}}function g(e){return e.op===`trim`||e.op===`lower`||e.op===`upper`}function _(e){return e.op===`partial`}function v(e){return e.op===`strip`}function y(e){return e.arg}export{i as kZodIds,a as toZod};
2
+ //# sourceMappingURL=zod.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod.mjs","names":["z","kZodIds","toZod","convert","schema","KSchema","toZodMethod","records","current","node","out","rootSchema","isStrip","partialAt","isPartial","transformed","description","run","index","record","isRunOp","textOf","applyRun","withDefault","root","maxTimestamp","fields","converted","key","strip","value","membersOf","objects","options","base","isNormaliser","applyNormaliser","applyCheck","kindOf","message","messageOf","kind","pattern","limit"],"sources":["../src/zod.ts"],"sourcesContent":["/**\n * Zod interop (KTD7): `toZod()` as a function, and as a method that importing this entry installs on\n * every `k` schema. Schemas are built with `zod/mini`, so the entry bundles Zod's core and the few\n * constructors used here, not the classic method API: a result parses, checks and feeds any library\n * that accepts a Zod 4 schema, and is extended with `zod/mini` functions. Core declarations never mention Zod; the method's type comes from the global\n * `CvxKitSchemaMethods` augmentation below, so only apps that import `cvx-kit/zod` see it. (A module\n * augmentation of `./k/schema` would not resolve from the built `.d.mts` files.)\n */\nimport * as z from 'zod/mini'\nimport { membersOf } from './k/compile'\nimport { maxTimestamp } from './k/formats'\nimport { KSchema } from './k/schema'\nimport type { KDiscriminated, KFields, KLiteralValue, KMessage, KNode, KType } from './k/types'\n\n/** The Zod Mini schema `toZod` produces: the `k` schema's output and input, except that transforms are not carried. */\nexport type KZod<S extends KType> = z.ZodMiniType<\n\tS['_t'] extends true ? S['validator']['type'] : S['_output'],\n\tS['validator']['type']\n>\n\n/** Metadata `toZod` records on every converted `k.id`: the table the id belongs to. */\nexport type KZodIdMeta = { tableName: string }\n\n/**\n * The registry holding {@link KZodIdMeta} for converted ids: `kZodIds.get(schema)?.tableName` reads\n * which table an id schema belongs to. An id converts to a plain `z.string()` (it parses exactly as\n * `k.id` does), so libraries that convert Zod to Convex validators see a string, not an id.\n */\nexport const kZodIds = z.registry<KZodIdMeta>()\n\ndeclare global {\n\tinterface CvxKitSchemaMethods {\n\t\t/** Convert to Zod 4; see {@link toZod}. Installed by importing `cvx-kit/zod`. */\n\t\ttoZod<S extends KType>(this: S): KZod<S>\n\t}\n}\n\n/**\n * Convert a `k` schema to a Zod 4 (`zod/mini`) schema, node by node. Ids keep their table typing in\n * {@link KZod} and record their table name in {@link kZodIds}. Carried: structure, strict objects (`strip()` objects strip), `min`, `max`,\n * `length`, `regex`, `int`, `trim`, case normalisers, defaults (as `prefault`, so a default runs through the chain like in `k`; a\n * `partial()` field drops its default), ISO date and date-time formats,\n * timestamps and `describe`. Not carried: `refine`, `check`, `overwrite`, `transform` and `pipe`; a\n * transformed schema converts to its input schema, and checks declared after a transform are dropped.\n */\nexport function toZod<S extends KType>(schema: S): KZod<S> {\n\t// SAFETY: convert mirrors the schema's structure and declared checks node by node.\n\treturn convert(schema) as KZod<S>\n}\n\nObject.defineProperty(KSchema.prototype, 'toZod', {\n\tvalue: toZodMethod,\n\twritable: true,\n\tconfigurable: true,\n})\n\nfunction toZodMethod(this: KType): Mini {\n\treturn convert(this)\n}\n\ntype Mini = z.ZodMiniType\n\nfunction convert(node: KNode): Mini {\n\tconst records: KNode[] = []\n\tfor (let current: KNode | null = node; current !== null; current = current.prev)\n\t\trecords.push(current)\n\t// SAFETY: a chain always ends at a root record.\n\tconst root = records.pop() as KNode\n\tlet out = rootSchema(root, records.some(isStrip))\n\tconst partialAt = records.findIndex(isPartial)\n\tlet transformed = false\n\tlet description: string | undefined\n\tlet run: KNode[] = []\n\tfor (let index = records.length - 1; index >= 0; index--) {\n\t\tconst record = records[index]\n\t\tif (isRunOp(record)) {\n\t\t\tif (!transformed) run.push(record)\n\t\t\tcontinue\n\t\t}\n\t\tif (record.op === 'describe') {\n\t\t\tdescription = textOf(record)\n\t\t\tcontinue\n\t\t}\n\t\tout = applyRun(out, run)\n\t\trun = []\n\t\tswitch (record.op) {\n\t\t\tcase 'transform':\n\t\t\tcase 'pipe':\n\t\t\t\ttransformed = true\n\t\t\t\tbreak\n\t\t\tcase 'optional':\n\t\t\tcase 'partial':\n\t\t\t\tout = z.optional(out)\n\t\t\t\tbreak\n\t\t\tcase 'nullable':\n\t\t\t\tout = z.nullable(out)\n\t\t\t\tbreak\n\t\t\tcase 'default':\n\t\t\t\tif (!transformed && !(partialAt >= 0 && index > partialAt)) out = withDefault(out, record)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t}\n\tout = applyRun(out, run)\n\treturn description === undefined ? out : out.check(z.describe(description))\n}\n\nfunction rootSchema(root: KNode, strip: boolean): Mini {\n\tswitch (root.op) {\n\t\tcase 'string':\n\t\t\treturn z.string()\n\t\tcase 'isoDate':\n\t\t\treturn z.iso.date()\n\t\tcase 'isoDateTime':\n\t\t\treturn z.iso.datetime({ offset: true })\n\t\tcase 'id':\n\t\t\t// SAFETY: k.id stores its table name as the root argument.\n\t\t\treturn z.string().register(kZodIds, { tableName: root.arg as string })\n\t\tcase 'number':\n\t\t\treturn z.number()\n\t\tcase 'int':\n\t\t\treturn z.int()\n\t\tcase 'timestamp':\n\t\t\treturn z.int().check(z.minimum(0), z.maximum(maxTimestamp))\n\t\tcase 'int64':\n\t\t\treturn z.bigint()\n\t\tcase 'boolean':\n\t\t\treturn z.boolean()\n\t\tcase 'null':\n\t\t\treturn z.null()\n\t\tcase 'bytes':\n\t\t\treturn z.instanceof(ArrayBuffer)\n\t\tcase 'any':\n\t\t\treturn z.any()\n\t\tcase 'json':\n\t\t\treturn z.json()\n\t\tcase 'literal':\n\t\t\t// SAFETY: k.literal stores its value as the root argument.\n\t\t\treturn z.literal(root.arg as KLiteralValue)\n\t\tcase 'enum':\n\t\t\t// SAFETY: k.enum stores its non-empty value list as the root argument.\n\t\t\treturn z.enum(root.arg as readonly [string, ...string[]])\n\t\tcase 'array':\n\t\t\t// SAFETY: k.array stores its element schema as the root argument.\n\t\t\treturn z.array(convert(root.arg as KType))\n\t\tcase 'object': {\n\t\t\t// SAFETY: k.object stores its field map as the root argument.\n\t\t\tconst fields = root.arg as KFields\n\t\t\tconst converted: Record<string, Mini> = {}\n\t\t\tfor (const key in fields) converted[key] = convert(fields[key])\n\t\t\treturn strip ? z.object(converted) : z.strictObject(converted)\n\t\t}\n\t\tcase 'record': {\n\t\t\t// SAFETY: k.record stores its key and value schemas as the root argument.\n\t\t\tconst [key, value] = root.arg as readonly KType[]\n\t\t\t// SAFETY: record keys are k.string() or k.id(), which convert to Zod record keys.\n\t\t\treturn z.record(convert(key) as z.ZodMiniString, convert(value))\n\t\t}\n\t\tcase 'union':\n\t\t\treturn z.union(membersOf(root).map(convert))\n\t\tcase 'discriminatedUnion': {\n\t\t\t// SAFETY: k.discriminatedUnion stores its key and object options as the root argument.\n\t\t\tconst { key, options } = root.arg as KDiscriminated\n\t\t\t// SAFETY: each option is a k.object, which converts to a Zod object.\n\t\t\tconst objects = options.map(convert) as [z.ZodMiniObject, ...z.ZodMiniObject[]]\n\t\t\treturn z.discriminatedUnion(key, objects)\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(`toZod: '${root.op}' is not a root operation`)\n\t}\n}\n\n/** Apply one run of chained conveniences: normalisers first, then checks, as `k` parses them. */\nfunction applyRun(base: Mini, run: readonly KNode[]): Mini {\n\tlet out = base\n\tfor (const record of run) if (isNormaliser(record)) out = applyNormaliser(out, record)\n\tfor (const record of run) if (!isNormaliser(record)) out = applyCheck(out, record)\n\treturn out\n}\n\n/** The Zod definition kind: a string format is a `string`, a number format a `number`. */\nfunction kindOf(schema: Mini): string {\n\treturn schema._zod.def.type\n}\n\nfunction applyNormaliser(base: Mini, record: KNode): Mini {\n\tif (kindOf(base) !== 'string') return base\n\tif (record.op === 'trim') return base.check(z.trim())\n\tif (record.op === 'lower') return base.check(z.toLowerCase())\n\tif (record.op === 'upper') return base.check(z.toUpperCase())\n\treturn base\n}\n\nfunction applyCheck(base: Mini, record: KNode): Mini {\n\tconst message = messageOf(record.message)\n\tconst kind = kindOf(base)\n\tif (record.op === 'regex') {\n\t\t// SAFETY: .regex stores its pattern as the record argument.\n\t\tconst pattern = record.arg as RegExp\n\t\treturn kind === 'string' ? base.check(z.regex(pattern, message)) : base\n\t}\n\tif (record.op === 'int') return kind === 'number' ? base.check(z.int(message)) : base\n\tif (record.op !== 'min' && record.op !== 'max' && record.op !== 'length') return base\n\t// SAFETY: min, max and length store their numeric limit as the record argument.\n\tconst limit = record.arg as number\n\tif (kind === 'string' || kind === 'array') {\n\t\tif (record.op === 'min') return base.check(z.minLength(limit, message))\n\t\tif (record.op === 'max') return base.check(z.maxLength(limit, message))\n\t\treturn base.check(z.length(limit, message))\n\t}\n\tif (kind === 'number') {\n\t\tif (record.op === 'min') return base.check(z.minimum(limit, message))\n\t\tif (record.op === 'max') return base.check(z.maximum(limit, message))\n\t}\n\treturn base\n}\n\n/**\n * `k` runs a default through the rest of the chain (normalisers, checks), so it maps to Zod's\n * `prefault`, not `default`, which would short-circuit.\n */\nfunction withDefault(base: Mini, record: KNode): Mini {\n\t// SAFETY: a default record stores a value of the schema's input type here (no transform below it).\n\treturn z.prefault(base, record.arg as never)\n}\n\nfunction messageOf(message: KMessage): string | undefined {\n\tif (message === undefined) return undefined\n\t// oxlint-disable-next-line anti-slop/no-runtime-typeof -- refine stores either its message or its options object.\n\treturn typeof message === 'string' ? message : message.message\n}\n\nfunction isRunOp(record: KNode): boolean {\n\tswitch (record.op) {\n\t\tcase 'min':\n\t\tcase 'max':\n\t\tcase 'length':\n\t\tcase 'regex':\n\t\tcase 'int':\n\t\tcase 'trim':\n\t\tcase 'lower':\n\t\tcase 'upper':\n\t\tcase 'refine':\n\t\tcase 'check':\n\t\tcase 'overwrite':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunction isNormaliser(record: KNode): boolean {\n\treturn record.op === 'trim' || record.op === 'lower' || record.op === 'upper'\n}\n\n/** A `partial()` field is optional and never receives the default declared below it. */\nfunction isPartial(record: KNode): boolean {\n\treturn record.op === 'partial'\n}\n\nfunction isStrip(record: KNode): boolean {\n\treturn record.op === 'strip'\n}\n\nfunction textOf(record: KNode): string {\n\t// SAFETY: a describe record stores its text as the record argument.\n\treturn record.arg as string\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,19 +1,63 @@
1
1
  {
2
2
  "name": "cvx-kit",
3
- "version": "0.2.0",
4
- "description": "Reusable Convex application kit: foundation kernels, approvals component, zod table boundaries, WorkOS-backed auth function constructors, and audited command protocol.",
5
- "type": "module",
3
+ "version": "2.0.0-beta.0",
4
+ "description": "Reusable Convex application kit: foundation kernels, approvals component, table boundaries on native Convex validators, WorkOS-backed auth function constructors, and audited command protocol.",
5
+ "keywords": [
6
+ "component",
7
+ "convex",
8
+ "validators",
9
+ "workos"
10
+ ],
11
+ "homepage": "https://github.com/ImRLopezAG/cvx-kit#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/ImRLopezAG/cvx-kit/issues"
14
+ },
6
15
  "license": "MIT",
7
- "sideEffects": false,
16
+ "author": "Angel Lopez",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/ImRLopezAG/cvx-kit.git"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src/test.ts",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "type": "module",
28
+ "sideEffects": [
29
+ "./dist/zod.mjs",
30
+ "./src/zod.ts"
31
+ ],
8
32
  "exports": {
9
33
  "./package.json": "./package.json",
10
34
  ".": {
11
35
  "types": "./dist/index.d.mts",
12
36
  "import": "./dist/index.mjs"
13
37
  },
14
- "./zod-table": {
15
- "types": "./dist/zod-table.d.mts",
16
- "import": "./dist/zod-table.mjs"
38
+ "./relations": {
39
+ "types": "./dist/relations-public.d.mts",
40
+ "import": "./dist/relations-public.mjs"
41
+ },
42
+ "./querying": {
43
+ "types": "./dist/querying.d.mts",
44
+ "import": "./dist/querying.mjs"
45
+ },
46
+ "./effect": {
47
+ "types": "./dist/effect.d.mts",
48
+ "import": "./dist/effect.mjs"
49
+ },
50
+ "./contracts": {
51
+ "types": "./dist/contracts.d.mts",
52
+ "import": "./dist/contracts.mjs"
53
+ },
54
+ "./idempotency": {
55
+ "types": "./dist/idempotency.d.mts",
56
+ "import": "./dist/idempotency.mjs"
57
+ },
58
+ "./workflow": {
59
+ "types": "./dist/workflow.d.mts",
60
+ "import": "./dist/workflow.mjs"
17
61
  },
18
62
  "./auth": {
19
63
  "types": "./dist/auth.d.mts",
@@ -51,6 +95,26 @@
51
95
  "types": "./dist/errors.d.mts",
52
96
  "import": "./dist/errors.mjs"
53
97
  },
98
+ "./k": {
99
+ "types": "./dist/k.d.mts",
100
+ "import": "./dist/k.mjs"
101
+ },
102
+ "./table": {
103
+ "types": "./dist/table.d.mts",
104
+ "import": "./dist/table.mjs"
105
+ },
106
+ "./registration": {
107
+ "types": "./dist/registration.d.mts",
108
+ "import": "./dist/registration.mjs"
109
+ },
110
+ "./json-schema": {
111
+ "types": "./dist/json-schema.d.mts",
112
+ "import": "./dist/json-schema.mjs"
113
+ },
114
+ "./zod": {
115
+ "types": "./dist/zod.d.mts",
116
+ "import": "./dist/zod.mjs"
117
+ },
54
118
  "./test": "./src/test.ts",
55
119
  "./components/foundation": {
56
120
  "types": "./dist/components/foundation/client.d.mts",
@@ -85,52 +149,100 @@
85
149
  },
86
150
  "./components/approvals/_generated/component": {
87
151
  "types": "./dist/components/approvals/_generated/component.d.mts"
152
+ },
153
+ "./oxlint": {
154
+ "types": "./dist/oxlint.d.mts",
155
+ "import": "./dist/oxlint.mjs"
156
+ },
157
+ "./filters": {
158
+ "types": "./dist/filters.d.mts",
159
+ "import": "./dist/filters.mjs"
160
+ },
161
+ "./react": {
162
+ "types": "./dist/react.d.mts",
163
+ "import": "./dist/react.mjs"
88
164
  }
89
165
  },
90
166
  "scripts": {
167
+ "lint": "vp lint",
168
+ "check": "vp check",
169
+ "test:lint": "vp test run tools/oxlint/cvx",
91
170
  "build": "vp pack && node scripts/convex-config-bridge.mjs && publint",
92
171
  "typecheck": "tsc --noEmit",
93
172
  "test": "vp test run --exclude test/package-contents.test.mjs",
173
+ "test:integration": "node scripts/test-ci-integration.mjs",
94
174
  "test:package": "bun run build && vp test run test/package-contents.test.mjs",
175
+ "test:package:ids": "bun run build && node scripts/test-packed-ids.mjs",
176
+ "test:package:variants": "bun run build && node scripts/test-packed-variants.mjs",
177
+ "test:package:variant-querying": "bun run build && node scripts/test-packed-variant-querying.mjs",
178
+ "test:package:oxlint": "bun run build && node scripts/test-packed-oxlint.mjs",
179
+ "test:package:effect": "bun run build && node scripts/test-packed-effect.mjs",
180
+ "test:package:auth": "bun run build && node scripts/test-packed-auth.mjs",
181
+ "test:package:querying": "bun run build && node scripts/test-packed-querying.mjs",
182
+ "test:package:smoke:effect": "bun run build && node scripts/smoke-packed-effect.mjs",
95
183
  "test:package:smoke:bun": "bun scripts/smoke-packed-components.mjs bun",
96
184
  "test:package:smoke:npm": "node scripts/smoke-packed-components.mjs npm",
97
- "docs:sync": "rm -f docs/*.md && cp src/docs/*.md docs/",
98
- "prepublishOnly": "bun run build && bun run typecheck && bun run test && bun run docs:sync",
185
+ "skills:check": "node scripts/check-skills.mjs",
186
+ "bench:app-load": "node scripts/bench-app-load.mjs --check scripts/bench/app-load-budget.json",
187
+ "prepublishOnly": "bun run build && bun run typecheck && bun run test && bun run skills:check",
99
188
  "build:codegen": "convex codegen --component-dir ./src/components/foundation && convex codegen --component-dir ./src/components/approvals && vp pack",
100
189
  "release": "npm version patch && git push --follow-tags",
101
190
  "release:minor": "npm version minor && git push --follow-tags"
102
191
  },
103
192
  "dependencies": {
104
- "@convex-dev/workflow": "0.4.4",
193
+ "@convex-dev/workflow": "0.5.0",
194
+ "@noble/ciphers": "2.4.0",
195
+ "@oxlint/plugins": "1.95.0",
196
+ "@standard-schema/spec": "^1.1.0",
105
197
  "convex-audit-log": "^0.2.0",
106
- "convex-helpers": "0.1.122"
107
- },
108
- "peerDependencies": {
109
- "convex": "^1.43.0",
110
- "zod": "^4.0.0"
198
+ "oxc-parser": "0.160.0",
199
+ "oxc-resolver": "11.24.2"
111
200
  },
112
201
  "devDependencies": {
113
202
  "@edge-runtime/vm": "^5.0.0",
114
- "convex": "1.43.0",
115
- "convex-test": "^0.0.55",
116
- "publint": "^0.3.23",
203
+ "@types/node": "^26.6.11",
204
+ "@types/react": "19.3.3",
205
+ "@types/react-dom": "19.3.0",
206
+ "convex": "1.51.0",
207
+ "convex-helpers": "0.1.137",
208
+ "convex-test": "^0.0.75",
209
+ "effect": "4.1.6",
210
+ "jsdom": "31.0.1",
211
+ "oxlint": "1.95.0",
212
+ "publint": "^0.3.25",
213
+ "react": "19.3.1",
214
+ "react-dom": "19.3.1",
117
215
  "typescript": "7.0.2",
118
- "vite-plus": "0.2.8",
119
- "zod": "4.4.3"
216
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
217
+ "vite-plus": "1.8.0",
218
+ "zod": "4.6.7"
120
219
  },
121
- "keywords": [
122
- "convex",
123
- "component",
124
- "workos",
125
- "zod"
126
- ],
127
- "author": "Angel Lopez",
128
- "repository": {
129
- "type": "git",
130
- "url": "git+https://github.com/ImRLopezAG/cvx-kit.git"
220
+ "peerDependencies": {
221
+ "convex": "^1.46.0",
222
+ "convex-helpers": ">=0.1.130 <0.2.0",
223
+ "effect": ">=4.0.1 <5",
224
+ "react": "^18.0.0 || ^19.0.0",
225
+ "zod": "^4.6.7"
131
226
  },
132
- "homepage": "https://github.com/ImRLopezAG/cvx-kit#readme",
133
- "bugs": {
134
- "url": "https://github.com/ImRLopezAG/cvx-kit/issues"
227
+ "peerDependenciesMeta": {
228
+ "zod": {
229
+ "optional": true
230
+ },
231
+ "effect": {
232
+ "optional": true
233
+ },
234
+ "react": {
235
+ "optional": true
236
+ }
237
+ },
238
+ "overrides": {
239
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001"
240
+ },
241
+ "devEngines": {
242
+ "packageManager": {
243
+ "name": "bun",
244
+ "version": "1.4.2",
245
+ "onFail": "download"
246
+ }
135
247
  }
136
248
  }
package/src/test.ts CHANGED
@@ -6,29 +6,21 @@
6
6
  * registers the COMPILED component modules from dist, so dist is the only
7
7
  * code the package ships.
8
8
  */
9
+ import type { TestConvex } from 'convex-test'
10
+ import type { GenericSchema, SchemaDefinition } from 'convex/server'
9
11
  import approvalsSchema from '../dist/components/approvals/schema.js'
10
12
  import foundationSchema from '../dist/components/foundation/schema.js'
11
13
 
12
- const foundationModules = import.meta.glob(
13
- '../dist/components/foundation/**/*.mjs',
14
- )
15
- const approvalsModules = import.meta.glob(
16
- '../dist/components/approvals/**/*.mjs',
17
- )
14
+ const foundationModules = import.meta.glob('../dist/components/foundation/**/*.mjs')
15
+ const approvalsModules = import.meta.glob('../dist/components/approvals/**/*.mjs')
18
16
 
19
- type RegistersComponents = {
20
- registerComponent: (
21
- name: string,
22
- schema: unknown,
23
- modules: Record<string, () => Promise<unknown>>,
24
- ) => void
25
- }
17
+ type RegistersComponents = Pick<
18
+ TestConvex<SchemaDefinition<GenericSchema, boolean>>,
19
+ 'registerComponent'
20
+ >
26
21
 
27
22
  /** Registers the foundation component under its default install name. */
28
- export function registerFoundation(
29
- t: RegistersComponents,
30
- name = 'foundation',
31
- ) {
23
+ export function registerFoundation(t: RegistersComponents, name = 'foundation') {
32
24
  t.registerComponent(name, foundationSchema, foundationModules)
33
25
  }
34
26