@qlever-llc/trellis 0.5.1 → 0.6.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 (490) hide show
  1. package/README.md +16 -2
  2. package/esm/_dnt.polyfills.d.ts +11 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -1
  4. package/esm/_dnt.polyfills.js +14 -0
  5. package/esm/_dnt.shims.d.ts +6 -0
  6. package/esm/_dnt.shims.d.ts.map +1 -0
  7. package/esm/_dnt.shims.js +61 -0
  8. package/esm/auth/browser/login.d.ts +27 -0
  9. package/esm/auth/browser/login.d.ts.map +1 -0
  10. package/esm/auth/browser/login.js +94 -0
  11. package/esm/auth/browser/portal.d.ts +11 -0
  12. package/esm/auth/browser/portal.d.ts.map +1 -0
  13. package/esm/auth/browser/portal.js +33 -0
  14. package/esm/auth/browser/session.d.ts +19 -0
  15. package/esm/auth/browser/session.d.ts.map +1 -0
  16. package/esm/auth/browser/session.js +65 -0
  17. package/esm/auth/browser/storage.d.ts +12 -0
  18. package/esm/auth/browser/storage.d.ts.map +1 -0
  19. package/esm/auth/browser/storage.js +61 -0
  20. package/esm/auth/browser.d.ts +13 -0
  21. package/esm/auth/browser.d.ts.map +1 -0
  22. package/esm/auth/browser.js +11 -0
  23. package/esm/auth/keys.d.ts +5 -0
  24. package/esm/auth/keys.d.ts.map +1 -0
  25. package/esm/auth/keys.js +50 -0
  26. package/esm/auth/mod.d.ts +18 -0
  27. package/esm/auth/mod.d.ts.map +1 -0
  28. package/esm/auth/mod.js +17 -0
  29. package/esm/auth/proof.d.ts +9 -0
  30. package/esm/auth/proof.d.ts.map +1 -0
  31. package/esm/auth/proof.js +43 -0
  32. package/esm/auth/protocol.d.ts +1212 -0
  33. package/esm/auth/protocol.d.ts.map +1 -0
  34. package/esm/auth/protocol.js +682 -0
  35. package/esm/auth/schemas.d.ts +93 -0
  36. package/esm/auth/schemas.d.ts.map +1 -0
  37. package/esm/auth/schemas.js +64 -0
  38. package/esm/auth/session_auth.d.ts +20 -0
  39. package/esm/auth/session_auth.d.ts.map +1 -0
  40. package/esm/auth/session_auth.js +42 -0
  41. package/esm/auth/trellis_id.d.ts +2 -0
  42. package/esm/auth/trellis_id.d.ts.map +1 -0
  43. package/esm/auth/trellis_id.js +5 -0
  44. package/esm/auth/types.d.ts +8 -0
  45. package/esm/auth/types.d.ts.map +1 -0
  46. package/esm/auth/types.js +1 -0
  47. package/esm/auth/utils.d.ts +11 -0
  48. package/esm/auth/utils.d.ts.map +1 -0
  49. package/esm/auth/utils.js +68 -0
  50. package/esm/auth/workload_activation.d.ts +192 -0
  51. package/esm/auth/workload_activation.d.ts.map +1 -0
  52. package/esm/auth/workload_activation.js +290 -0
  53. package/esm/contracts/canonical.d.ts +14 -0
  54. package/esm/contracts/canonical.d.ts.map +1 -0
  55. package/esm/contracts/canonical.js +135 -0
  56. package/esm/contracts/mod.d.ts +462 -0
  57. package/esm/contracts/mod.d.ts.map +1 -0
  58. package/esm/contracts/mod.js +532 -0
  59. package/esm/contracts/protocol.d.ts +301 -0
  60. package/esm/contracts/protocol.d.ts.map +1 -0
  61. package/esm/contracts/protocol.js +130 -0
  62. package/esm/contracts/runtime.d.ts +48 -0
  63. package/esm/contracts/runtime.d.ts.map +1 -0
  64. package/esm/contracts/runtime.js +9 -0
  65. package/esm/contracts/schema_pointers.d.ts +18 -0
  66. package/esm/contracts/schema_pointers.d.ts.map +1 -0
  67. package/esm/contracts/schema_pointers.js +59 -0
  68. package/esm/server/deno.d.ts +7 -0
  69. package/esm/server/deno.d.ts.map +1 -0
  70. package/esm/server/deno.js +16 -0
  71. package/esm/server/health.d.ts +92 -0
  72. package/esm/server/health.d.ts.map +1 -0
  73. package/esm/server/health.js +74 -0
  74. package/esm/server/health_rpc.d.ts +16 -0
  75. package/esm/server/health_rpc.d.ts.map +1 -0
  76. package/esm/server/health_rpc.js +23 -0
  77. package/esm/server/health_schemas.d.ts +20 -0
  78. package/esm/server/health_schemas.d.ts.map +1 -0
  79. package/esm/server/health_schemas.js +18 -0
  80. package/esm/server/mod.d.ts +17 -0
  81. package/esm/server/mod.d.ts.map +1 -0
  82. package/esm/server/mod.js +17 -0
  83. package/esm/server/node.d.ts +7 -0
  84. package/esm/server/node.d.ts.map +1 -0
  85. package/esm/server/node.js +16 -0
  86. package/esm/server/runtime.d.ts +16 -0
  87. package/esm/server/runtime.d.ts.map +1 -0
  88. package/esm/server/runtime.js +1 -0
  89. package/esm/server/service.d.ts +121 -0
  90. package/esm/server/service.d.ts.map +1 -0
  91. package/esm/server/service.js +256 -0
  92. package/esm/server/subscription.d.ts +99 -0
  93. package/esm/server/subscription.d.ts.map +1 -0
  94. package/esm/server/subscription.js +25 -0
  95. package/esm/telemetry/carrier.d.ts +9 -0
  96. package/esm/telemetry/carrier.d.ts.map +1 -0
  97. package/esm/telemetry/carrier.js +20 -0
  98. package/esm/telemetry/core.d.ts +8 -0
  99. package/esm/telemetry/core.d.ts.map +1 -0
  100. package/esm/telemetry/core.js +14 -0
  101. package/esm/telemetry/env.d.ts +2 -0
  102. package/esm/telemetry/env.d.ts.map +1 -0
  103. package/esm/telemetry/env.js +10 -0
  104. package/esm/telemetry/mod.d.ts +11 -0
  105. package/esm/telemetry/mod.d.ts.map +1 -0
  106. package/esm/telemetry/mod.js +7 -0
  107. package/esm/telemetry/nats.d.ts +7 -0
  108. package/esm/telemetry/nats.d.ts.map +1 -0
  109. package/esm/telemetry/nats.js +6 -0
  110. package/esm/telemetry/result.d.ts +2 -0
  111. package/esm/telemetry/result.d.ts.map +1 -0
  112. package/esm/telemetry/result.js +18 -0
  113. package/esm/telemetry/runtime.d.ts +2 -0
  114. package/esm/telemetry/runtime.d.ts.map +1 -0
  115. package/esm/telemetry/runtime.js +53 -0
  116. package/esm/telemetry/trace.d.ts +5 -0
  117. package/esm/telemetry/trace.d.ts.map +1 -0
  118. package/esm/telemetry/trace.js +26 -0
  119. package/esm/telemetry/trellis.d.ts +3 -0
  120. package/esm/telemetry/trellis.d.ts.map +1 -0
  121. package/esm/telemetry/trellis.js +7 -0
  122. package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts +12 -0
  123. package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +1 -0
  124. package/esm/trellis/_sdk/activity/_dnt.polyfills.js +15 -0
  125. package/esm/trellis/_sdk/activity/api.d.ts +10 -0
  126. package/esm/trellis/_sdk/activity/api.d.ts.map +1 -0
  127. package/esm/trellis/_sdk/activity/api.js +43 -0
  128. package/esm/trellis/_sdk/activity/contract.d.ts +8 -0
  129. package/esm/trellis/_sdk/activity/contract.d.ts.map +1 -0
  130. package/esm/trellis/_sdk/activity/contract.js +59 -0
  131. package/esm/trellis/_sdk/activity/mod.d.ts +7 -0
  132. package/esm/trellis/_sdk/activity/mod.d.ts.map +1 -0
  133. package/esm/trellis/_sdk/activity/mod.js +5 -0
  134. package/esm/trellis/_sdk/activity/package.json +3 -0
  135. package/esm/trellis/_sdk/activity/schemas.d.ts +607 -0
  136. package/esm/trellis/_sdk/activity/schemas.d.ts.map +1 -0
  137. package/esm/trellis/_sdk/activity/schemas.js +33 -0
  138. package/esm/trellis/_sdk/activity/types.d.ts +96 -0
  139. package/esm/trellis/_sdk/activity/types.d.ts.map +1 -0
  140. package/esm/trellis/_sdk/activity/types.js +3 -0
  141. package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts +12 -0
  142. package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +1 -0
  143. package/esm/trellis/_sdk/auth/_dnt.polyfills.js +15 -0
  144. package/esm/trellis/_sdk/auth/api.d.ts +10 -0
  145. package/esm/trellis/_sdk/auth/api.d.ts.map +1 -0
  146. package/esm/trellis/_sdk/auth/api.js +354 -0
  147. package/esm/trellis/_sdk/auth/contract.d.ts +28 -0
  148. package/esm/trellis/_sdk/auth/contract.d.ts.map +1 -0
  149. package/esm/trellis/_sdk/auth/contract.js +83 -0
  150. package/esm/trellis/_sdk/auth/mod.d.ts +7 -0
  151. package/esm/trellis/_sdk/auth/mod.d.ts.map +1 -0
  152. package/esm/trellis/_sdk/auth/mod.js +5 -0
  153. package/esm/trellis/_sdk/auth/package.json +3 -0
  154. package/esm/trellis/_sdk/auth/schemas.d.ts +8967 -0
  155. package/esm/trellis/_sdk/auth/schemas.d.ts.map +1 -0
  156. package/esm/trellis/_sdk/auth/schemas.js +306 -0
  157. package/esm/trellis/_sdk/auth/types.d.ts +1232 -0
  158. package/esm/trellis/_sdk/auth/types.d.ts.map +1 -0
  159. package/esm/trellis/_sdk/auth/types.js +3 -0
  160. package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts +12 -0
  161. package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts.map +1 -0
  162. package/esm/trellis/_sdk/core/_dnt.polyfills.js +15 -0
  163. package/esm/trellis/_sdk/core/api.d.ts +10 -0
  164. package/esm/trellis/_sdk/core/api.d.ts.map +1 -0
  165. package/esm/trellis/_sdk/core/api.js +36 -0
  166. package/esm/trellis/_sdk/core/contract.d.ts +8 -0
  167. package/esm/trellis/_sdk/core/contract.d.ts.map +1 -0
  168. package/esm/trellis/_sdk/core/contract.js +59 -0
  169. package/esm/trellis/_sdk/core/mod.d.ts +7 -0
  170. package/esm/trellis/_sdk/core/mod.d.ts.map +1 -0
  171. package/esm/trellis/_sdk/core/mod.js +5 -0
  172. package/esm/trellis/_sdk/core/package.json +3 -0
  173. package/esm/trellis/_sdk/core/schemas.d.ts +1144 -0
  174. package/esm/trellis/_sdk/core/schemas.d.ts.map +1 -0
  175. package/esm/trellis/_sdk/core/schemas.js +28 -0
  176. package/esm/trellis/_sdk/core/types.d.ts +176 -0
  177. package/esm/trellis/_sdk/core/types.d.ts.map +1 -0
  178. package/esm/trellis/_sdk/core/types.js +3 -0
  179. package/esm/trellis/auth/browser.d.ts +3 -0
  180. package/esm/trellis/auth/browser.d.ts.map +1 -0
  181. package/esm/trellis/auth/browser.js +2 -0
  182. package/esm/trellis/auth.d.ts +3 -0
  183. package/esm/trellis/auth.d.ts.map +1 -0
  184. package/esm/trellis/auth.js +2 -0
  185. package/esm/trellis/browser.d.ts +2 -7
  186. package/esm/trellis/browser.d.ts.map +1 -1
  187. package/esm/trellis/browser.js +2 -7
  188. package/esm/trellis/client.d.ts +6 -4
  189. package/esm/trellis/client.d.ts.map +1 -1
  190. package/esm/trellis/client.js +28 -1
  191. package/esm/trellis/codec.d.ts +4 -3
  192. package/esm/trellis/codec.d.ts.map +1 -1
  193. package/esm/trellis/codec.js +15 -2
  194. package/esm/trellis/contract.d.ts +11 -0
  195. package/esm/trellis/contract.d.ts.map +1 -0
  196. package/esm/trellis/contract.js +15 -0
  197. package/esm/trellis/contracts.d.ts +5 -0
  198. package/esm/trellis/contracts.d.ts.map +1 -0
  199. package/esm/trellis/contracts.js +3 -0
  200. package/esm/trellis/env.d.ts +1 -1
  201. package/esm/trellis/env.d.ts.map +1 -1
  202. package/esm/trellis/env.js +1 -1
  203. package/esm/trellis/errors/AuthError.d.ts +1 -1
  204. package/esm/trellis/errors/AuthError.d.ts.map +1 -1
  205. package/esm/trellis/errors/AuthError.js +11 -0
  206. package/esm/trellis/errors/RemoteError.d.ts +3 -3
  207. package/esm/trellis/errors/RemoteError.d.ts.map +1 -1
  208. package/esm/trellis/errors/RemoteError.js +3 -3
  209. package/esm/trellis/errors/TrellisError.d.ts +1 -1
  210. package/esm/trellis/errors/TrellisError.js +1 -1
  211. package/esm/trellis/errors/index.d.ts +2 -1
  212. package/esm/trellis/errors/index.d.ts.map +1 -1
  213. package/esm/trellis/errors/index.js +3 -2
  214. package/esm/trellis/globals.d.ts +9 -1
  215. package/esm/trellis/globals.d.ts.map +1 -1
  216. package/esm/trellis/globals.js +16 -8
  217. package/esm/trellis/helpers.d.ts +2 -1
  218. package/esm/trellis/helpers.d.ts.map +1 -1
  219. package/esm/trellis/helpers.js +1 -0
  220. package/esm/trellis/index.d.ts +13 -5
  221. package/esm/trellis/index.d.ts.map +1 -1
  222. package/esm/trellis/index.js +8 -3
  223. package/esm/trellis/kv.d.ts +10 -7
  224. package/esm/trellis/kv.d.ts.map +1 -1
  225. package/esm/trellis/kv.js +57 -34
  226. package/esm/trellis/models/trellis/TrellisError.d.ts +1 -1
  227. package/esm/trellis/models/trellis/TrellisError.js +1 -1
  228. package/esm/trellis/operations.d.ts +81 -0
  229. package/esm/trellis/operations.d.ts.map +1 -0
  230. package/esm/trellis/operations.js +206 -0
  231. package/esm/trellis/sdk/activity.d.ts +3 -0
  232. package/esm/trellis/sdk/activity.d.ts.map +1 -0
  233. package/esm/trellis/sdk/activity.js +2 -0
  234. package/esm/trellis/sdk/auth.d.ts +4 -0
  235. package/esm/trellis/sdk/auth.d.ts.map +1 -0
  236. package/esm/trellis/sdk/auth.js +3 -0
  237. package/esm/trellis/sdk/core.d.ts +4 -0
  238. package/esm/trellis/sdk/core.d.ts.map +1 -0
  239. package/esm/trellis/sdk/core.js +3 -0
  240. package/esm/trellis/server/deno.d.ts +3 -0
  241. package/esm/trellis/server/deno.d.ts.map +1 -0
  242. package/esm/trellis/server/deno.js +2 -0
  243. package/esm/trellis/server/health.d.ts +5 -0
  244. package/esm/trellis/server/health.d.ts.map +1 -0
  245. package/esm/trellis/server/health.js +3 -0
  246. package/esm/trellis/server/mod.d.ts +3 -0
  247. package/esm/trellis/server/mod.d.ts.map +1 -0
  248. package/esm/trellis/server/mod.js +2 -0
  249. package/esm/trellis/server/node.d.ts +3 -0
  250. package/esm/trellis/server/node.d.ts.map +1 -0
  251. package/esm/trellis/server/node.js +2 -0
  252. package/esm/trellis/server/runtime.d.ts +4 -0
  253. package/esm/trellis/server/runtime.d.ts.map +1 -0
  254. package/esm/trellis/server/runtime.js +2 -0
  255. package/esm/trellis/server.d.ts +21 -0
  256. package/esm/trellis/server.d.ts.map +1 -0
  257. package/esm/trellis/server.js +536 -0
  258. package/esm/trellis/server_logger.d.ts +3 -0
  259. package/esm/trellis/server_logger.d.ts.map +1 -0
  260. package/esm/trellis/server_logger.js +7 -0
  261. package/esm/trellis/tasks.d.ts +3 -3
  262. package/esm/trellis/tasks.d.ts.map +1 -1
  263. package/esm/trellis/tasks.js +1 -1
  264. package/esm/trellis/tracing.d.ts +2 -2
  265. package/esm/trellis/tracing.d.ts.map +1 -1
  266. package/esm/trellis/tracing.js +2 -2
  267. package/esm/trellis/trellis.d.ts +167 -78
  268. package/esm/trellis/trellis.d.ts.map +1 -1
  269. package/esm/trellis/trellis.js +281 -87
  270. package/esm/trellis/workload.d.ts +45 -0
  271. package/esm/trellis/workload.d.ts.map +1 -0
  272. package/esm/trellis/workload.js +144 -0
  273. package/package.json +63 -4
  274. package/script/auth/browser/login.d.ts +27 -0
  275. package/script/auth/browser/login.d.ts.map +1 -0
  276. package/script/auth/browser/login.js +100 -0
  277. package/script/auth/browser/portal.d.ts +11 -0
  278. package/script/auth/browser/portal.d.ts.map +1 -0
  279. package/script/auth/browser/portal.js +40 -0
  280. package/script/auth/browser/session.d.ts +19 -0
  281. package/script/auth/browser/session.d.ts.map +1 -0
  282. package/script/auth/browser/session.js +79 -0
  283. package/script/auth/browser/storage.d.ts +12 -0
  284. package/script/auth/browser/storage.d.ts.map +1 -0
  285. package/script/auth/browser/storage.js +67 -0
  286. package/script/auth/browser.d.ts +13 -0
  287. package/script/auth/browser.d.ts.map +1 -0
  288. package/script/auth/browser.js +46 -0
  289. package/script/auth/keys.d.ts +5 -0
  290. package/script/auth/keys.d.ts.map +1 -0
  291. package/script/auth/keys.js +56 -0
  292. package/script/auth/mod.d.ts +18 -0
  293. package/script/auth/mod.d.ts.map +1 -0
  294. package/script/auth/mod.js +172 -0
  295. package/script/auth/proof.d.ts +9 -0
  296. package/script/auth/proof.d.ts.map +1 -0
  297. package/script/auth/proof.js +48 -0
  298. package/script/auth/protocol.d.ts +1212 -0
  299. package/script/auth/protocol.d.ts.map +1 -0
  300. package/script/auth/protocol.js +687 -0
  301. package/script/auth/schemas.d.ts +93 -0
  302. package/script/auth/schemas.d.ts.map +1 -0
  303. package/script/auth/schemas.js +67 -0
  304. package/script/auth/session_auth.d.ts +20 -0
  305. package/script/auth/session_auth.d.ts.map +1 -0
  306. package/script/auth/session_auth.js +45 -0
  307. package/script/auth/trellis_id.d.ts +2 -0
  308. package/script/auth/trellis_id.d.ts.map +1 -0
  309. package/script/auth/trellis_id.js +8 -0
  310. package/script/auth/types.d.ts +8 -0
  311. package/script/auth/types.d.ts.map +1 -0
  312. package/script/auth/utils.d.ts +11 -0
  313. package/script/auth/utils.d.ts.map +1 -0
  314. package/script/auth/utils.js +77 -0
  315. package/script/auth/workload_activation.d.ts +192 -0
  316. package/script/auth/workload_activation.d.ts.map +1 -0
  317. package/script/auth/workload_activation.js +308 -0
  318. package/script/contracts/canonical.d.ts +14 -0
  319. package/script/contracts/canonical.d.ts.map +1 -0
  320. package/script/contracts/canonical.js +144 -0
  321. package/script/contracts/mod.d.ts +462 -0
  322. package/script/contracts/mod.d.ts.map +1 -0
  323. package/script/contracts/mod.js +555 -0
  324. package/script/contracts/protocol.d.ts +301 -0
  325. package/script/contracts/protocol.d.ts.map +1 -0
  326. package/script/contracts/protocol.js +136 -0
  327. package/script/contracts/runtime.d.ts +48 -0
  328. package/script/contracts/runtime.d.ts.map +1 -0
  329. package/script/contracts/runtime.js +13 -0
  330. package/script/contracts/schema_pointers.d.ts +18 -0
  331. package/script/contracts/schema_pointers.d.ts.map +1 -0
  332. package/script/contracts/schema_pointers.js +63 -0
  333. package/script/telemetry/carrier.d.ts +9 -0
  334. package/script/telemetry/carrier.d.ts.map +1 -0
  335. package/script/telemetry/carrier.js +25 -0
  336. package/script/telemetry/core.d.ts +8 -0
  337. package/script/telemetry/core.d.ts.map +1 -0
  338. package/script/telemetry/core.js +24 -0
  339. package/script/telemetry/env.d.ts +2 -0
  340. package/script/telemetry/env.d.ts.map +1 -0
  341. package/script/telemetry/env.js +12 -0
  342. package/script/telemetry/mod.d.ts +11 -0
  343. package/script/telemetry/mod.d.ts.map +1 -0
  344. package/script/telemetry/mod.js +29 -0
  345. package/script/telemetry/nats.d.ts +7 -0
  346. package/script/telemetry/nats.d.ts.map +1 -0
  347. package/script/telemetry/nats.js +9 -0
  348. package/script/telemetry/result.d.ts +2 -0
  349. package/script/telemetry/result.d.ts.map +1 -0
  350. package/script/telemetry/result.js +21 -0
  351. package/script/telemetry/runtime.d.ts +2 -0
  352. package/script/telemetry/runtime.d.ts.map +1 -0
  353. package/script/telemetry/runtime.js +79 -0
  354. package/script/telemetry/trace.d.ts +5 -0
  355. package/script/telemetry/trace.d.ts.map +1 -0
  356. package/script/telemetry/trace.js +31 -0
  357. package/script/telemetry/trellis.d.ts +3 -0
  358. package/script/telemetry/trellis.d.ts.map +1 -0
  359. package/script/telemetry/trellis.js +14 -0
  360. package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts +12 -0
  361. package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +1 -0
  362. package/script/trellis/_sdk/activity/_dnt.polyfills.js +16 -0
  363. package/script/trellis/_sdk/activity/api.d.ts +10 -0
  364. package/script/trellis/_sdk/activity/api.d.ts.map +1 -0
  365. package/script/trellis/_sdk/activity/api.js +46 -0
  366. package/script/trellis/_sdk/activity/contract.d.ts +8 -0
  367. package/script/trellis/_sdk/activity/contract.d.ts.map +1 -0
  368. package/script/trellis/_sdk/activity/contract.js +62 -0
  369. package/script/trellis/_sdk/activity/mod.d.ts +7 -0
  370. package/script/trellis/_sdk/activity/mod.d.ts.map +1 -0
  371. package/script/trellis/_sdk/activity/mod.js +30 -0
  372. package/script/trellis/_sdk/activity/package.json +3 -0
  373. package/script/trellis/_sdk/activity/schemas.d.ts +607 -0
  374. package/script/trellis/_sdk/activity/schemas.d.ts.map +1 -0
  375. package/script/trellis/_sdk/activity/schemas.js +36 -0
  376. package/script/trellis/_sdk/activity/types.d.ts +96 -0
  377. package/script/trellis/_sdk/activity/types.d.ts.map +1 -0
  378. package/script/trellis/_sdk/activity/types.js +6 -0
  379. package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts +12 -0
  380. package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +1 -0
  381. package/script/trellis/_sdk/auth/_dnt.polyfills.js +16 -0
  382. package/script/trellis/_sdk/auth/api.d.ts +10 -0
  383. package/script/trellis/_sdk/auth/api.d.ts.map +1 -0
  384. package/script/trellis/_sdk/auth/api.js +357 -0
  385. package/script/trellis/_sdk/auth/contract.d.ts +28 -0
  386. package/script/trellis/_sdk/auth/contract.d.ts.map +1 -0
  387. package/script/trellis/_sdk/auth/contract.js +86 -0
  388. package/script/trellis/_sdk/auth/mod.d.ts +7 -0
  389. package/script/trellis/_sdk/auth/mod.d.ts.map +1 -0
  390. package/script/trellis/_sdk/auth/mod.js +31 -0
  391. package/script/trellis/_sdk/auth/package.json +3 -0
  392. package/script/trellis/_sdk/auth/schemas.d.ts +8967 -0
  393. package/script/trellis/_sdk/auth/schemas.d.ts.map +1 -0
  394. package/script/trellis/_sdk/auth/schemas.js +309 -0
  395. package/script/trellis/_sdk/auth/types.d.ts +1232 -0
  396. package/script/trellis/_sdk/auth/types.d.ts.map +1 -0
  397. package/script/trellis/_sdk/auth/types.js +6 -0
  398. package/script/trellis/_sdk/core/_dnt.polyfills.d.ts +12 -0
  399. package/script/trellis/_sdk/core/_dnt.polyfills.d.ts.map +1 -0
  400. package/script/trellis/_sdk/core/_dnt.polyfills.js +16 -0
  401. package/script/trellis/_sdk/core/api.d.ts +10 -0
  402. package/script/trellis/_sdk/core/api.d.ts.map +1 -0
  403. package/script/trellis/_sdk/core/api.js +39 -0
  404. package/script/trellis/_sdk/core/contract.d.ts +8 -0
  405. package/script/trellis/_sdk/core/contract.d.ts.map +1 -0
  406. package/script/trellis/_sdk/core/contract.js +62 -0
  407. package/script/trellis/_sdk/core/mod.d.ts +7 -0
  408. package/script/trellis/_sdk/core/mod.d.ts.map +1 -0
  409. package/script/trellis/_sdk/core/mod.js +30 -0
  410. package/script/trellis/_sdk/core/package.json +3 -0
  411. package/script/trellis/_sdk/core/schemas.d.ts +1144 -0
  412. package/script/trellis/_sdk/core/schemas.d.ts.map +1 -0
  413. package/script/trellis/_sdk/core/schemas.js +31 -0
  414. package/script/trellis/_sdk/core/types.d.ts +176 -0
  415. package/script/trellis/_sdk/core/types.d.ts.map +1 -0
  416. package/script/trellis/_sdk/core/types.js +6 -0
  417. package/script/trellis/auth.d.ts +2 -0
  418. package/script/trellis/auth.d.ts.map +1 -0
  419. package/script/trellis/auth.js +17 -0
  420. package/script/trellis/client.d.ts +8 -6
  421. package/script/trellis/client.d.ts.map +1 -1
  422. package/script/trellis/client.js +54 -3
  423. package/script/trellis/codec.d.ts +5 -4
  424. package/script/trellis/codec.d.ts.map +1 -1
  425. package/script/trellis/codec.js +31 -17
  426. package/script/trellis/contract.d.ts +11 -0
  427. package/script/trellis/contract.d.ts.map +1 -0
  428. package/script/trellis/contract.js +18 -0
  429. package/script/trellis/contracts.d.ts +4 -0
  430. package/script/trellis/contracts.d.ts.map +1 -0
  431. package/script/trellis/contracts.js +20 -0
  432. package/script/trellis/errors/AuthError.d.ts +2 -2
  433. package/script/trellis/errors/AuthError.d.ts.map +1 -1
  434. package/script/trellis/errors/AuthError.js +13 -2
  435. package/script/trellis/errors/KVError.d.ts +1 -1
  436. package/script/trellis/errors/KVError.d.ts.map +1 -1
  437. package/script/trellis/errors/KVError.js +2 -2
  438. package/script/trellis/errors/RemoteError.d.ts +4 -4
  439. package/script/trellis/errors/RemoteError.d.ts.map +1 -1
  440. package/script/trellis/errors/RemoteError.js +11 -11
  441. package/script/trellis/errors/TrellisError.d.ts +1 -1
  442. package/script/trellis/errors/TrellisError.d.ts.map +1 -1
  443. package/script/trellis/errors/TrellisError.js +2 -2
  444. package/script/trellis/errors/ValidationError.d.ts +1 -1
  445. package/script/trellis/errors/ValidationError.d.ts.map +1 -1
  446. package/script/trellis/errors/ValidationError.js +2 -2
  447. package/script/trellis/errors/index.d.ts +14 -14
  448. package/script/trellis/errors/index.d.ts.map +1 -1
  449. package/script/trellis/errors/index.js +31 -31
  450. package/script/trellis/globals.d.ts +9 -1
  451. package/script/trellis/globals.d.ts.map +1 -1
  452. package/script/trellis/globals.js +16 -8
  453. package/script/trellis/helpers.d.ts +1 -1
  454. package/script/trellis/helpers.d.ts.map +1 -1
  455. package/script/trellis/index.d.ts +17 -10
  456. package/script/trellis/index.d.ts.map +1 -1
  457. package/script/trellis/index.js +57 -22
  458. package/script/trellis/kv.d.ts +11 -8
  459. package/script/trellis/kv.d.ts.map +1 -1
  460. package/script/trellis/kv.js +91 -68
  461. package/script/trellis/models/trellis/TrellisError.d.ts +1 -1
  462. package/script/trellis/models/trellis/TrellisError.d.ts.map +1 -1
  463. package/script/trellis/models/trellis/TrellisError.js +8 -8
  464. package/script/trellis/operations.d.ts +81 -0
  465. package/script/trellis/operations.d.ts.map +1 -0
  466. package/script/trellis/operations.js +212 -0
  467. package/script/trellis/sdk/core.d.ts +3 -0
  468. package/script/trellis/sdk/core.d.ts.map +1 -0
  469. package/script/trellis/sdk/core.js +20 -0
  470. package/script/trellis/tasks.d.ts +3 -3
  471. package/script/trellis/tasks.d.ts.map +1 -1
  472. package/script/trellis/tasks.js +5 -5
  473. package/script/trellis/tracing.d.ts +2 -3
  474. package/script/trellis/tracing.d.ts.map +1 -1
  475. package/script/trellis/tracing.js +17 -20
  476. package/script/trellis/trellis.d.ts +169 -80
  477. package/script/trellis/trellis.d.ts.map +1 -1
  478. package/script/trellis/trellis.js +379 -177
  479. package/script/trellis/workload.d.ts +45 -0
  480. package/script/trellis/workload.d.ts.map +1 -0
  481. package/script/trellis/workload.js +172 -0
  482. package/script/_dnt.polyfills.d.ts +0 -7
  483. package/script/_dnt.polyfills.d.ts.map +0 -1
  484. package/script/trellis/browser.d.ts +0 -11
  485. package/script/trellis/browser.d.ts.map +0 -1
  486. package/script/trellis/browser.js +0 -21
  487. package/script/trellis/env.d.ts +0 -2
  488. package/script/trellis/env.d.ts.map +0 -1
  489. package/script/trellis/env.js +0 -5
  490. /package/script/{_dnt.polyfills.js → auth/types.js} +0 -0
