@qlever-llc/trellis 0.10.22 → 0.11.0-rc.1

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 (406) hide show
  1. package/esm/auth/mod.d.ts +1 -1
  2. package/esm/auth/mod.d.ts.map +1 -1
  3. package/esm/auth/mod.js +1 -1
  4. package/esm/auth/protocol.d.ts +55 -0
  5. package/esm/auth/protocol.d.ts.map +1 -1
  6. package/esm/browser.d.ts +3 -3
  7. package/esm/browser.d.ts.map +1 -1
  8. package/esm/browser.js +1 -1
  9. package/esm/client_connect.d.ts +12 -3
  10. package/esm/client_connect.d.ts.map +1 -1
  11. package/esm/client_connect.js +112 -7
  12. package/esm/codec.d.ts +7 -6
  13. package/esm/codec.d.ts.map +1 -1
  14. package/esm/codec.js +125 -6
  15. package/esm/contract_support/canonical.d.ts +3 -0
  16. package/esm/contract_support/canonical.d.ts.map +1 -1
  17. package/esm/contract_support/canonical.js +3 -0
  18. package/esm/contract_support/mod.d.ts +125 -10
  19. package/esm/contract_support/mod.d.ts.map +1 -1
  20. package/esm/contract_support/mod.js +159 -5
  21. package/esm/contract_support/protocol.d.ts +92 -7
  22. package/esm/contract_support/protocol.d.ts.map +1 -1
  23. package/esm/contract_support/protocol.js +41 -7
  24. package/esm/contract_support/runtime.d.ts +4 -1
  25. package/esm/contract_support/runtime.d.ts.map +1 -1
  26. package/esm/errors/SchemaValidationError.d.ts +49 -0
  27. package/esm/errors/SchemaValidationError.d.ts.map +1 -0
  28. package/esm/errors/SchemaValidationError.js +67 -0
  29. package/esm/errors/index.d.ts +38 -9
  30. package/esm/errors/index.d.ts.map +1 -1
  31. package/esm/errors/index.js +16 -0
  32. package/esm/generated-sdk/auth/api.d.ts +33 -605
  33. package/esm/generated-sdk/auth/api.d.ts.map +1 -1
  34. package/esm/generated-sdk/auth/api.js +6 -1
  35. package/esm/generated-sdk/auth/client.d.ts +129 -134
  36. package/esm/generated-sdk/auth/client.d.ts.map +1 -1
  37. package/esm/generated-sdk/auth/contract.d.ts +2 -601
  38. package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
  39. package/esm/generated-sdk/auth/contract.js +310 -93
  40. package/esm/generated-sdk/auth/mod.d.ts +1 -1
  41. package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
  42. package/esm/generated-sdk/auth/owned_api.d.ts +88 -86
  43. package/esm/generated-sdk/auth/owned_api.d.ts.map +1 -1
  44. package/esm/generated-sdk/auth/owned_api.js +6 -0
  45. package/esm/generated-sdk/auth/schemas.d.ts +284 -136
  46. package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
  47. package/esm/generated-sdk/auth/schemas.js +231 -92
  48. package/esm/generated-sdk/auth/types.d.ts +565 -89
  49. package/esm/generated-sdk/auth/types.d.ts.map +1 -1
  50. package/esm/generated-sdk/auth/types.js +1 -1
  51. package/esm/generated-sdk/health/api.d.ts +29 -18
  52. package/esm/generated-sdk/health/api.d.ts.map +1 -1
  53. package/esm/generated-sdk/health/client.d.ts +7 -21
  54. package/esm/generated-sdk/health/client.d.ts.map +1 -1
  55. package/esm/generated-sdk/health/contract.d.ts +2 -15
  56. package/esm/generated-sdk/health/contract.d.ts.map +1 -1
  57. package/esm/generated-sdk/health/contract.js +2 -10
  58. package/esm/generated-sdk/health/mod.d.ts +1 -1
  59. package/esm/generated-sdk/health/mod.d.ts.map +1 -1
  60. package/esm/generated-sdk/health/owned_api.d.ts +2 -2
  61. package/esm/generated-sdk/health/schemas.d.ts +1 -14
  62. package/esm/generated-sdk/health/schemas.d.ts.map +1 -1
  63. package/esm/generated-sdk/health/schemas.js +1 -9
  64. package/esm/generated-sdk/health/types.d.ts +10 -5
  65. package/esm/generated-sdk/health/types.d.ts.map +1 -1
  66. package/esm/generated-sdk/health/types.js +1 -2
  67. package/esm/generated-sdk/jobs/api.d.ts +29 -109
  68. package/esm/generated-sdk/jobs/api.d.ts.map +1 -1
  69. package/esm/generated-sdk/jobs/client.d.ts +21 -33
  70. package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
  71. package/esm/generated-sdk/jobs/contract.d.ts +2 -106
  72. package/esm/generated-sdk/jobs/contract.d.ts.map +1 -1
  73. package/esm/generated-sdk/jobs/contract.js +268 -1
  74. package/esm/generated-sdk/jobs/mod.d.ts +1 -1
  75. package/esm/generated-sdk/jobs/mod.d.ts.map +1 -1
  76. package/esm/generated-sdk/jobs/owned_api.d.ts +22 -9
  77. package/esm/generated-sdk/jobs/owned_api.d.ts.map +1 -1
  78. package/esm/generated-sdk/jobs/owned_api.js +20 -1
  79. package/esm/generated-sdk/jobs/schemas.d.ts +437 -0
  80. package/esm/generated-sdk/jobs/schemas.d.ts.map +1 -1
  81. package/esm/generated-sdk/jobs/schemas.js +211 -0
  82. package/esm/generated-sdk/jobs/types.d.ts +195 -12
  83. package/esm/generated-sdk/jobs/types.d.ts.map +1 -1
  84. package/esm/generated-sdk/jobs/types.js +1 -1
  85. package/esm/generated-sdk/state/api.d.ts +29 -68
  86. package/esm/generated-sdk/state/api.d.ts.map +1 -1
  87. package/esm/generated-sdk/state/client.d.ts +17 -31
  88. package/esm/generated-sdk/state/client.d.ts.map +1 -1
  89. package/esm/generated-sdk/state/contract.d.ts +1 -64
  90. package/esm/generated-sdk/state/contract.d.ts.map +1 -1
  91. package/esm/generated-sdk/state/mod.d.ts +1 -1
  92. package/esm/generated-sdk/state/mod.d.ts.map +1 -1
  93. package/esm/generated-sdk/state/owned_api.d.ts +7 -7
  94. package/esm/generated-sdk/state/types.d.ts +52 -9
  95. package/esm/generated-sdk/state/types.d.ts.map +1 -1
  96. package/esm/generated-sdk/trellis-core/api.d.ts +33 -45
  97. package/esm/generated-sdk/trellis-core/api.d.ts.map +1 -1
  98. package/esm/generated-sdk/trellis-core/api.js +6 -1
  99. package/esm/generated-sdk/trellis-core/client.d.ts +31 -20
  100. package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
  101. package/esm/generated-sdk/trellis-core/contract.d.ts +2 -41
  102. package/esm/generated-sdk/trellis-core/contract.d.ts.map +1 -1
  103. package/esm/generated-sdk/trellis-core/contract.js +91 -1
  104. package/esm/generated-sdk/trellis-core/mod.d.ts +1 -1
  105. package/esm/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  106. package/esm/generated-sdk/trellis-core/owned_api.d.ts +4 -4
  107. package/esm/generated-sdk/trellis-core/schemas.d.ts +113 -0
  108. package/esm/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
  109. package/esm/generated-sdk/trellis-core/schemas.js +81 -0
  110. package/esm/generated-sdk/trellis-core/types.d.ts +54 -7
  111. package/esm/generated-sdk/trellis-core/types.d.ts.map +1 -1
  112. package/esm/generated-sdk/trellis-core/types.js +1 -1
  113. package/esm/health.d.ts +1 -1
  114. package/esm/health.d.ts.map +1 -1
  115. package/esm/health.js +1 -1
  116. package/esm/index.d.ts +4 -4
  117. package/esm/index.d.ts.map +1 -1
  118. package/esm/index.js +2 -2
  119. package/esm/jobs.d.ts +69 -3
  120. package/esm/jobs.d.ts.map +1 -1
  121. package/esm/jobs.js +92 -3
  122. package/esm/server/health.d.ts +2 -6
  123. package/esm/server/health.d.ts.map +1 -1
  124. package/esm/server/health_schemas.d.ts +0 -8
  125. package/esm/server/health_schemas.d.ts.map +1 -1
  126. package/esm/server/health_schemas.js +0 -5
  127. package/esm/server/internal_jobs/bindings.d.ts +11 -0
  128. package/esm/server/internal_jobs/bindings.d.ts.map +1 -1
  129. package/esm/server/internal_jobs/job-manager.d.ts +58 -2
  130. package/esm/server/internal_jobs/job-manager.d.ts.map +1 -1
  131. package/esm/server/internal_jobs/job-manager.js +429 -55
  132. package/esm/server/internal_jobs/key-coordinator.d.ts +269 -0
  133. package/esm/server/internal_jobs/key-coordinator.d.ts.map +1 -0
  134. package/esm/server/internal_jobs/key-coordinator.js +677 -0
  135. package/esm/server/internal_jobs/projection.d.ts.map +1 -1
  136. package/esm/server/internal_jobs/projection.js +2 -0
  137. package/esm/server/internal_jobs/runtime-worker.d.ts +5 -1
  138. package/esm/server/internal_jobs/runtime-worker.d.ts.map +1 -1
  139. package/esm/server/internal_jobs/runtime-worker.js +14 -2
  140. package/esm/server/internal_jobs/types.d.ts +5 -5
  141. package/esm/server/internal_jobs/types.d.ts.map +1 -1
  142. package/esm/server/internal_jobs/types.js +6 -0
  143. package/esm/server/runtime.d.ts.map +1 -1
  144. package/esm/server/service.d.ts +81 -112
  145. package/esm/server/service.d.ts.map +1 -1
  146. package/esm/server/service.js +372 -130
  147. package/esm/server.d.ts +3 -3
  148. package/esm/server.d.ts.map +1 -1
  149. package/esm/service/deno.d.ts +1 -1
  150. package/esm/service/deno.d.ts.map +1 -1
  151. package/esm/service/drizzle.d.ts +52 -0
  152. package/esm/service/drizzle.d.ts.map +1 -0
  153. package/esm/service/drizzle.js +108 -0
  154. package/esm/service/mod.d.ts +3 -3
  155. package/esm/service/mod.d.ts.map +1 -1
  156. package/esm/service/mod.js +2 -2
  157. package/esm/service/node.d.ts +1 -1
  158. package/esm/service/node.d.ts.map +1 -1
  159. package/esm/service/outbox_inbox.d.ts +76 -22
  160. package/esm/service/outbox_inbox.d.ts.map +1 -1
  161. package/esm/service/outbox_inbox.js +231 -70
  162. package/esm/telemetry/metrics.d.ts +55 -0
  163. package/esm/telemetry/metrics.d.ts.map +1 -1
  164. package/esm/telemetry/metrics.js +86 -0
  165. package/esm/telemetry/mod.d.ts +2 -1
  166. package/esm/telemetry/mod.d.ts.map +1 -1
  167. package/esm/telemetry/mod.js +1 -1
  168. package/esm/trellis.d.ts +62 -30
  169. package/esm/trellis.d.ts.map +1 -1
  170. package/esm/trellis.js +125 -42
  171. package/package.json +14 -2
  172. package/script/auth/mod.d.ts +1 -1
  173. package/script/auth/mod.d.ts.map +1 -1
  174. package/script/auth/mod.js +11 -4
  175. package/script/auth/protocol.d.ts +55 -0
  176. package/script/auth/protocol.d.ts.map +1 -1
  177. package/script/browser.d.ts +3 -3
  178. package/script/browser.d.ts.map +1 -1
  179. package/script/browser.js +3 -2
  180. package/script/client_connect.d.ts +12 -3
  181. package/script/client_connect.d.ts.map +1 -1
  182. package/script/client_connect.js +111 -6
  183. package/script/codec.d.ts +7 -6
  184. package/script/codec.d.ts.map +1 -1
  185. package/script/codec.js +124 -5
  186. package/script/contract_support/canonical.d.ts +3 -0
  187. package/script/contract_support/canonical.d.ts.map +1 -1
  188. package/script/contract_support/canonical.js +3 -0
  189. package/script/contract_support/mod.d.ts +125 -10
  190. package/script/contract_support/mod.d.ts.map +1 -1
  191. package/script/contract_support/mod.js +165 -5
  192. package/script/contract_support/protocol.d.ts +92 -7
  193. package/script/contract_support/protocol.d.ts.map +1 -1
  194. package/script/contract_support/protocol.js +42 -8
  195. package/script/contract_support/runtime.d.ts +4 -1
  196. package/script/contract_support/runtime.d.ts.map +1 -1
  197. package/script/errors/SchemaValidationError.d.ts +49 -0
  198. package/script/errors/SchemaValidationError.d.ts.map +1 -0
  199. package/script/errors/SchemaValidationError.js +74 -0
  200. package/script/errors/index.d.ts +38 -9
  201. package/script/errors/index.d.ts.map +1 -1
  202. package/script/errors/index.js +20 -1
  203. package/script/generated-sdk/auth/api.d.ts +33 -605
  204. package/script/generated-sdk/auth/api.d.ts.map +1 -1
  205. package/script/generated-sdk/auth/api.js +6 -1
  206. package/script/generated-sdk/auth/client.d.ts +129 -134
  207. package/script/generated-sdk/auth/client.d.ts.map +1 -1
  208. package/script/generated-sdk/auth/contract.d.ts +2 -601
  209. package/script/generated-sdk/auth/contract.d.ts.map +1 -1
  210. package/script/generated-sdk/auth/contract.js +310 -93
  211. package/script/generated-sdk/auth/mod.d.ts +1 -1
  212. package/script/generated-sdk/auth/mod.d.ts.map +1 -1
  213. package/script/generated-sdk/auth/owned_api.d.ts +88 -86
  214. package/script/generated-sdk/auth/owned_api.d.ts.map +1 -1
  215. package/script/generated-sdk/auth/owned_api.js +6 -0
  216. package/script/generated-sdk/auth/schemas.d.ts +284 -136
  217. package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
  218. package/script/generated-sdk/auth/schemas.js +231 -92
  219. package/script/generated-sdk/auth/types.d.ts +565 -89
  220. package/script/generated-sdk/auth/types.d.ts.map +1 -1
  221. package/script/generated-sdk/auth/types.js +1 -1
  222. package/script/generated-sdk/health/api.d.ts +29 -18
  223. package/script/generated-sdk/health/api.d.ts.map +1 -1
  224. package/script/generated-sdk/health/client.d.ts +7 -21
  225. package/script/generated-sdk/health/client.d.ts.map +1 -1
  226. package/script/generated-sdk/health/contract.d.ts +2 -15
  227. package/script/generated-sdk/health/contract.d.ts.map +1 -1
  228. package/script/generated-sdk/health/contract.js +2 -10
  229. package/script/generated-sdk/health/mod.d.ts +1 -1
  230. package/script/generated-sdk/health/mod.d.ts.map +1 -1
  231. package/script/generated-sdk/health/owned_api.d.ts +2 -2
  232. package/script/generated-sdk/health/schemas.d.ts +1 -14
  233. package/script/generated-sdk/health/schemas.d.ts.map +1 -1
  234. package/script/generated-sdk/health/schemas.js +1 -9
  235. package/script/generated-sdk/health/types.d.ts +10 -5
  236. package/script/generated-sdk/health/types.d.ts.map +1 -1
  237. package/script/generated-sdk/health/types.js +1 -2
  238. package/script/generated-sdk/jobs/api.d.ts +29 -109
  239. package/script/generated-sdk/jobs/api.d.ts.map +1 -1
  240. package/script/generated-sdk/jobs/client.d.ts +21 -33
  241. package/script/generated-sdk/jobs/client.d.ts.map +1 -1
  242. package/script/generated-sdk/jobs/contract.d.ts +2 -106
  243. package/script/generated-sdk/jobs/contract.d.ts.map +1 -1
  244. package/script/generated-sdk/jobs/contract.js +268 -1
  245. package/script/generated-sdk/jobs/mod.d.ts +1 -1
  246. package/script/generated-sdk/jobs/mod.d.ts.map +1 -1
  247. package/script/generated-sdk/jobs/owned_api.d.ts +22 -9
  248. package/script/generated-sdk/jobs/owned_api.d.ts.map +1 -1
  249. package/script/generated-sdk/jobs/owned_api.js +19 -0
  250. package/script/generated-sdk/jobs/schemas.d.ts +437 -0
  251. package/script/generated-sdk/jobs/schemas.d.ts.map +1 -1
  252. package/script/generated-sdk/jobs/schemas.js +212 -1
  253. package/script/generated-sdk/jobs/types.d.ts +195 -12
  254. package/script/generated-sdk/jobs/types.d.ts.map +1 -1
  255. package/script/generated-sdk/jobs/types.js +1 -1
  256. package/script/generated-sdk/state/api.d.ts +29 -68
  257. package/script/generated-sdk/state/api.d.ts.map +1 -1
  258. package/script/generated-sdk/state/client.d.ts +17 -31
  259. package/script/generated-sdk/state/client.d.ts.map +1 -1
  260. package/script/generated-sdk/state/contract.d.ts +1 -64
  261. package/script/generated-sdk/state/contract.d.ts.map +1 -1
  262. package/script/generated-sdk/state/mod.d.ts +1 -1
  263. package/script/generated-sdk/state/mod.d.ts.map +1 -1
  264. package/script/generated-sdk/state/owned_api.d.ts +7 -7
  265. package/script/generated-sdk/state/types.d.ts +52 -9
  266. package/script/generated-sdk/state/types.d.ts.map +1 -1
  267. package/script/generated-sdk/trellis-core/api.d.ts +33 -45
  268. package/script/generated-sdk/trellis-core/api.d.ts.map +1 -1
  269. package/script/generated-sdk/trellis-core/api.js +6 -1
  270. package/script/generated-sdk/trellis-core/client.d.ts +31 -20
  271. package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
  272. package/script/generated-sdk/trellis-core/contract.d.ts +2 -41
  273. package/script/generated-sdk/trellis-core/contract.d.ts.map +1 -1
  274. package/script/generated-sdk/trellis-core/contract.js +91 -1
  275. package/script/generated-sdk/trellis-core/mod.d.ts +1 -1
  276. package/script/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  277. package/script/generated-sdk/trellis-core/owned_api.d.ts +4 -4
  278. package/script/generated-sdk/trellis-core/schemas.d.ts +113 -0
  279. package/script/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
  280. package/script/generated-sdk/trellis-core/schemas.js +81 -0
  281. package/script/generated-sdk/trellis-core/types.d.ts +54 -7
  282. package/script/generated-sdk/trellis-core/types.d.ts.map +1 -1
  283. package/script/generated-sdk/trellis-core/types.js +1 -1
  284. package/script/health.d.ts +1 -1
  285. package/script/health.d.ts.map +1 -1
  286. package/script/health.js +1 -2
  287. package/script/index.d.ts +4 -4
  288. package/script/index.d.ts.map +1 -1
  289. package/script/index.js +2 -2
  290. package/script/jobs.d.ts +69 -3
  291. package/script/jobs.d.ts.map +1 -1
  292. package/script/jobs.js +93 -3
  293. package/script/server/health.d.ts +2 -6
  294. package/script/server/health.d.ts.map +1 -1
  295. package/script/server/health_schemas.d.ts +0 -8
  296. package/script/server/health_schemas.d.ts.map +1 -1
  297. package/script/server/health_schemas.js +1 -6
  298. package/script/server/internal_jobs/bindings.d.ts +11 -0
  299. package/script/server/internal_jobs/bindings.d.ts.map +1 -1
  300. package/script/server/internal_jobs/job-manager.d.ts +58 -2
  301. package/script/server/internal_jobs/job-manager.d.ts.map +1 -1
  302. package/script/server/internal_jobs/job-manager.js +429 -54
  303. package/script/server/internal_jobs/key-coordinator.d.ts +269 -0
  304. package/script/server/internal_jobs/key-coordinator.d.ts.map +1 -0
  305. package/script/server/internal_jobs/key-coordinator.js +690 -0
  306. package/script/server/internal_jobs/projection.d.ts.map +1 -1
  307. package/script/server/internal_jobs/projection.js +2 -0
  308. package/script/server/internal_jobs/runtime-worker.d.ts +5 -1
  309. package/script/server/internal_jobs/runtime-worker.d.ts.map +1 -1
  310. package/script/server/internal_jobs/runtime-worker.js +14 -2
  311. package/script/server/internal_jobs/types.d.ts +5 -5
  312. package/script/server/internal_jobs/types.d.ts.map +1 -1
  313. package/script/server/internal_jobs/types.js +6 -0
  314. package/script/server/runtime.d.ts.map +1 -1
  315. package/script/server/service.d.ts +81 -112
  316. package/script/server/service.d.ts.map +1 -1
  317. package/script/server/service.js +369 -127
  318. package/script/server.d.ts +3 -3
  319. package/script/server.d.ts.map +1 -1
  320. package/script/service/deno.d.ts +1 -1
  321. package/script/service/deno.d.ts.map +1 -1
  322. package/script/service/drizzle.d.ts +52 -0
  323. package/script/service/drizzle.d.ts.map +1 -0
  324. package/script/service/drizzle.js +113 -0
  325. package/script/service/mod.d.ts +3 -3
  326. package/script/service/mod.d.ts.map +1 -1
  327. package/script/service/mod.js +4 -3
  328. package/script/service/node.d.ts +1 -1
  329. package/script/service/node.d.ts.map +1 -1
  330. package/script/service/outbox_inbox.d.ts +76 -22
  331. package/script/service/outbox_inbox.d.ts.map +1 -1
  332. package/script/service/outbox_inbox.js +233 -70
  333. package/script/telemetry/metrics.d.ts +55 -0
  334. package/script/telemetry/metrics.d.ts.map +1 -1
  335. package/script/telemetry/metrics.js +88 -0
  336. package/script/telemetry/mod.d.ts +2 -1
  337. package/script/telemetry/mod.d.ts.map +1 -1
  338. package/script/telemetry/mod.js +3 -1
  339. package/script/trellis.d.ts +62 -30
  340. package/script/trellis.d.ts.map +1 -1
  341. package/script/trellis.js +124 -41
  342. package/src/auth/mod.ts +7 -0
  343. package/src/browser.ts +5 -7
  344. package/src/client_connect.ts +200 -12
  345. package/src/codec.ts +186 -11
  346. package/src/contract_support/canonical.ts +3 -0
  347. package/src/contract_support/mod.ts +380 -9
  348. package/src/contract_support/protocol.ts +57 -10
  349. package/src/contract_support/runtime.ts +7 -0
  350. package/src/errors/SchemaValidationError.ts +67 -0
  351. package/src/errors/index.ts +28 -0
  352. package/src/health.ts +0 -1
  353. package/src/index.ts +7 -8
  354. package/src/jobs.ts +138 -1
  355. package/src/sdk/_generated/auth/api.ts +38 -7
  356. package/src/sdk/_generated/auth/client.ts +168 -530
  357. package/src/sdk/_generated/auth/contract.ts +310 -93
  358. package/src/sdk/_generated/auth/mod.ts +0 -1
  359. package/src/sdk/_generated/auth/owned_api.ts +92 -86
  360. package/src/sdk/_generated/auth/schemas.ts +231 -92
  361. package/src/sdk/_generated/auth/types.ts +1069 -273
  362. package/src/sdk/_generated/core/api.ts +38 -7
  363. package/src/sdk/_generated/core/client.ts +47 -73
  364. package/src/sdk/_generated/core/contract.ts +91 -1
  365. package/src/sdk/_generated/core/mod.ts +0 -1
  366. package/src/sdk/_generated/core/owned_api.ts +4 -4
  367. package/src/sdk/_generated/core/schemas.ts +81 -0
  368. package/src/sdk/_generated/core/types.ts +79 -15
  369. package/src/sdk/_generated/health/api.ts +29 -5
  370. package/src/sdk/_generated/health/client.ts +11 -58
  371. package/src/sdk/_generated/health/contract.ts +2 -10
  372. package/src/sdk/_generated/health/mod.ts +0 -1
  373. package/src/sdk/_generated/health/owned_api.ts +2 -2
  374. package/src/sdk/_generated/health/schemas.ts +1 -9
  375. package/src/sdk/_generated/health/types.ts +23 -2
  376. package/src/sdk/_generated/jobs/api.ts +29 -5
  377. package/src/sdk/_generated/jobs/client.ts +25 -109
  378. package/src/sdk/_generated/jobs/contract.ts +269 -1
  379. package/src/sdk/_generated/jobs/mod.ts +0 -1
  380. package/src/sdk/_generated/jobs/owned_api.ts +30 -9
  381. package/src/sdk/_generated/jobs/schemas.ts +213 -0
  382. package/src/sdk/_generated/jobs/types.ts +252 -18
  383. package/src/sdk/_generated/state/api.ts +29 -5
  384. package/src/sdk/_generated/state/client.ts +18 -95
  385. package/src/sdk/_generated/state/mod.ts +0 -1
  386. package/src/sdk/_generated/state/owned_api.ts +7 -7
  387. package/src/sdk/_generated/state/types.ts +91 -15
  388. package/src/server/health.ts +2 -6
  389. package/src/server/health_schemas.ts +0 -6
  390. package/src/server/internal_jobs/bindings.ts +11 -0
  391. package/src/server/internal_jobs/job-manager.ts +553 -24
  392. package/src/server/internal_jobs/key-coordinator.ts +1080 -0
  393. package/src/server/internal_jobs/projection.ts +2 -0
  394. package/src/server/internal_jobs/runtime-worker.ts +17 -1
  395. package/src/server/internal_jobs/types.ts +6 -0
  396. package/src/server/runtime.ts +4 -0
  397. package/src/server/service.ts +645 -625
  398. package/src/server.ts +14 -7
  399. package/src/service/deno.ts +0 -5
  400. package/src/service/drizzle.ts +184 -0
  401. package/src/service/mod.ts +17 -7
  402. package/src/service/node.ts +0 -5
  403. package/src/service/outbox_inbox.ts +354 -88
  404. package/src/telemetry/metrics.ts +198 -1
  405. package/src/telemetry/mod.ts +6 -0
  406. package/src/trellis.ts +286 -105
@@ -9,11 +9,12 @@ import { importEd25519PrivateKeyFromSeedBase64url, publicKeyBase64urlFromSeed, s
9
9
  import { DEFAULT_RUNTIME_MAX_RECONNECT_ATTEMPTS, } from "./runtime_transport.js";
10
10
  import { Trellis, } from "./trellis.js";
11
11
  import { TransportError } from "./errors/index.js";
12
- import { AsyncResult, Result, UnexpectedError } from "@qlever-llc/result";
12
+ import { AsyncResult, BaseError, Result, UnexpectedError, } from "@qlever-llc/result";
13
13
  import { Type } from "typebox";
14
14
  import { Value } from "typebox/value";
15
15
  import { bindFlowSig, oauthInitSig, signBytes, } from "./auth/browser/session.js";
16
16
  import { observeNatsTrellisConnection, } from "./connection.js";
17
+ import { recordTrellisDuration } from "./telemetry/mod.js";
17
18
  function createConnectedClient(args) {
18
19
  const trellis = new Trellis(args.name, args.nc, {
19
20
  sessionKey: args.sessionKey,
@@ -25,17 +26,26 @@ function createConnectedClient(args) {
25
26
  return trellis;
26
27
  }
27
28
  function clientConnectResult(promise) {
28
- return AsyncResult.from(promise.then((value) => Result.ok(value), (cause) => Result.err(cause instanceof TransportError
29
+ return AsyncResult.from(promise.then((value) => Result.ok(value), (cause) => Result.err(cause instanceof TransportError ||
30
+ cause instanceof ClientAuthHandledError
29
31
  ? cause
30
32
  : new UnexpectedError({ cause }))));
31
33
  }
32
34
  /**
33
35
  * Error raised when client authentication was delegated to caller-owned routing.
34
36
  */
35
- export class ClientAuthHandledError extends Error {
37
+ export class ClientAuthHandledError extends BaseError {
36
38
  constructor() {
37
39
  super("Client authentication was handled by the caller");
38
- this.name = "ClientAuthHandledError";
40
+ Object.defineProperty(this, "name", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: "ClientAuthHandledError"
45
+ });
46
+ }
47
+ toSerializable() {
48
+ return this.baseSerializable();
39
49
  }
40
50
  }
41
51
  const ClientTransportEndpointsSchema = Type.Object({
@@ -230,6 +240,7 @@ async function resolveClientIdentity(auth) {
230
240
  };
231
241
  }
232
242
  async function bindClientFlow(args) {
243
+ const startedAt = performance.now();
233
244
  const response = await fetch(`${args.trellisUrl}/auth/flow/${encodeURIComponent(args.flowId)}/bind`, {
234
245
  method: "POST",
235
246
  headers: { "Content-Type": "application/json" },
@@ -286,8 +297,14 @@ async function bindClientFlow(args) {
286
297
  },
287
298
  });
288
299
  }
300
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
301
+ phase: "bootstrap",
302
+ participantKind: "client",
303
+ outcome: "ok",
304
+ });
289
305
  }
290
306
  async function fetchClientBootstrap(args) {
307
+ const startedAt = performance.now();
291
308
  const response = await fetch(`${args.trellisUrl}/bootstrap/client`, {
292
309
  method: "POST",
293
310
  headers: { "Content-Type": "application/json" },
@@ -319,12 +336,27 @@ async function fetchClientBootstrap(args) {
319
336
  });
320
337
  }
321
338
  if (Value.Check(ClientBootstrapReadySchema, payload)) {
339
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
340
+ phase: "bootstrap",
341
+ participantKind: "client",
342
+ outcome: "ok",
343
+ });
322
344
  return payload;
323
345
  }
324
346
  if (Value.Check(ClientBootstrapAuthRequiredSchema, payload)) {
347
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
348
+ phase: "bootstrap",
349
+ participantKind: "client",
350
+ outcome: "ok",
351
+ });
325
352
  return payload;
326
353
  }
327
354
  if (Value.Check(ClientBootstrapNotReadySchema, payload)) {
355
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
356
+ phase: "bootstrap",
357
+ participantKind: "client",
358
+ outcome: "ok",
359
+ });
328
360
  return payload;
329
361
  }