@@ -0,0 +1,536 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _TrellisServer_instances, _TrellisServer_version, _TrellisServer_log, _TrellisServer_operations, _TrellisServer_resolveOperation, _TrellisServer_applyOperationUpdate;
13
+ import { AsyncResult, err, isErr, ok, } from "@qlever-llc/result";
14
+ import { ulid } from "ulid";
15
+ import { parseSchema } from "./codec.js";
16
+ import { AuthError, UnexpectedError, } from "./errors/index.js";
17
+ import { serverLogger } from "./server_logger.js";
18
+ import { base64urlDecode, base64urlEncode, buildProofInput, buildRuntimeOperationSnapshot, isResultLike, isTerminalRuntimeOperationSnapshot, safeJson, sha256, toArrayBuffer, Trellis, } from "./trellis.js";
19
+ export class TrellisServer extends Trellis {
20
+ constructor(name, nats, auth, opts) {
21
+ super(name, nats, auth, { ...opts, log: opts?.log ?? serverLogger });
22
+ _TrellisServer_instances.add(this);
23
+ _TrellisServer_version.set(this, void 0);
24
+ _TrellisServer_log.set(this, void 0);
25
+ _TrellisServer_operations.set(this, new Map());
26
+ Object.defineProperty(this, "operations", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ __classPrivateFieldSet(this, _TrellisServer_version, opts?.version, "f");
33
+ __classPrivateFieldSet(this, _TrellisServer_log, (opts?.log ?? serverLogger).child({ lib: "trellis-server" }), "f");
34
+ this.operations = {
35
+ get: async (operationId) => {
36
+ const runtime = await __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_resolveOperation).call(this, operationId);
37
+ if (!runtime) {
38
+ return err(new UnexpectedError({
39
+ cause: new Error(`Unknown operation '${operationId}'`),
40
+ }));
41
+ }
42
+ return ok(runtime.snapshot);
43
+ },
44
+ started: async (operationId) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "running", {
45
+ event: { type: "started" },
46
+ }),
47
+ progress: async (operationId, progress) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "running", {
48
+ patch: { progress },
49
+ event: { type: "progress" },
50
+ }),
51
+ complete: async (operationId, output) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "completed", {
52
+ patch: { output },
53
+ event: { type: "completed" },
54
+ }),
55
+ fail: async (operationId, error) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "failed", {
56
+ patch: { error: { type: error.name, message: error.message } },
57
+ event: { type: "failed" },
58
+ }),
59
+ cancel: async (operationId) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "cancelled", {
60
+ event: { type: "cancelled" },
61
+ }),
62
+ };
63
+ }
64
+ static create(name, nats, auth, opts) {
65
+ return new TrellisServer(name, nats, auth, opts);
66
+ }
67
+ operation(operation) {
68
+ const ctx = this.api["operations"]?.[operation];
69
+ if (!ctx) {
70
+ throw new Error(`Unknown operation '${operation.toString()}'. Did you forget to include its API module?`);
71
+ }
72
+ return {
73
+ handle: async (handler) => {
74
+ const startSubject = ctx.subject;
75
+ const controlSubject = `${ctx.subject}.control`;
76
+ const now = () => new Date().toISOString();
77
+ const publishFrame = async (reply, frame) => {
78
+ await this.nats.publish(reply, JSON.stringify(frame));
79
+ };
80
+ const publishSnapshot = async (reply, snapshot) => {
81
+ await publishFrame(reply, { kind: "snapshot", snapshot });
82
+ };
83
+ const publishEventToWatchers = async (runtime, event) => {
84
+ const frame = { kind: "event", sequence: runtime.sequence, event };
85
+ for (const reply of runtime.watchers) {
86
+ await publishFrame(reply, frame);
87
+ }
88
+ };
89
+ const flushWaiters = async (runtime) => {
90
+ const frame = { kind: "snapshot", snapshot: runtime.snapshot };
91
+ for (const reply of runtime.waiters) {
92
+ await publishFrame(reply, frame);
93
+ }
94
+ runtime.waiters.clear();
95
+ };
96
+ const makeOperation = (runtime) => {
97
+ const ensureActive = () => {
98
+ if (runtime.terminal) {
99
+ return err(new UnexpectedError({
100
+ cause: new Error("operation already terminal"),
101
+ }));
102
+ }
103
+ return null;
104
+ };
105
+ const transition = async (state, patch, event) => {
106
+ runtime.sequence += 1;
107
+ runtime.snapshot = buildRuntimeOperationSnapshot(runtime, state, patch);
108
+ await this.saveOperationRecord(runtime);
109
+ if (event) {
110
+ await publishEventToWatchers(runtime, event);
111
+ }
112
+ return ok(runtime.snapshot);
113
+ };
114
+ return {
115
+ id: runtime.id,
116
+ started: async () => {
117
+ const active = ensureActive();
118
+ if (active)
119
+ return active;
120
+ return transition("running", undefined, {
121
+ type: "started",
122
+ snapshot: buildRuntimeOperationSnapshot(runtime, "running", {
123
+ revision: runtime.snapshot.revision + 1,
124
+ }),
125
+ });
126
+ },
127
+ progress: async (value) => {
128
+ const active = ensureActive();
129
+ if (active)
130
+ return active;
131
+ return transition("running", { progress: value }, {
132
+ type: "progress",
133
+ snapshot: buildRuntimeOperationSnapshot(runtime, "running", {
134
+ revision: runtime.snapshot.revision + 1,
135
+ progress: value,
136
+ }),
137
+ });
138
+ },
139
+ complete: async (value) => {
140
+ const active = ensureActive();
141
+ if (active)
142
+ return active;
143
+ const snapshot = buildRuntimeOperationSnapshot(runtime, "completed", {
144
+ output: value,
145
+ completedAt: now(),
146
+ });
147
+ runtime.sequence += 1;
148
+ runtime.snapshot = snapshot;
149
+ runtime.terminal = true;
150
+ await this.saveOperationRecord(runtime);
151
+ await publishEventToWatchers(runtime, {
152
+ type: "completed",
153
+ snapshot,
154
+ });
155
+ await flushWaiters(runtime);
156
+ return ok(snapshot);
157
+ },
158
+ fail: async (error) => {
159
+ const active = ensureActive();
160
+ if (active)
161
+ return active;
162
+ const snapshot = buildRuntimeOperationSnapshot(runtime, "failed", {
163
+ error: { type: error.name, message: error.message },
164
+ completedAt: now(),
165
+ });
166
+ runtime.sequence += 1;
167
+ runtime.snapshot = snapshot;
168
+ runtime.terminal = true;
169
+ await this.saveOperationRecord(runtime);
170
+ await publishEventToWatchers(runtime, {
171
+ type: "failed",
172
+ snapshot,
173
+ });
174
+ await flushWaiters(runtime);
175
+ return ok(snapshot);
176
+ },
177
+ cancel: async () => {
178
+ const active = ensureActive();
179
+ if (active)
180
+ return active;
181
+ const snapshot = buildRuntimeOperationSnapshot(runtime, "cancelled", {
182
+ completedAt: now(),
183
+ });
184
+ runtime.sequence += 1;
185
+ runtime.snapshot = snapshot;
186
+ runtime.terminal = true;
187
+ await this.saveOperationRecord(runtime);
188
+ await publishEventToWatchers(runtime, {
189
+ type: "cancelled",
190
+ snapshot,
191
+ });
192
+ await flushWaiters(runtime);
193
+ return ok(snapshot);
194
+ },
195
+ attach: async (job) => {
196
+ const waited = await job.wait();
197
+ const waitedValue = waited.take();
198
+ if (isErr(waitedValue)) {
199
+ return err(new UnexpectedError({ cause: waitedValue.error }));
200
+ }
201
+ const finalRuntime = await __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_resolveOperation).call(this, runtime.id);
202
+ if (!finalRuntime || !finalRuntime.terminal) {
203
+ return err(new UnexpectedError({
204
+ cause: new Error("attached job completed without terminal operation state"),
205
+ }));
206
+ }
207
+ return ok(finalRuntime.snapshot);
208
+ },
209
+ };
210
+ };
211
+ const authenticate = async (msg, parseInput = true) => {
212
+ const jsonData = safeJson(msg).take();
213
+ if (isErr(jsonData))
214
+ return jsonData;
215
+ let parsedInput;
216
+ if (parseInput) {
217
+ const parsedInputResult = parseSchema(ctx.input, jsonData).take();
218
+ if (isErr(parsedInputResult)) {
219
+ return err(parsedInputResult.error);
220
+ }
221
+ parsedInput = parsedInputResult;
222
+ }
223
+ else {
224
+ parsedInput = jsonData;
225
+ }
226
+ const sessionKey = msg.headers?.get("session-key");
227
+ const proof = msg.headers?.get("proof");
228
+ if (!sessionKey) {
229
+ return err(new AuthError({ reason: "missing_session_key" }));
230
+ }
231
+ if (!proof)
232
+ return err(new AuthError({ reason: "missing_proof" }));
233
+ const payloadBytes = msg.data ?? new Uint8Array();
234
+ const payloadHash = await sha256(payloadBytes);
235
+ const proofInput = buildProofInput(sessionKey, msg.subject, payloadHash);
236
+ const digest = await sha256(proofInput);
237
+ const verifyResult = await AsyncResult.try(async () => {
238
+ const publicKeyRaw = base64urlDecode(sessionKey);
239
+ const pub = await crypto.subtle.importKey("raw", toArrayBuffer(publicKeyRaw), { name: "Ed25519" }, true, ["verify"]);
240
+ return crypto.subtle.verify({ name: "Ed25519" }, pub, toArrayBuffer(base64urlDecode(proof)), toArrayBuffer(digest));
241
+ });
242
+ const signatureOk = verifyResult.isOk() &&
243
+ (await verifyResult).take() === true;
244
+ if (!signatureOk) {
245
+ return err(new AuthError({
246
+ reason: "invalid_signature",
247
+ context: { sessionKey },
248
+ }));
249
+ }
250
+ const authResult = await this.requestAuthValidate({
251
+ sessionKey,
252
+ proof,
253
+ subject: msg.subject,
254
+ payloadHash: base64urlEncode(payloadHash),
255
+ capabilities: ctx.callerCapabilities,
256
+ });
257
+ const auth = authResult.take();
258
+ if (isErr(auth)) {
259
+ return err(auth.error);
260
+ }
261
+ if (!auth.allowed) {
262
+ return err(new AuthError({
263
+ reason: "insufficient_permissions",
264
+ context: {
265
+ requiredCapabilities: ctx.callerCapabilities,
266
+ userCapabilities: auth.caller.capabilities,
267
+ },
268
+ }));
269
+ }
270
+ if (typeof msg.reply !== "string" ||
271
+ !msg.reply.startsWith(`${auth.inboxPrefix}.`)) {
272
+ return err(new AuthError({
273
+ reason: "reply_subject_mismatch",
274
+ context: { expected: auth.inboxPrefix, actual: msg.reply },
275
+ }));
276
+ }
277
+ return ok({
278
+ input: parsedInput,
279
+ caller: auth.caller,
280
+ sessionKey,
281
+ auth,
282
+ });
283
+ };
284
+ __classPrivateFieldGet(this, _TrellisServer_log, "f").info({ operation: String(operation) }, `Mounting ${String(operation)} operation handler`);
285
+ const startSub = this.nats.subscribe(startSubject);
286
+ const controlSub = this.nats.subscribe(controlSubject);
287
+ await this.nats.flush();
288
+ void (async () => {
289
+ for await (const msg of startSub) {
290
+ const validated = await authenticate(msg, true);
291
+ const value = validated.take();
292
+ if (isErr(value)) {
293
+ this.respondWithError(msg, value.error);
294
+ continue;
295
+ }
296
+ const operationId = ulid();
297
+ const createdAt = now();
298
+ const runtime = {
299
+ id: operationId,
300
+ service: this.name,
301
+ operation: String(operation),
302
+ ownerSessionKey: value.sessionKey,
303
+ snapshot: {
304
+ id: operationId,
305
+ service: this.name,
306
+ operation: String(operation),
307
+ revision: 1,
308
+ state: "pending",
309
+ createdAt,
310
+ updatedAt: createdAt,
311
+ },
312
+ sequence: 0,
313
+ terminal: false,
314
+ watchers: new Set(),
315
+ waiters: new Set(),
316
+ };
317
+ __classPrivateFieldGet(this, _TrellisServer_operations, "f").set(operationId, runtime);
318
+ await this.saveOperationRecord(runtime);
319
+ const accepted = {
320
+ kind: "accepted",
321
+ ref: {
322
+ id: operationId,
323
+ service: this.name,
324
+ operation: String(operation),
325
+ },
326
+ snapshot: runtime.snapshot,
327
+ };
328
+ msg.respond(JSON.stringify(accepted));
329
+ void (async () => {
330
+ const op = makeOperation(runtime);
331
+ try {
332
+ const handlerResult = await handler({
333
+ input: value.input,
334
+ op,
335
+ caller: value.caller,
336
+ });
337
+ const handlerOutcome = isResultLike(handlerResult)
338
+ ? handlerResult.take()
339
+ : handlerResult;
340
+ if (isErr(handlerOutcome)) {
341
+ await op.fail(handlerOutcome.error);
342
+ return;
343
+ }
344
+ if (isTerminalRuntimeOperationSnapshot(handlerOutcome)) {
345
+ runtime.sequence = handlerOutcome.revision;
346
+ runtime.snapshot = handlerOutcome;
347
+ runtime.terminal = true;
348
+ await this.saveOperationRecord(runtime);
349
+ return;
350
+ }
351
+ if (!runtime.terminal) {
352
+ await op.complete(handlerOutcome);
353
+ }
354
+ }
355
+ catch (cause) {
356
+ await op.fail(new UnexpectedError({ cause }));
357
+ }
358
+ })();
359
+ }
360
+ })();
361
+ void (async () => {
362
+ for await (const msg of controlSub) {
363
+ const validated = await authenticate(msg, false);
364
+ const value = validated.take();
365
+ if (isErr(value)) {
366
+ this.respondWithError(msg, value.error);
367
+ continue;
368
+ }
369
+ const request = safeJson(msg).take();
370
+ if (isErr(request)) {
371
+ this.respondWithError(msg, request.error);
372
+ continue;
373
+ }
374
+ if (!request ||
375
+ typeof request !== "object" ||
376
+ typeof request.action !==
377
+ "string" ||
378
+ typeof request.operationId !==
379
+ "string") {
380
+ this.respondWithError(msg, new UnexpectedError({
381
+ cause: new Error("Invalid operation control request"),
382
+ }));
383
+ continue;
384
+ }
385
+ const control = request;
386
+ const runtime = __classPrivateFieldGet(this, _TrellisServer_operations, "f").get(control.operationId);
387
+ const durableRecord = runtime
388
+ ? null
389
+ : await this.loadOperationRecord(control.operationId);
390
+ if (!runtime && !durableRecord) {
391
+ this.respondWithError(msg, new UnexpectedError({
392
+ cause: new Error(`Unknown operation '${control.operationId}'`),
393
+ }));
394
+ continue;
395
+ }
396
+ const snapshot = runtime?.snapshot ?? durableRecord.snapshot;
397
+ const ownerSessionKey = runtime?.ownerSessionKey ??
398
+ durableRecord.ownerSessionKey;
399
+ if (ownerSessionKey !== value.sessionKey) {
400
+ this.respondWithError(msg, new AuthError({
401
+ reason: "forbidden",
402
+ context: { ownerSessionKey },
403
+ }));
404
+ continue;
405
+ }
406
+ if (control.action === "watch") {
407
+ if (msg.reply) {
408
+ await publishSnapshot(msg.reply, snapshot);
409
+ if (!runtime)
410
+ continue;
411
+ runtime.watchers.add(msg.reply);
412
+ }
413
+ continue;
414
+ }
415
+ if (control.action === "wait") {
416
+ if (snapshot.state === "completed" || snapshot.state === "failed" ||
417
+ snapshot.state === "cancelled") {
418
+ msg.respond(JSON.stringify({ kind: "snapshot", snapshot }));
419
+ }
420
+ else if (runtime && msg.reply) {
421
+ runtime.waiters.add(msg.reply);
422
+ }
423
+ else if (msg.reply) {
424
+ this.respondWithError(msg, new UnexpectedError({
425
+ cause: new Error("operation is not running in this process"),
426
+ }));
427
+ }
428
+ else {
429
+ this.respondWithError(msg, new UnexpectedError({
430
+ cause: new Error("missing reply subject for wait request"),
431
+ }));
432
+ }
433
+ continue;
434
+ }
435
+ if (control.action === "get") {
436
+ msg.respond(JSON.stringify({ kind: "snapshot", snapshot }));
437
+ continue;
438
+ }
439
+ if (control.action === "cancel") {
440
+ if (!runtime) {
441
+ msg.respond(JSON.stringify({ kind: "snapshot", snapshot }));
442
+ continue;
443
+ }
444
+ runtime.snapshot = {
445
+ ...runtime.snapshot,
446
+ revision: runtime.snapshot.revision + 1,
447
+ state: "cancelled",
448
+ updatedAt: now(),
449
+ completedAt: now(),
450
+ };
451
+ runtime.terminal = true;
452
+ runtime.sequence += 1;
453
+ await this.saveOperationRecord(runtime);
454
+ await publishEventToWatchers(runtime, {
455
+ type: "cancelled",
456
+ snapshot: runtime.snapshot,
457
+ });
458
+ await flushWaiters(runtime);
459
+ msg.respond(JSON.stringify({
460
+ kind: "snapshot",
461
+ snapshot: runtime.snapshot,
462
+ }));
463
+ continue;
464
+ }
465
+ this.respondWithError(msg, new UnexpectedError({
466
+ cause: new Error(`Unknown operation control action '${control.action}'`),
467
+ }));
468
+ }
469
+ })();
470
+ return Promise.resolve();
471
+ },
472
+ };
473
+ }
474
+ async stop() {
475
+ if (!this.natsConnection.isClosed()) {
476
+ await this.natsConnection.drain();
477
+ }
478
+ }
479
+ }
480
+ _TrellisServer_version = new WeakMap(), _TrellisServer_log = new WeakMap(), _TrellisServer_operations = new WeakMap(), _TrellisServer_instances = new WeakSet(), _TrellisServer_resolveOperation = async function _TrellisServer_resolveOperation(operationId) {
481
+ const existing = __classPrivateFieldGet(this, _TrellisServer_operations, "f").get(operationId);
482
+ if (existing)
483
+ return existing;
484
+ const durable = await this.loadOperationRecord(operationId);
485
+ if (!durable)
486
+ return null;
487
+ const runtime = {
488
+ id: durable.snapshot.id,
489
+ service: durable.snapshot.service,
490
+ operation: durable.snapshot.operation,
491
+ ownerSessionKey: durable.ownerSessionKey,
492
+ snapshot: durable.snapshot,
493
+ sequence: durable.sequence,
494
+ terminal: durable.snapshot.state === "completed" ||
495
+ durable.snapshot.state === "failed" ||
496
+ durable.snapshot.state === "cancelled",
497
+ watchers: new Set(),
498
+ waiters: new Set(),
499
+ };
500
+ __classPrivateFieldGet(this, _TrellisServer_operations, "f").set(operationId, runtime);
501
+ return runtime;
502
+ }, _TrellisServer_applyOperationUpdate = async function _TrellisServer_applyOperationUpdate(operationId, state, opts) {
503
+ const runtime = await __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_resolveOperation).call(this, operationId);
504
+ if (!runtime) {
505
+ return err(new UnexpectedError({
506
+ cause: new Error(`Unknown operation '${operationId}'`),
507
+ }));
508
+ }
509
+ if (runtime.terminal && state !== "cancelled") {
510
+ return err(new UnexpectedError({ cause: new Error("operation already terminal") }));
511
+ }
512
+ runtime.sequence += 1;
513
+ runtime.snapshot = buildRuntimeOperationSnapshot(runtime, state, opts.patch);
514
+ runtime.terminal = state === "completed" || state === "failed" ||
515
+ state === "cancelled";
516
+ await this.saveOperationRecord(runtime);
517
+ const frame = {
518
+ kind: "event",
519
+ sequence: runtime.sequence,
520
+ event: {
521
+ type: opts.event.type,
522
+ snapshot: runtime.snapshot,
523
+ },
524
+ };
525
+ for (const reply of runtime.watchers) {
526
+ await this.nats.publish(reply, JSON.stringify(frame));
527
+ }
528
+ if (runtime.terminal) {
529
+ const terminalFrame = { kind: "snapshot", snapshot: runtime.snapshot };
530
+ for (const reply of runtime.waiters) {
531
+ await this.nats.publish(reply, JSON.stringify(terminalFrame));
532
+ }
533
+ runtime.waiters.clear();
534
+ }
535
+ return ok(runtime.snapshot);
536
+ };
@@ -0,0 +1,3 @@
1
+ import type { LoggerLike } from "./globals.js";
2
+ export declare const serverLogger: LoggerLike;
3
+ //# sourceMappingURL=server_logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server_logger.d.ts","sourceRoot":"","sources":["../../src/trellis/server_logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,eAAO,MAAM,YAAY,EAAE,UAGzB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { pino } from "pino";
2
+ import { getEnv } from "./env.js";
3
+ const level = getEnv("PINO_LEVEL") || "info";
4
+ export const serverLogger = pino({
5
+ level,
6
+ base: { library: "@qlever-llc/trellis" },
7
+ });
@@ -1,9 +1,9 @@
1
- import { AsyncResult, type BaseError } from "@qlever-llc/trellis-result";
2
- import type { Logger } from "pino";
1
+ import { AsyncResult, type BaseError } from "@qlever-llc/result";
2
+ import { type LoggerLike } from "./globals.js";
3
3
  export declare class TrellisTasks {
4
4
  #private;
5
5
  constructor(opts: {
6
- log?: Logger;
6
+ log?: LoggerLike;
7
7
  });
8
8
  add<E extends BaseError>(name: string, task: AsyncResult<void, E>): void;
9
9
  wait(): AsyncResult<void, BaseError>;
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/trellis/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAU,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,qBAAa,YAAY;;gBAKX,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE;IAOlC,GAAG,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAejE,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC;CAGrC"}
1
+ {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/trellis/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAU,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvD,qBAAa,YAAY;;gBAKX,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,UAAU,CAAA;KAAE;IAOtC,GAAG,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAejE,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC;CAGrC"}
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _TrellisTasks_tasks, _TrellisTasks_log;
13
- import { AsyncResult, Result } from "@qlever-llc/trellis-result";
13
+ import { AsyncResult, Result } from "@qlever-llc/result";
14
14
  import { logger } from "./globals.js";
15
15
  export class TrellisTasks {
16
16
  constructor(opts) {
@@ -1,5 +1,5 @@
1
1
  import "../_dnt.polyfills.js";
2
- export type { HeaderCarrier, NatsHeadersLike } from "@qlever-llc/trellis-telemetry";
3
- export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "@qlever-llc/trellis-telemetry";
2
+ export type { HeaderCarrier, NatsHeadersLike } from "../telemetry/mod.js";
3
+ export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "../telemetry/mod.js";
4
4
  export declare function initTracing(serviceName: string): void;
5
5
  //# sourceMappingURL=tracing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/trellis/tracing.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAE9B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAC,qBAAqB,EAC3B,OAAO,EACP,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,EAAC,gBAAgB,IAAI,SAAS,EAC3C,kBAAkB,EAClB,QAAQ,EACR,cAAc,EAAC,eAAe,EAAE,eAAe,EAC/C,KAAK,EACL,QAAQ,EACR,aAAa,EACd,MAAM,+BAA+B,CAAC;AACvC,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAErD"}
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/trellis/tracing.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAE9B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAC,qBAAqB,EAC3B,OAAO,EACP,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,EAAC,gBAAgB,IAAI,SAAS,EAC3C,kBAAkB,EAClB,QAAQ,EACR,cAAc,EAAC,eAAe,EAAE,eAAe,EAC/C,KAAK,EACL,QAAQ,EACR,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAErD"}
@@ -1,7 +1,7 @@
1
1
  // Keep this subpath for Trellis-specific tracing convenience without exposing
2
2
  // telemetry from the root `@qlever-llc/trellis` package surface.
3
3
  import "../_dnt.polyfills.js";
4
- export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "@qlever-llc/trellis-telemetry";
4
+ export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "../telemetry/mod.js";
5
5
  export function initTracing(serviceName) {
6
- void import("@qlever-llc/trellis-telemetry").then((mod) => mod.initTracing(serviceName));
6
+ void import("../telemetry/mod.js").then((mod) => mod.initTracing(serviceName));
7
7
  }