330
362
  throw createTransportError({
@@ -343,6 +375,7 @@ function updateClockOffsetFromServer(args) {
343
375
  }
344
376
  async function fetchClientBootstrapWithRetry(args) {
345
377
  for (let attempt = 0; attempt < 2; attempt += 1) {
378
+ const attemptStartedAt = performance.now();
346
379
  const requestStartedAtMs = args.deps.now();
347
380
  const iat = correctedIatSeconds(requestStartedAtMs, args.offsetState.serverClockOffsetMs);
348
381
  const response = await fetchClientBootstrap({
@@ -352,6 +385,11 @@ async function fetchClientBootstrapWithRetry(args) {
352
385
  bootstrapSig: await args.identity.bootstrapSig(iat),
353
386
  });
354
387
  const responseReceivedAtMs = args.deps.now();
388
+ recordTrellisDuration("trellis.connect.duration", performance.now() - attemptStartedAt, {
389
+ phase: "bootstrap",
390
+ participantKind: "client",
391
+ outcome: "ok",
392
+ });
355
393
  updateClockOffsetFromServer({
356
394
  offsetState: args.offsetState,
357
395
  requestStartedAtMs,
@@ -514,6 +552,7 @@ function bootstrapTargetsRequestedContract(bootstrap, args) {
514
552
  bootstrap.connectInfo.contractDigest === requestedDigest;
515
553
  }
516
554
  async function buildSessionKeyLoginUrl(args) {
555
+ const startedAt = performance.now();
517
556
  const context = authRequestContextRecord(args.context);
518
557
  let response = await fetch(`${args.trellisUrl}/auth/requests`, {
519
558
  method: "POST",
@@ -528,6 +567,11 @@ async function buildSessionKeyLoginUrl(args) {
528
567
  }),
529
568
  });
530
569
  if (await authStartNeedsManifest(response)) {
570
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
571
+ phase: "bootstrap",
572
+ participantKind: "client",
573
+ outcome: "ok",
574
+ });
531
575
  response = await fetch(`${args.trellisUrl}/auth/requests`, {
532
576
  method: "POST",
533
577
  headers: { "Content-Type": "application/json" },
@@ -560,6 +604,11 @@ async function buildSessionKeyLoginUrl(args) {
560
604
  if (payload && typeof payload === "object" &&
561
605
  payload.status === "flow_started" &&
562
606
  typeof payload.loginUrl === "string") {
607
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
608
+ phase: "bootstrap",
609
+ participantKind: "client",
610
+ outcome: "ok",
611
+ });
563
612
  return {
564
613
  status: "flow_started",
565
614
  loginUrl: payload.loginUrl,
@@ -567,6 +616,11 @@ async function buildSessionKeyLoginUrl(args) {
567
616
  }
568
617
  if (payload && typeof payload === "object" &&
569
618
  payload.status === "bound") {
619
+ recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
620
+ phase: "bootstrap",
621
+ participantKind: "client",
622
+ outcome: "ok",
623
+ });
570
624
  return { status: "bound" };
571
625
  }
572
626
  throw createTransportError({
@@ -596,6 +650,7 @@ async function authStartNeedsManifest(response) {
596
650
  return (await response.clone().text()).includes("manifest_required");
597
651
  }
598
652
  export async function connectClientWithDeps(args, deps) {
653
+ const totalStartedAt = performance.now();
599
654
  const trellisUrl = normalizeTrellisUrl(args.trellisUrl);
600
655
  const identity = await resolveClientIdentity(args.auth);
601
656
  const currentUrl = args.auth?.mode === "session_key"
@@ -640,6 +695,7 @@ export async function connectClientWithDeps(args, deps) {
640
695
  }
641
696
  }
642
697
  }
698
+ const initialBootstrapStartedAt = performance.now();
643
699
  const initialBootstrap = await fetchClientBootstrapWithRetry({
644
700
  trellisUrl,
645
701
  sessionKey: identity.sessionKey,
@@ -647,10 +703,21 @@ export async function connectClientWithDeps(args, deps) {
647
703
  deps,
648
704
  offsetState,
649
705
  });
706
+ recordTrellisDuration("trellis.connect.duration", performance.now() - initialBootstrapStartedAt, {
707
+ phase: "bootstrap",
708
+ participantKind: "client",
709
+ outcome: "ok",
710
+ });
711
+ const authStartedAt = performance.now();
650
712
  const bootstrap = needsReauth(initialBootstrap) ||
651
713
  !bootstrapTargetsRequestedContract(initialBootstrap, args)
652
714
  ? await resolveAuthRequired(args, identity, currentUrl, deps, offsetState)
653
715
  : initialBootstrap;
716
+ recordTrellisDuration("trellis.connect.duration", performance.now() - authStartedAt, {
717
+ phase: "auth_resolution",
718
+ participantKind: "client",
719
+ outcome: "ok",
720
+ });
654
721
  if (bootstrap.status !== "ready") {
655
722
  if (bootstrap.status === "not_ready") {
656
723
  throw createTransportError({
@@ -730,12 +797,18 @@ export async function connectClientWithDeps(args, deps) {
730
797
  });
731
798
  let nc;
732
799
  try {
800
+ const natsStartedAt = performance.now();
733
801
  nc = await transport.connect({
734
802
  servers: selectClientRuntimeTransportServers(bootstrap.connectInfo.transports),
735
803
  maxReconnectAttempts: DEFAULT_RUNTIME_MAX_RECONNECT_ATTEMPTS,
736
804
  inboxPrefix: bootstrap.connectInfo.transport.inboxPrefix,
737
805
  authenticator: runtimeAuth.authenticators,
738
806
  });
807
+ recordTrellisDuration("trellis.connect.duration", performance.now() - natsStartedAt, {
808
+ phase: "nats_connect",
809
+ participantKind: "client",
810
+ outcome: "ok",
811
+ });
739
812
  }
740
813
  catch (error) {
741
814
  runtimeAuth.stop();
@@ -775,7 +848,7 @@ export async function connectClientWithDeps(args, deps) {
775
848
  throw new Error("Contract is missing an owned or trellis API view");
776
849
  }
777
850
  const state = args.contract[CONTRACT_STATE_METADATA];
778
- return createConnectedClient({
851
+ const client = createConnectedClient({
779
852
  name: clientOpts.name ?? "client",
780
853
  nc,
781
854
  connection,
@@ -791,6 +864,12 @@ export async function connectClientWithDeps(args, deps) {
791
864
  onSessionNotFound: handleSessionNotFound,
792
865
  },
793
866
  });
867
+ recordTrellisDuration("trellis.connect.duration", performance.now() - totalStartedAt, {
868
+ phase: "total",
869
+ participantKind: "client",
870
+ outcome: "ok",
871
+ });
872
+ return client;
794
873
  }
795
874
  async function resolveAuthRequired(args, identity, currentUrl, deps, offsetState) {
796
875
  const browserAuth = args.auth?.mode === "session_key" ? {} : args.auth ?? {};
@@ -825,37 +904,63 @@ async function resolveAuthRequired(args, identity, currentUrl, deps, offsetState
825
904
  context: browserAuth.context,
826
905
  });
827
906
  if (authStart.status === "bound") {
828
- return await fetchClientBootstrapWithRetry({
907
+ const bootstrapStartedAt = performance.now();
908
+ const bootstrap = await fetchClientBootstrapWithRetry({
829
909
  trellisUrl: normalizeTrellisUrl(args.trellisUrl),
830
910
  sessionKey: identity.sessionKey,
831
911
  identity,
832
912
  deps,
833
913
  offsetState,
834
914
  });
915
+ recordTrellisDuration("trellis.connect.duration", performance.now() - bootstrapStartedAt, {
916
+ phase: "bootstrap",
917
+ participantKind: "client",
918
+ outcome: "ok",
919
+ });
920
+ return bootstrap;
835
921
  }
836
922
  const loginUrl = authStart.loginUrl;
923
+ const continuationStartedAt = performance.now();
837
924
  const continuation = await args.onAuthRequired?.({
838
925
  loginUrl,
839
926
  sessionKey: identity.sessionKey,
840
927
  mode: identity.mode,
841
928
  });
929
+ recordTrellisDuration("trellis.connect.duration", performance.now() - continuationStartedAt, {
930
+ phase: "bootstrap",
931
+ participantKind: "client",
932
+ outcome: "ok",
933
+ });
842
934
  if (continuation && continuation.status === "handled") {
843
935
  throw new ClientAuthHandledError();
844
936
  }
845
937
  if (continuation && continuation.status === "bound") {
938
+ const bindStartedAt = performance.now();
846
939
  await bindClientFlow({
847
940
  trellisUrl: normalizeTrellisUrl(args.trellisUrl),
848
941
  sessionKey: identity.sessionKey,
849
942
  flowId: continuation.flowId,
850
943
  sig: await identity.bindFlowSig(continuation.flowId),
851
944
  });
852
- return await fetchClientBootstrapWithRetry({
945
+ recordTrellisDuration("trellis.connect.duration", performance.now() - bindStartedAt, {
946
+ phase: "bootstrap",
947
+ participantKind: "client",
948
+ outcome: "ok",
949
+ });
950
+ const bootstrapStartedAt = performance.now();
951
+ const bootstrap = await fetchClientBootstrapWithRetry({
853
952
  trellisUrl: normalizeTrellisUrl(args.trellisUrl),
854
953
  sessionKey: identity.sessionKey,
855
954
  identity,
856
955
  deps,
857
956
  offsetState,
858
957
  });
958
+ recordTrellisDuration("trellis.connect.duration", performance.now() - bootstrapStartedAt, {
959
+ phase: "bootstrap",
960
+ participantKind: "client",
961
+ outcome: "ok",
962
+ });
963
+ return bootstrap;
859
964
  }
860
965
  if (isBrowserRuntime()) {
861
966
  globalThis.location.href = loginUrl;
package/esm/codec.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { type InferSchemaType, type SchemaLike } from "./contracts.js";
2
2
  import { Result } from "@qlever-llc/result";
3
3
  import type { StaticDecode, TSchema } from "typebox";
4
- import { UnexpectedError, ValidationError } from "./errors/index.js";
4
+ import { SchemaValidationError, UnexpectedError, ValidationError } from "./errors/index.js";
5
5
  export type JsonValue = string | number | boolean | null | JsonValue[] | {
6
6
  [key: string]: JsonValue;
7
7
  };
8
- export declare function parse<T extends TSchema>(schema: T, data: JsonValue): Result<StaticDecode<T>, ValidationError | UnexpectedError>;
9
- export declare function parseSchema<S extends SchemaLike>(schema: S, data: JsonValue): Result<InferSchemaType<S>, ValidationError | UnexpectedError>;
10
- export declare function parseUnknownSchema(schema: SchemaLike, data: JsonValue): Result<unknown, ValidationError | UnexpectedError>;
11
- export declare function encode<T extends TSchema>(schema: T, data: unknown): Result<string, ValidationError | UnexpectedError>;
12
- export declare function encodeSchema(schema: SchemaLike, data: unknown): Result<string, ValidationError | UnexpectedError>;
8
+ export declare function parse<T extends TSchema>(schema: T, data: JsonValue): Result<StaticDecode<T>, SchemaValidationError | ValidationError | UnexpectedError>;
9
+ export declare function parseSchema<S extends SchemaLike>(schema: S, data: JsonValue): Result<InferSchemaType<S>, SchemaValidationError | ValidationError | UnexpectedError>;
10
+ /** Parses unknown JSON-compatible data with an arbitrary Trellis schema. */
11
+ export declare function parseUnknownSchema(schema: SchemaLike, data: JsonValue): Result<unknown, SchemaValidationError | ValidationError | UnexpectedError>;
12
+ export declare function encode<T extends TSchema>(schema: T, data: unknown): Result<string, SchemaValidationError | ValidationError | UnexpectedError>;
13
+ export declare function encodeSchema(schema: SchemaLike, data: unknown): Result<string, SchemaValidationError | ValidationError | UnexpectedError>;
13
14
  //# sourceMappingURL=codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAErE,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAUJ,wBAAgB,KAAK,CAAC,CAAC,SAAS,OAAO,EACrC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC,CAU5D;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC,CAa/D;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,eAAe,CAAC,CAWpD;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,OAAO,EACtC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC,CAUnD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC,CAWnD"}
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAwKJ,wBAAgB,KAAK,CAAC,CAAC,SAAS,OAAO,EACrC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CACP,YAAY,CAAC,CAAC,CAAC,EACf,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAC1D,CAUA;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CACP,eAAe,CAAC,CAAC,CAAC,EAClB,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAC1D,CAaA;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC,CAW5E;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,OAAO,EACtC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC,CAU3E;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC,CAW3E"}
package/esm/codec.js CHANGED
@@ -1,7 +1,125 @@
1
1
  import { unwrapSchema, } from "./contracts.js";
2
2
  import { Result } from "@qlever-llc/result";
3
3
  import { EncodeError, ParseError, Value } from "typebox/value";
4
- import { UnexpectedError, ValidationError } from "./errors/index.js";
4
+ import { SchemaValidationError, UnexpectedError, ValidationError, } from "./errors/index.js";
5
+ const X_TRELLIS_VALIDATION = "x-trellis-validation";
6
+ function readTrellisValidationExtension(schema) {
7
+ if (schema === null || schema === undefined || typeof schema !== "object") {
8
+ return undefined;
9
+ }
10
+ const ext = schema[X_TRELLIS_VALIDATION];
11
+ if (ext === null || ext === undefined || typeof ext !== "object") {
12
+ return undefined;
13
+ }
14
+ return ext;
15
+ }
16
+ function resolveSchemaNode(root, schemaPath) {
17
+ if (!schemaPath.startsWith("#/")) {
18
+ if (schemaPath === "#")
19
+ return root;
20
+ return undefined;
21
+ }
22
+ const parts = schemaPath.slice(2).split("/").map(decodeURIComponent);
23
+ let current = root;
24
+ for (const part of parts) {
25
+ if (current === null || current === undefined || typeof current !== "object") {
26
+ return undefined;
27
+ }
28
+ current = current[part];
29
+ }
30
+ return current;
31
+ }
32
+ function resolveRequiredErrorNode(root, error) {
33
+ const params = error.params;
34
+ const missingProperty = (params?.missingProperty ??
35
+ params?.requiredProperties?.[0]);
36
+ if (!missingProperty)
37
+ return undefined;
38
+ const objNode = resolveSchemaNode(root, error.schemaPath);
39
+ if (!objNode || typeof objNode !== "object")
40
+ return undefined;
41
+ const properties = objNode.properties;
42
+ if (!properties || typeof properties !== "object")
43
+ return undefined;
44
+ return properties[missingProperty];
45
+ }
46
+ const ALLOWED_HINT_KEYWORDS = new Set([
47
+ "required",
48
+ "minItems",
49
+ "maxItems",
50
+ "minLength",
51
+ "maxLength",
52
+ "minimum",
53
+ "maximum",
54
+ "exclusiveMinimum",
55
+ "exclusiveMaximum",
56
+ "pattern",
57
+ "format",
58
+ "enum",
59
+ "const",
60
+ ]);
61
+ function keywordAllowsHint(keyword) {
62
+ return ALLOWED_HINT_KEYWORDS.has(keyword);
63
+ }
64
+ function typeboxIssueToPath(error) {
65
+ if (error.keyword === "required") {
66
+ const params = error.params;
67
+ const missingProperty = (params?.missingProperty ??
68
+ params?.requiredProperties?.[0]);
69
+ if (missingProperty) {
70
+ return error.instancePath
71
+ ? `${error.instancePath}/${missingProperty}`
72
+ : `/${missingProperty}`;
73
+ }
74
+ }
75
+ return error.instancePath || error.schemaPath;
76
+ }
77
+ function collectValidationIssues(root, errors) {
78
+ const annotated = [];
79
+ const unannotated = [];
80
+ for (const error of [...errors]) {
81
+ const schemaNode = error.keyword === "required"
82
+ ? resolveRequiredErrorNode(root, error)
83
+ : resolveSchemaNode(root, error.schemaPath);
84
+ const extension = schemaNode !== undefined
85
+ ? readTrellisValidationExtension(schemaNode)
86
+ : undefined;
87
+ if (extension !== undefined &&
88
+ keywordAllowsHint(error.keyword) &&
89
+ extension.issues?.[error.keyword] !== undefined) {
90
+ const hint = extension.issues[error.keyword];
91
+ if (hint.code !== undefined) {
92
+ annotated.push({
93
+ path: typeboxIssueToPath(error),
94
+ schemaPath: error.schemaPath,
95
+ keyword: error.keyword,
96
+ code: hint.code,
97
+ message: hint.message || error.message,
98
+ label: hint.label ?? extension.label,
99
+ note: hint.note ?? extension.note,
100
+ i18nKey: hint.i18nKey,
101
+ severity: hint.severity ?? "error",
102
+ params: error.params,
103
+ });
104
+ continue;
105
+ }
106
+ }
107
+ unannotated.push(error);
108
+ }
109
+ return { annotated, unannotated };
110
+ }
111
+ function buildValidationError(schema, data, errors, cause) {
112
+ const { annotated, unannotated } = collectValidationIssues(schema, errors);
113
+ if (annotated.length > 0 && unannotated.length === 0) {
114
+ return new SchemaValidationError({ issues: annotated, cause });
115
+ }
116
+ return new ValidationError({
117
+ errors: unannotated.length > 0
118
+ ? unannotated
119
+ : annotated.map((i) => ({ path: i.path, message: i.message })),
120
+ cause,
121
+ });
122
+ }
5
123
  function parseWithSchema(schema, data) {
6
124
  return Value.Parse(schema, data);
7
125
  }
@@ -15,7 +133,7 @@ export function parse(schema, data) {
15
133
  catch (cause) {
16
134
  if (cause instanceof ParseError) {
17
135
  const errors = Value.Errors(schema, data);
18
- return Result.err(new ValidationError({ errors, cause }));
136
+ return Result.err(buildValidationError(schema, data, errors, cause));
19
137
  }
20
138
  return Result.err(new UnexpectedError({ cause }));
21
139
  }
@@ -28,11 +146,12 @@ export function parseSchema(schema, data) {
28
146
  catch (cause) {
29
147
  if (cause instanceof ParseError) {
30
148
  const errors = Value.Errors(raw, data);
31
- return Result.err(new ValidationError({ errors, cause }));
149
+ return Result.err(buildValidationError(raw, data, errors, cause));
32
150
  }
33
151
  return Result.err(new UnexpectedError({ cause }));
34
152
  }
35
153
  }
154
+ /** Parses unknown JSON-compatible data with an arbitrary Trellis schema. */
36
155
  export function parseUnknownSchema(schema, data) {
37
156
  const raw = unwrapSchema(schema);
38
157
  try {
@@ -41,7 +160,7 @@ export function parseUnknownSchema(schema, data) {
41
160
  catch (cause) {
42
161
  if (cause instanceof ParseError) {
43
162
  const errors = Value.Errors(raw, data);
44
- return Result.err(new ValidationError({ errors, cause }));
163
+ return Result.err(buildValidationError(raw, data, errors, cause));
45
164
  }
46
165
  return Result.err(new UnexpectedError({ cause }));
47
166
  }
@@ -53,7 +172,7 @@ export function encode(schema, data) {
53
172
  catch (cause) {
54
173
  if (cause instanceof EncodeError) {
55
174
  const errors = Value.Errors(schema, data);
56
- return Result.err(new ValidationError({ errors, cause }));
175
+ return Result.err(buildValidationError(schema, data, errors, cause));
57
176
  }
58
177
  return Result.err(new UnexpectedError({ cause }));
59
178
  }
@@ -66,7 +185,7 @@ export function encodeSchema(schema, data) {
66
185
  catch (cause) {
67
186
  if (cause instanceof EncodeError) {
68
187
  const errors = Value.Errors(raw, data);
69
- return Result.err(new ValidationError({ errors, cause }));
188
+ return Result.err(buildValidationError(raw, data, errors, cause));
70
189
  }
71
190
  return Result.err(new UnexpectedError({ cause }));
72
191
  }
@@ -5,8 +5,11 @@ export declare function isJsonValue(value: unknown): value is JsonValue;
5
5
  export declare function canonicalizeJson(value: JsonValue): string;
6
6
  export declare function base64url(bytes: Uint8Array): string;
7
7
  export declare function sha256Bytes(data: Uint8Array): Uint8Array;
8
+ /** Computes a synchronous SHA-256 digest encoded as base64url. */
8
9
  export declare function sha256Base64urlSync(text: string): string;
10
+ /** Computes a SHA-256 digest encoded as base64url. */
9
11
  export declare function sha256Base64url(text: string): Promise<string>;
12
+ /** Canonicalizes JSON and computes its SHA-256 base64url digest. */
10
13
  export declare function digestJson(value: JsonValue): Promise<{
11
14
  canonical: string;
12
15
  digest: string;
@@ -1 +1 @@
1
- {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/contract_support/canonical.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/B,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAiB9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAoBzD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKnD;AAMD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAsIxD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnE;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAID"}
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/contract_support/canonical.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/B,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAiB9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAoBzD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKnD;AAMD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAsIxD;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,sDAAsD;AACtD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnE;AAED,oEAAoE;AACpE,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAID"}
@@ -172,9 +172,11 @@ export function sha256Bytes(data) {
172
172
  }
173
173
  return out;
174
174
  }
175
+ /** Computes a synchronous SHA-256 digest encoded as base64url. */
175
176
  export function sha256Base64urlSync(text) {
176
177
  return base64url(sha256Bytes(new TextEncoder().encode(text)));
177
178
  }
179
+ /** Computes a SHA-256 digest encoded as base64url. */
178
180
  export async function sha256Base64url(text) {
179
181
  if (typeof crypto !== "undefined" && crypto.subtle) {
180
182
  const data = new TextEncoder().encode(text);
@@ -183,6 +185,7 @@ export async function sha256Base64url(text) {
183
185
  }
184
186
  return sha256Base64urlSync(text);
185
187
  }
188
+ /** Canonicalizes JSON and computes its SHA-256 base64url digest. */
186
189
  export async function digestJson(value) {
187
190
  const canonical = canonicalizeJson(value);
188
191
  const digest = await sha256Base64url(canonical);