@qlever-llc/trellis 0.7.0-rc.5 → 0.7.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 (994) hide show
  1. package/README.md +9 -8
  2. package/esm/_dnt.shims.d.ts +1 -2
  3. package/esm/_dnt.shims.d.ts.map +1 -1
  4. package/esm/auth/browser/login.d.ts +10 -2
  5. package/esm/auth/browser/login.d.ts.map +1 -1
  6. package/esm/auth/browser/login.js +37 -21
  7. package/esm/auth/browser.d.ts +4 -3
  8. package/esm/auth/browser.d.ts.map +1 -1
  9. package/esm/auth/browser.js +3 -2
  10. package/esm/auth/device_activation.d.ts +16 -4
  11. package/esm/auth/device_activation.d.ts.map +1 -1
  12. package/esm/auth/device_activation.js +37 -13
  13. package/esm/auth/mod.d.ts +4 -4
  14. package/esm/auth/mod.d.ts.map +1 -1
  15. package/esm/auth/mod.js +4 -4
  16. package/esm/auth/protocol.d.ts +330 -65
  17. package/esm/auth/protocol.d.ts.map +1 -1
  18. package/esm/auth/protocol.js +278 -206
  19. package/esm/auth/schemas.d.ts +67 -2
  20. package/esm/auth/schemas.d.ts.map +1 -1
  21. package/esm/auth/schemas.js +30 -5
  22. package/esm/auth/session_auth.d.ts +2 -3
  23. package/esm/auth/session_auth.d.ts.map +1 -1
  24. package/esm/auth/session_auth.js +24 -10
  25. package/esm/auth.d.ts +3 -0
  26. package/esm/auth.d.ts.map +1 -0
  27. package/esm/auth.js +2 -0
  28. package/esm/browser.d.ts +6 -0
  29. package/esm/browser.d.ts.map +1 -0
  30. package/esm/browser.js +5 -0
  31. package/esm/client.d.ts.map +1 -0
  32. package/esm/client_connect.d.ts +53 -0
  33. package/esm/client_connect.d.ts.map +1 -0
  34. package/esm/client_connect.js +338 -0
  35. package/esm/codec.d.ts.map +1 -0
  36. package/esm/contract.d.ts +20 -0
  37. package/esm/contract.d.ts.map +1 -0
  38. package/esm/contract.js +1 -0
  39. package/esm/contract_support/canonical.d.ts.map +1 -0
  40. package/esm/contract_support/mod.d.ts +622 -0
  41. package/esm/contract_support/mod.d.ts.map +1 -0
  42. package/esm/contract_support/mod.js +968 -0
  43. package/esm/contract_support/protocol.d.ts.map +1 -0
  44. package/esm/contract_support/protocol.js +145 -0
  45. package/esm/contract_support/runtime.d.ts +75 -0
  46. package/esm/contract_support/runtime.d.ts.map +1 -0
  47. package/esm/contract_support/schema_pointers.d.ts.map +1 -0
  48. package/esm/contracts.d.ts +5 -0
  49. package/esm/contracts.d.ts.map +1 -0
  50. package/esm/contracts.js +3 -0
  51. package/esm/device.d.ts +48 -0
  52. package/esm/device.d.ts.map +1 -0
  53. package/esm/device.js +288 -0
  54. package/esm/env.d.ts +2 -0
  55. package/esm/env.d.ts.map +1 -0
  56. package/esm/env.js +1 -0
  57. package/esm/errors/AuthError.d.ts +30 -0
  58. package/esm/errors/AuthError.d.ts.map +1 -0
  59. package/esm/errors/AuthError.js +76 -0
  60. package/esm/errors/KVError.d.ts.map +1 -0
  61. package/esm/errors/RemoteError.d.ts +53 -0
  62. package/esm/errors/RemoteError.d.ts.map +1 -0
  63. package/esm/errors/RemoteError.js +80 -0
  64. package/esm/errors/StoreError.d.ts.map +1 -0
  65. package/esm/errors/TransferError.d.ts.map +1 -0
  66. package/esm/errors/TrellisError.d.ts.map +1 -0
  67. package/esm/errors/ValidationError.d.ts.map +1 -0
  68. package/esm/errors/index.d.ts +178 -0
  69. package/esm/errors/index.d.ts.map +1 -0
  70. package/esm/errors/index.js +118 -0
  71. package/esm/globals.d.ts.map +1 -0
  72. package/esm/health.d.ts +5 -0
  73. package/esm/health.d.ts.map +1 -0
  74. package/esm/health.js +3 -0
  75. package/esm/helpers.d.ts +10 -0
  76. package/esm/helpers.d.ts.map +1 -0
  77. package/esm/helpers.js +38 -0
  78. package/esm/host/deno.d.ts +3 -0
  79. package/esm/host/deno.d.ts.map +1 -0
  80. package/esm/host/deno.js +2 -0
  81. package/esm/host/mod.d.ts +3 -0
  82. package/esm/host/mod.d.ts.map +1 -0
  83. package/esm/host/mod.js +2 -0
  84. package/esm/host/node.d.ts +3 -0
  85. package/esm/host/node.d.ts.map +1 -0
  86. package/esm/host/node.js +2 -0
  87. package/esm/index.d.ts +29 -0
  88. package/esm/index.d.ts.map +1 -0
  89. package/esm/index.js +15 -0
  90. package/esm/kv.d.ts.map +1 -0
  91. package/esm/models/trellis/TrellisError.d.ts +20 -0
  92. package/esm/models/trellis/TrellisError.d.ts.map +1 -0
  93. package/esm/models/trellis/TrellisError.js +15 -0
  94. package/esm/operations.d.ts +103 -0
  95. package/esm/operations.d.ts.map +1 -0
  96. package/esm/operations.js +229 -0
  97. package/esm/runtime_transport.d.ts +21 -0
  98. package/esm/runtime_transport.d.ts.map +1 -0
  99. package/esm/runtime_transport.js +50 -0
  100. package/esm/sdk/core.d.ts +3 -0
  101. package/esm/sdk/core.d.ts.map +1 -0
  102. package/esm/sdk/core.js +2 -0
  103. package/esm/server/deno.d.ts +1 -1
  104. package/esm/server/deno.d.ts.map +1 -1
  105. package/esm/server/health.d.ts +78 -9
  106. package/esm/server/health.d.ts.map +1 -1
  107. package/esm/server/health.js +196 -11
  108. package/esm/server/health_rpc.d.ts +2 -1
  109. package/esm/server/health_rpc.d.ts.map +1 -1
  110. package/esm/server/health_rpc.js +6 -4
  111. package/esm/server/health_schemas.d.ts +51 -0
  112. package/esm/server/health_schemas.d.ts.map +1 -1
  113. package/esm/server/health_schemas.js +39 -3
  114. package/esm/server/mod.d.ts +7 -10
  115. package/esm/server/mod.d.ts.map +1 -1
  116. package/esm/server/mod.js +6 -7
  117. package/esm/server/node.d.ts +1 -1
  118. package/esm/server/node.d.ts.map +1 -1
  119. package/esm/server/service.d.ts +65 -13
  120. package/esm/server/service.d.ts.map +1 -1
  121. package/esm/server/service.js +299 -54
  122. package/esm/server/transfer.d.ts +21 -5
  123. package/esm/server/transfer.d.ts.map +1 -1
  124. package/esm/server/transfer.js +210 -25
  125. package/esm/server.d.ts +40 -0
  126. package/esm/server.d.ts.map +1 -0
  127. package/esm/server.js +807 -0
  128. package/esm/server_logger.d.ts.map +1 -0
  129. package/esm/store.d.ts +60 -0
  130. package/esm/store.d.ts.map +1 -0
  131. package/esm/store.js +371 -0
  132. package/esm/tasks.d.ts.map +1 -0
  133. package/esm/tracing.d.ts +5 -0
  134. package/esm/tracing.d.ts.map +1 -0
  135. package/esm/tracing.js +7 -0
  136. package/esm/transfer.d.ts +114 -0
  137. package/esm/transfer.d.ts.map +1 -0
  138. package/esm/transfer.js +353 -0
  139. package/esm/trellis.d.ts +314 -0
  140. package/esm/trellis.d.ts.map +1 -0
  141. package/esm/trellis.js +1049 -0
  142. package/package.json +32 -55
  143. package/script/generated/js/sdks/trellis-core/api.d.ts.map +1 -0
  144. package/script/generated/js/sdks/trellis-core/api.js +42 -0
  145. package/script/generated/js/sdks/trellis-core/contract.d.ts +8 -0
  146. package/script/generated/js/sdks/trellis-core/contract.d.ts.map +1 -0
  147. package/script/generated/js/sdks/trellis-core/contract.js +62 -0
  148. package/script/generated/js/sdks/trellis-core/mod.d.ts +6 -0
  149. package/script/generated/js/sdks/trellis-core/mod.d.ts.map +1 -0
  150. package/script/generated/js/sdks/trellis-core/mod.js +29 -0
  151. package/script/generated/js/sdks/trellis-core/schemas.d.ts +1237 -0
  152. package/script/generated/js/sdks/trellis-core/schemas.d.ts.map +1 -0
  153. package/script/generated/js/sdks/trellis-core/schemas.js +32 -0
  154. package/script/generated/js/sdks/trellis-core/types.d.ts +198 -0
  155. package/script/generated/js/sdks/trellis-core/types.d.ts.map +1 -0
  156. package/script/generated/js/sdks/trellis-core/types.js +5 -0
  157. package/script/js/packages/trellis/auth/browser/login.d.ts +35 -0
  158. package/script/js/packages/trellis/auth/browser/login.d.ts.map +1 -0
  159. package/script/js/packages/trellis/auth/browser/login.js +117 -0
  160. package/script/js/packages/trellis/auth/browser/portal.d.ts.map +1 -0
  161. package/script/js/packages/trellis/auth/browser/portal.js +40 -0
  162. package/script/js/packages/trellis/auth/browser/session.d.ts.map +1 -0
  163. package/script/js/packages/trellis/auth/browser/session.js +79 -0
  164. package/script/js/packages/trellis/auth/browser/storage.d.ts.map +1 -0
  165. package/script/js/packages/trellis/auth/browser.d.ts +13 -0
  166. package/script/js/packages/trellis/auth/browser.d.ts.map +1 -0
  167. package/script/js/packages/trellis/auth/browser.js +52 -0
  168. package/script/js/packages/trellis/auth/device_activation.d.ts +206 -0
  169. package/script/js/packages/trellis/auth/device_activation.d.ts.map +1 -0
  170. package/script/js/packages/trellis/auth/device_activation.js +357 -0
  171. package/script/js/packages/trellis/auth/keys.d.ts.map +1 -0
  172. package/script/js/packages/trellis/auth/keys.js +56 -0
  173. package/script/js/packages/trellis/auth/mod.d.ts +18 -0
  174. package/script/js/packages/trellis/auth/mod.d.ts.map +1 -0
  175. package/script/js/packages/trellis/auth/mod.js +217 -0
  176. package/script/js/packages/trellis/auth/proof.d.ts.map +1 -0
  177. package/script/js/packages/trellis/auth/proof.js +48 -0
  178. package/script/js/packages/trellis/auth/protocol.d.ts +1580 -0
  179. package/script/js/packages/trellis/auth/protocol.d.ts.map +1 -0
  180. package/script/js/packages/trellis/auth/protocol.js +808 -0
  181. package/script/js/packages/trellis/auth/schemas.d.ts +158 -0
  182. package/script/js/packages/trellis/auth/schemas.d.ts.map +1 -0
  183. package/script/js/packages/trellis/auth/schemas.js +92 -0
  184. package/script/js/packages/trellis/auth/session_auth.d.ts +19 -0
  185. package/script/js/packages/trellis/auth/session_auth.d.ts.map +1 -0
  186. package/script/js/packages/trellis/auth/session_auth.js +59 -0
  187. package/script/js/packages/trellis/auth/trellis_id.d.ts.map +1 -0
  188. package/script/js/packages/trellis/auth/trellis_id.js +8 -0
  189. package/script/js/packages/trellis/auth/types.d.ts.map +1 -0
  190. package/script/js/packages/trellis/auth/utils.d.ts.map +1 -0
  191. package/script/js/packages/trellis/auth.d.ts +2 -0
  192. package/script/js/packages/trellis/auth.d.ts.map +1 -0
  193. package/script/js/packages/trellis/auth.js +17 -0
  194. package/script/js/packages/trellis/client.d.ts.map +1 -0
  195. package/script/js/packages/trellis/client.js +67 -0
  196. package/script/js/packages/trellis/client_connect.d.ts +53 -0
  197. package/script/js/packages/trellis/client_connect.d.ts.map +1 -0
  198. package/script/js/packages/trellis/client_connect.js +342 -0
  199. package/script/js/packages/trellis/codec.d.ts.map +1 -0
  200. package/script/js/packages/trellis/codec.js +80 -0
  201. package/script/js/packages/trellis/contract.d.ts +20 -0
  202. package/script/js/packages/trellis/contract.d.ts.map +1 -0
  203. package/script/js/packages/trellis/contract.js +9 -0
  204. package/script/js/packages/trellis/contract_support/canonical.d.ts.map +1 -0
  205. package/script/js/packages/trellis/contract_support/mod.d.ts +622 -0
  206. package/script/js/packages/trellis/contract_support/mod.d.ts.map +1 -0
  207. package/script/js/packages/trellis/contract_support/mod.js +1001 -0
  208. package/script/js/packages/trellis/contract_support/protocol.d.ts.map +1 -0
  209. package/script/js/packages/trellis/contract_support/protocol.js +151 -0
  210. package/script/js/packages/trellis/contract_support/runtime.d.ts +75 -0
  211. package/script/js/packages/trellis/contract_support/runtime.d.ts.map +1 -0
  212. package/script/js/packages/trellis/contract_support/schema_pointers.d.ts.map +1 -0
  213. package/script/js/packages/trellis/contracts.d.ts +4 -0
  214. package/script/js/packages/trellis/contracts.d.ts.map +1 -0
  215. package/script/js/packages/trellis/contracts.js +24 -0
  216. package/script/js/packages/trellis/device.d.ts +48 -0
  217. package/script/js/packages/trellis/device.d.ts.map +1 -0
  218. package/script/js/packages/trellis/device.js +292 -0
  219. package/script/js/packages/trellis/errors/AuthError.d.ts +30 -0
  220. package/script/js/packages/trellis/errors/AuthError.d.ts.map +1 -0
  221. package/script/js/packages/trellis/errors/AuthError.js +83 -0
  222. package/script/js/packages/trellis/errors/KVError.d.ts.map +1 -0
  223. package/script/js/packages/trellis/errors/KVError.js +53 -0
  224. package/script/js/packages/trellis/errors/RemoteError.d.ts +53 -0
  225. package/script/js/packages/trellis/errors/RemoteError.d.ts.map +1 -0
  226. package/script/js/packages/trellis/errors/RemoteError.js +87 -0
  227. package/script/js/packages/trellis/errors/StoreError.d.ts.map +1 -0
  228. package/script/js/packages/trellis/errors/StoreError.js +48 -0
  229. package/script/js/packages/trellis/errors/TransferError.d.ts.map +1 -0
  230. package/script/js/packages/trellis/errors/TransferError.js +48 -0
  231. package/script/js/packages/trellis/errors/TrellisError.d.ts +16 -0
  232. package/script/js/packages/trellis/errors/TrellisError.d.ts.map +1 -0
  233. package/script/js/packages/trellis/errors/TrellisError.js +19 -0
  234. package/script/js/packages/trellis/errors/ValidationError.d.ts.map +1 -0
  235. package/script/js/packages/trellis/errors/ValidationError.js +84 -0
  236. package/script/js/packages/trellis/errors/index.d.ts +177 -0
  237. package/script/js/packages/trellis/errors/index.d.ts.map +1 -0
  238. package/script/js/packages/trellis/errors/index.js +136 -0
  239. package/script/js/packages/trellis/globals.d.ts.map +1 -0
  240. package/script/js/packages/trellis/health.d.ts +4 -0
  241. package/script/js/packages/trellis/health.d.ts.map +1 -0
  242. package/script/js/packages/trellis/health.js +18 -0
  243. package/script/js/packages/trellis/helpers.d.ts +10 -0
  244. package/script/js/packages/trellis/helpers.d.ts.map +1 -0
  245. package/script/js/packages/trellis/helpers.js +44 -0
  246. package/script/js/packages/trellis/index.d.ts +28 -0
  247. package/script/js/packages/trellis/index.d.ts.map +1 -0
  248. package/script/js/packages/trellis/index.js +81 -0
  249. package/script/js/packages/trellis/kv.d.ts.map +1 -0
  250. package/script/js/packages/trellis/kv.js +383 -0
  251. package/script/js/packages/trellis/models/trellis/TrellisError.d.ts +20 -0
  252. package/script/js/packages/trellis/models/trellis/TrellisError.d.ts.map +1 -0
  253. package/script/js/packages/trellis/models/trellis/TrellisError.js +21 -0
  254. package/script/js/packages/trellis/npm/src/_dnt.polyfills.d.ts +18 -0
  255. package/script/js/packages/trellis/npm/src/_dnt.polyfills.d.ts.map +1 -0
  256. package/script/js/packages/trellis/npm/src/_dnt.shims.d.ts +5 -0
  257. package/script/js/packages/trellis/npm/src/_dnt.shims.d.ts.map +1 -0
  258. package/script/js/packages/trellis/npm/src/_dnt.shims.js +65 -0
  259. package/script/js/packages/trellis/npm/src/auth/browser/login.d.ts +35 -0
  260. package/script/js/packages/trellis/npm/src/auth/browser/login.d.ts.map +1 -0
  261. package/script/js/packages/trellis/npm/src/auth/browser/login.js +117 -0
  262. package/script/js/packages/trellis/npm/src/auth/browser/portal.d.ts +11 -0
  263. package/script/js/packages/trellis/npm/src/auth/browser/portal.d.ts.map +1 -0
  264. package/script/js/packages/trellis/npm/src/auth/browser/portal.js +40 -0
  265. package/script/js/packages/trellis/npm/src/auth/browser/session.d.ts +19 -0
  266. package/script/js/packages/trellis/npm/src/auth/browser/session.d.ts.map +1 -0
  267. package/script/js/packages/trellis/npm/src/auth/browser/session.js +79 -0
  268. package/script/js/packages/trellis/npm/src/auth/browser/storage.d.ts +12 -0
  269. package/script/js/packages/trellis/npm/src/auth/browser/storage.d.ts.map +1 -0
  270. package/script/js/packages/trellis/npm/src/auth/browser/storage.js +67 -0
  271. package/script/js/packages/trellis/npm/src/auth/browser.d.ts +14 -0
  272. package/script/js/packages/trellis/npm/src/auth/browser.d.ts.map +1 -0
  273. package/script/js/packages/trellis/npm/src/auth/browser.js +53 -0
  274. package/script/js/packages/trellis/npm/src/auth/device_activation.d.ts +206 -0
  275. package/script/js/packages/trellis/npm/src/auth/device_activation.d.ts.map +1 -0
  276. package/script/js/packages/trellis/npm/src/auth/device_activation.js +357 -0
  277. package/script/js/packages/trellis/npm/src/auth/keys.d.ts +5 -0
  278. package/script/js/packages/trellis/npm/src/auth/keys.d.ts.map +1 -0
  279. package/script/js/packages/trellis/npm/src/auth/keys.js +56 -0
  280. package/script/js/packages/trellis/npm/src/auth/mod.d.ts +18 -0
  281. package/script/js/packages/trellis/npm/src/auth/mod.d.ts.map +1 -0
  282. package/script/js/packages/trellis/npm/src/auth/mod.js +217 -0
  283. package/script/js/packages/trellis/npm/src/auth/proof.d.ts +9 -0
  284. package/script/js/packages/trellis/npm/src/auth/proof.d.ts.map +1 -0
  285. package/script/js/packages/trellis/npm/src/auth/proof.js +48 -0
  286. package/script/js/packages/trellis/npm/src/auth/protocol.d.ts +1580 -0
  287. package/script/js/packages/trellis/npm/src/auth/protocol.d.ts.map +1 -0
  288. package/script/js/packages/trellis/npm/src/auth/protocol.js +808 -0
  289. package/script/js/packages/trellis/npm/src/auth/schemas.d.ts +158 -0
  290. package/script/js/packages/trellis/npm/src/auth/schemas.d.ts.map +1 -0
  291. package/script/js/packages/trellis/npm/src/auth/schemas.js +92 -0
  292. package/script/js/packages/trellis/npm/src/auth/session_auth.d.ts +19 -0
  293. package/script/js/packages/trellis/npm/src/auth/session_auth.d.ts.map +1 -0
  294. package/script/js/packages/trellis/npm/src/auth/session_auth.js +59 -0
  295. package/script/js/packages/trellis/npm/src/auth/trellis_id.d.ts +2 -0
  296. package/script/js/packages/trellis/npm/src/auth/trellis_id.d.ts.map +1 -0
  297. package/script/js/packages/trellis/npm/src/auth/trellis_id.js +8 -0
  298. package/script/js/packages/trellis/npm/src/auth/types.d.ts +8 -0
  299. package/script/js/packages/trellis/npm/src/auth/types.d.ts.map +1 -0
  300. package/script/js/packages/trellis/npm/src/auth/types.js +2 -0
  301. package/script/js/packages/trellis/npm/src/auth/utils.d.ts +11 -0
  302. package/script/js/packages/trellis/npm/src/auth/utils.d.ts.map +1 -0
  303. package/script/js/packages/trellis/npm/src/auth/utils.js +77 -0
  304. package/script/js/packages/trellis/npm/src/auth.d.ts +3 -0
  305. package/script/js/packages/trellis/npm/src/auth.d.ts.map +1 -0
  306. package/script/js/packages/trellis/npm/src/auth.js +18 -0
  307. package/script/js/packages/trellis/npm/src/browser.d.ts +6 -0
  308. package/script/js/packages/trellis/npm/src/browser.d.ts.map +1 -0
  309. package/script/js/packages/trellis/npm/src/browser.js +21 -0
  310. package/script/js/packages/trellis/npm/src/client.d.ts +33 -0
  311. package/script/js/packages/trellis/npm/src/client.d.ts.map +1 -0
  312. package/script/js/packages/trellis/npm/src/client.js +67 -0
  313. package/script/js/packages/trellis/npm/src/client_connect.d.ts +53 -0
  314. package/script/js/packages/trellis/npm/src/client_connect.d.ts.map +1 -0
  315. package/script/js/packages/trellis/npm/src/client_connect.js +366 -0
  316. package/script/js/packages/trellis/npm/src/codec.d.ts +13 -0
  317. package/script/js/packages/trellis/npm/src/codec.d.ts.map +1 -0
  318. package/script/js/packages/trellis/npm/src/codec.js +80 -0
  319. package/script/js/packages/trellis/npm/src/contract.d.ts +20 -0
  320. package/script/js/packages/trellis/npm/src/contract.d.ts.map +1 -0
  321. package/script/js/packages/trellis/npm/src/contract.js +9 -0
  322. package/script/js/packages/trellis/npm/src/contract_support/canonical.d.ts +14 -0
  323. package/script/js/packages/trellis/npm/src/contract_support/canonical.d.ts.map +1 -0
  324. package/script/js/packages/trellis/npm/src/contract_support/canonical.js +144 -0
  325. package/script/js/packages/trellis/npm/src/contract_support/mod.d.ts +622 -0
  326. package/script/js/packages/trellis/npm/src/contract_support/mod.d.ts.map +1 -0
  327. package/script/js/packages/trellis/npm/src/contract_support/mod.js +1001 -0
  328. package/script/js/packages/trellis/npm/src/contract_support/protocol.d.ts +335 -0
  329. package/script/js/packages/trellis/npm/src/contract_support/protocol.d.ts.map +1 -0
  330. package/script/js/packages/trellis/npm/src/contract_support/protocol.js +151 -0
  331. package/script/js/packages/trellis/npm/src/contract_support/runtime.d.ts +75 -0
  332. package/script/js/packages/trellis/npm/src/contract_support/runtime.d.ts.map +1 -0
  333. package/script/js/packages/trellis/npm/src/contract_support/runtime.js +13 -0
  334. package/script/js/packages/trellis/npm/src/contract_support/schema_pointers.d.ts +18 -0
  335. package/script/js/packages/trellis/npm/src/contract_support/schema_pointers.d.ts.map +1 -0
  336. package/script/js/packages/trellis/npm/src/contract_support/schema_pointers.js +63 -0
  337. package/script/js/packages/trellis/npm/src/contracts.d.ts +5 -0
  338. package/script/js/packages/trellis/npm/src/contracts.d.ts.map +1 -0
  339. package/script/js/packages/trellis/npm/src/contracts.js +25 -0
  340. package/script/js/packages/trellis/npm/src/device.d.ts +48 -0
  341. package/script/js/packages/trellis/npm/src/device.d.ts.map +1 -0
  342. package/script/js/packages/trellis/npm/src/device.js +292 -0
  343. package/script/js/packages/trellis/npm/src/env.d.ts +2 -0
  344. package/script/js/packages/trellis/npm/src/env.d.ts.map +1 -0
  345. package/script/js/packages/trellis/npm/src/env.js +5 -0
  346. package/script/js/packages/trellis/npm/src/errors/AuthError.d.ts +30 -0
  347. package/script/js/packages/trellis/npm/src/errors/AuthError.d.ts.map +1 -0
  348. package/script/js/packages/trellis/npm/src/errors/AuthError.js +83 -0
  349. package/script/js/packages/trellis/npm/src/errors/KVError.d.ts +31 -0
  350. package/script/js/packages/trellis/npm/src/errors/KVError.d.ts.map +1 -0
  351. package/script/js/packages/trellis/npm/src/errors/KVError.js +53 -0
  352. package/script/js/packages/trellis/npm/src/errors/RemoteError.d.ts +53 -0
  353. package/script/js/packages/trellis/npm/src/errors/RemoteError.d.ts.map +1 -0
  354. package/script/js/packages/trellis/npm/src/errors/RemoteError.js +87 -0
  355. package/script/js/packages/trellis/npm/src/errors/StoreError.d.ts +22 -0
  356. package/script/js/packages/trellis/npm/src/errors/StoreError.d.ts.map +1 -0
  357. package/script/js/packages/trellis/npm/src/errors/StoreError.js +48 -0
  358. package/script/js/packages/trellis/npm/src/errors/TransferError.d.ts +22 -0
  359. package/script/js/packages/trellis/npm/src/errors/TransferError.d.ts.map +1 -0
  360. package/script/js/packages/trellis/npm/src/errors/TransferError.js +48 -0
  361. package/script/js/packages/trellis/npm/src/errors/TrellisError.d.ts +16 -0
  362. package/script/js/packages/trellis/npm/src/errors/TrellisError.d.ts.map +1 -0
  363. package/script/js/packages/trellis/npm/src/errors/TrellisError.js +19 -0
  364. package/script/js/packages/trellis/npm/src/errors/ValidationError.d.ts +51 -0
  365. package/script/js/packages/trellis/npm/src/errors/ValidationError.d.ts.map +1 -0
  366. package/script/js/packages/trellis/npm/src/errors/ValidationError.js +84 -0
  367. package/script/js/packages/trellis/npm/src/errors/index.d.ts +178 -0
  368. package/script/js/packages/trellis/npm/src/errors/index.d.ts.map +1 -0
  369. package/script/js/packages/trellis/npm/src/errors/index.js +137 -0
  370. package/script/js/packages/trellis/npm/src/globals.d.ts +10 -0
  371. package/script/js/packages/trellis/npm/src/globals.d.ts.map +1 -0
  372. package/script/js/packages/trellis/npm/src/globals.js +19 -0
  373. package/script/js/packages/trellis/npm/src/health.d.ts +5 -0
  374. package/script/js/packages/trellis/npm/src/health.d.ts.map +1 -0
  375. package/script/js/packages/trellis/npm/src/health.js +19 -0
  376. package/script/js/packages/trellis/npm/src/helpers.d.ts +10 -0
  377. package/script/js/packages/trellis/npm/src/helpers.d.ts.map +1 -0
  378. package/script/js/packages/trellis/npm/src/helpers.js +44 -0
  379. package/script/js/packages/trellis/npm/src/host/deno.d.ts +3 -0
  380. package/script/js/packages/trellis/npm/src/host/deno.d.ts.map +1 -0
  381. package/script/js/packages/trellis/npm/src/host/deno.js +18 -0
  382. package/script/js/packages/trellis/npm/src/host/mod.d.ts +3 -0
  383. package/script/js/packages/trellis/npm/src/host/mod.d.ts.map +1 -0
  384. package/script/js/packages/trellis/npm/src/host/mod.js +18 -0
  385. package/script/js/packages/trellis/npm/src/host/node.d.ts +3 -0
  386. package/script/js/packages/trellis/npm/src/host/node.d.ts.map +1 -0
  387. package/script/js/packages/trellis/npm/src/host/node.js +18 -0
  388. package/script/js/packages/trellis/npm/src/index.d.ts +29 -0
  389. package/script/js/packages/trellis/npm/src/index.d.ts.map +1 -0
  390. package/script/js/packages/trellis/npm/src/index.js +82 -0
  391. package/script/js/packages/trellis/npm/src/kv.d.ts +72 -0
  392. package/script/js/packages/trellis/npm/src/kv.d.ts.map +1 -0
  393. package/script/js/packages/trellis/npm/src/kv.js +383 -0
  394. package/script/js/packages/trellis/npm/src/models/trellis/TrellisError.d.ts +20 -0
  395. package/script/js/packages/trellis/npm/src/models/trellis/TrellisError.d.ts.map +1 -0
  396. package/script/js/packages/trellis/npm/src/models/trellis/TrellisError.js +21 -0
  397. package/script/js/packages/trellis/npm/src/operations.d.ts +103 -0
  398. package/script/js/packages/trellis/npm/src/operations.d.ts.map +1 -0
  399. package/script/js/packages/trellis/npm/src/operations.js +235 -0
  400. package/script/js/packages/trellis/npm/src/runtime_transport.d.ts +21 -0
  401. package/script/js/packages/trellis/npm/src/runtime_transport.d.ts.map +1 -0
  402. package/script/js/packages/trellis/npm/src/runtime_transport.js +77 -0
  403. package/script/js/packages/trellis/npm/src/sdk/core.d.ts +3 -0
  404. package/script/js/packages/trellis/npm/src/sdk/core.d.ts.map +1 -0
  405. package/script/js/packages/trellis/npm/src/sdk/core.js +20 -0
  406. package/script/js/packages/trellis/npm/src/server/deno.d.ts +2 -0
  407. package/script/js/packages/trellis/npm/src/server/deno.d.ts.map +1 -0
  408. package/script/js/packages/trellis/npm/src/server/deno.js +6 -0
  409. package/script/js/packages/trellis/npm/src/server/health.d.ts +161 -0
  410. package/script/js/packages/trellis/npm/src/server/health.d.ts.map +1 -0
  411. package/script/js/packages/trellis/npm/src/server/health.js +291 -0
  412. package/script/js/packages/trellis/npm/src/server/health_rpc.d.ts +17 -0
  413. package/script/js/packages/trellis/npm/src/server/health_rpc.d.ts.map +1 -0
  414. package/script/js/packages/trellis/npm/src/server/health_rpc.js +28 -0
  415. package/script/js/packages/trellis/npm/src/server/health_schemas.d.ts +71 -0
  416. package/script/js/packages/trellis/npm/src/server/health_schemas.d.ts.map +1 -0
  417. package/script/js/packages/trellis/npm/src/server/health_schemas.js +57 -0
  418. package/script/js/packages/trellis/npm/src/server/mod.d.ts +15 -0
  419. package/script/js/packages/trellis/npm/src/server/mod.d.ts.map +1 -0
  420. package/script/js/packages/trellis/npm/src/server/mod.js +39 -0
  421. package/script/js/packages/trellis/npm/src/server/node.d.ts +2 -0
  422. package/script/js/packages/trellis/npm/src/server/node.d.ts.map +1 -0
  423. package/script/js/packages/trellis/npm/src/server/node.js +6 -0
  424. package/script/js/packages/trellis/npm/src/server/runtime.d.ts +16 -0
  425. package/script/js/packages/trellis/npm/src/server/runtime.d.ts.map +1 -0
  426. package/script/js/packages/trellis/npm/src/server/runtime.js +2 -0
  427. package/script/js/packages/trellis/npm/src/server/service.d.ts +205 -0
  428. package/script/js/packages/trellis/npm/src/server/service.d.ts.map +1 -0
  429. package/script/js/packages/trellis/npm/src/server/service.js +654 -0
  430. package/script/js/packages/trellis/npm/src/server/subscription.d.ts +99 -0
  431. package/script/js/packages/trellis/npm/src/server/subscription.d.ts.map +1 -0
  432. package/script/js/packages/trellis/npm/src/server/subscription.js +29 -0
  433. package/script/js/packages/trellis/npm/src/server/transfer.d.ts +57 -0
  434. package/script/js/packages/trellis/npm/src/server/transfer.d.ts.map +1 -0
  435. package/script/js/packages/trellis/npm/src/server/transfer.js +607 -0
  436. package/script/js/packages/trellis/npm/src/server.d.ts +40 -0
  437. package/script/js/packages/trellis/npm/src/server.d.ts.map +1 -0
  438. package/script/js/packages/trellis/npm/src/server.js +811 -0
  439. package/script/js/packages/trellis/npm/src/server_logger.d.ts +3 -0
  440. package/script/js/packages/trellis/npm/src/server_logger.d.ts.map +1 -0
  441. package/script/js/packages/trellis/npm/src/server_logger.js +10 -0
  442. package/script/js/packages/trellis/npm/src/store.d.ts +60 -0
  443. package/script/js/packages/trellis/npm/src/store.d.ts.map +1 -0
  444. package/script/js/packages/trellis/npm/src/store.js +377 -0
  445. package/script/js/packages/trellis/npm/src/tasks.d.ts +11 -0
  446. package/script/js/packages/trellis/npm/src/tasks.d.ts.map +1 -0
  447. package/script/js/packages/trellis/npm/src/tasks.js +45 -0
  448. package/script/js/packages/trellis/npm/src/telemetry/carrier.d.ts.map +1 -0
  449. package/script/js/packages/trellis/npm/src/telemetry/core.d.ts.map +1 -0
  450. package/script/js/packages/trellis/npm/src/telemetry/env.d.ts.map +1 -0
  451. package/script/js/packages/trellis/npm/src/telemetry/env.js +36 -0
  452. package/script/js/packages/trellis/npm/src/telemetry/init.d.ts +4 -0
  453. package/script/js/packages/trellis/npm/src/telemetry/init.d.ts.map +1 -0
  454. package/script/js/packages/trellis/npm/src/telemetry/init.js +11 -0
  455. package/script/js/packages/trellis/npm/src/telemetry/mod.d.ts +10 -0
  456. package/script/js/packages/trellis/npm/src/telemetry/mod.d.ts.map +1 -0
  457. package/script/js/packages/trellis/npm/src/telemetry/mod.js +26 -0
  458. package/script/js/packages/trellis/npm/src/telemetry/nats.d.ts +7 -0
  459. package/script/js/packages/trellis/npm/src/telemetry/nats.d.ts.map +1 -0
  460. package/script/js/packages/trellis/npm/src/telemetry/result.d.ts.map +1 -0
  461. package/script/js/packages/trellis/npm/src/telemetry/runtime.d.ts.map +1 -0
  462. package/script/js/packages/trellis/npm/src/telemetry/runtime.js +60 -0
  463. package/script/js/packages/trellis/npm/src/telemetry/trace.d.ts.map +1 -0
  464. package/script/js/packages/trellis/npm/src/telemetry/trace.js +31 -0
  465. package/script/js/packages/trellis/npm/src/telemetry/trellis.d.ts +2 -0
  466. package/script/js/packages/trellis/npm/src/telemetry/trellis.d.ts.map +1 -0
  467. package/script/js/packages/trellis/npm/src/telemetry/trellis.js +7 -0
  468. package/script/js/packages/trellis/npm/src/tracing.d.ts +5 -0
  469. package/script/js/packages/trellis/npm/src/tracing.d.ts.map +1 -0
  470. package/script/js/packages/trellis/npm/src/tracing.js +49 -0
  471. package/script/js/packages/trellis/npm/src/transfer.d.ts +114 -0
  472. package/script/js/packages/trellis/npm/src/transfer.d.ts.map +1 -0
  473. package/script/js/packages/trellis/npm/src/transfer.js +363 -0
  474. package/script/js/packages/trellis/npm/src/trellis.d.ts +314 -0
  475. package/script/js/packages/trellis/npm/src/trellis.d.ts.map +1 -0
  476. package/script/js/packages/trellis/npm/src/trellis.js +1062 -0
  477. package/script/js/packages/trellis/operations.d.ts +103 -0
  478. package/script/js/packages/trellis/operations.d.ts.map +1 -0
  479. package/script/js/packages/trellis/operations.js +235 -0
  480. package/script/js/packages/trellis/runtime_transport.d.ts +21 -0
  481. package/script/js/packages/trellis/runtime_transport.d.ts.map +1 -0
  482. package/script/js/packages/trellis/runtime_transport.js +53 -0
  483. package/script/js/packages/trellis/sdk/core.d.ts +3 -0
  484. package/script/js/packages/trellis/sdk/core.d.ts.map +1 -0
  485. package/script/js/packages/trellis/sdk/core.js +20 -0
  486. package/script/js/packages/trellis/server/health.d.ts +170 -0
  487. package/script/js/packages/trellis/server/health.d.ts.map +1 -0
  488. package/script/js/packages/trellis/server/health.js +267 -0
  489. package/script/js/packages/trellis/server/health_schemas.d.ts +71 -0
  490. package/script/js/packages/trellis/server/health_schemas.d.ts.map +1 -0
  491. package/script/js/packages/trellis/server/health_schemas.js +57 -0
  492. package/script/js/packages/trellis/store.d.ts +60 -0
  493. package/script/js/packages/trellis/store.d.ts.map +1 -0
  494. package/script/js/packages/trellis/store.js +377 -0
  495. package/script/js/packages/trellis/tasks.d.ts.map +1 -0
  496. package/script/js/packages/trellis/tasks.js +45 -0
  497. package/script/js/packages/trellis/telemetry/carrier.d.ts +9 -0
  498. package/script/js/packages/trellis/telemetry/carrier.d.ts.map +1 -0
  499. package/script/js/packages/trellis/telemetry/carrier.js +25 -0
  500. package/script/js/packages/trellis/telemetry/core.d.ts +8 -0
  501. package/script/js/packages/trellis/telemetry/core.d.ts.map +1 -0
  502. package/script/js/packages/trellis/telemetry/core.js +24 -0
  503. package/script/js/packages/trellis/telemetry/env.d.ts +2 -0
  504. package/script/js/packages/trellis/telemetry/env.d.ts.map +1 -0
  505. package/script/js/packages/trellis/telemetry/init.d.ts.map +1 -0
  506. package/script/js/packages/trellis/telemetry/init.js +11 -0
  507. package/script/js/packages/trellis/telemetry/mod.d.ts.map +1 -0
  508. package/script/js/packages/trellis/telemetry/mod.js +26 -0
  509. package/script/js/packages/trellis/telemetry/nats.d.ts.map +1 -0
  510. package/script/js/packages/trellis/telemetry/nats.js +9 -0
  511. package/script/js/packages/trellis/telemetry/result.d.ts +2 -0
  512. package/script/js/packages/trellis/telemetry/result.d.ts.map +1 -0
  513. package/script/js/packages/trellis/telemetry/result.js +21 -0
  514. package/script/js/packages/trellis/telemetry/runtime.d.ts +2 -0
  515. package/script/js/packages/trellis/telemetry/runtime.d.ts.map +1 -0
  516. package/script/js/packages/trellis/telemetry/runtime.js +60 -0
  517. package/script/js/packages/trellis/telemetry/trace.d.ts +5 -0
  518. package/script/js/packages/trellis/telemetry/trace.d.ts.map +1 -0
  519. package/script/js/packages/trellis/telemetry/trace.js +31 -0
  520. package/script/js/packages/trellis/telemetry/trellis.d.ts.map +1 -0
  521. package/script/js/packages/trellis/telemetry/trellis.js +7 -0
  522. package/script/js/packages/trellis/tracing.d.ts +4 -0
  523. package/script/js/packages/trellis/tracing.d.ts.map +1 -0
  524. package/script/js/packages/trellis/tracing.js +46 -0
  525. package/script/js/packages/trellis/transfer.d.ts +114 -0
  526. package/script/js/packages/trellis/transfer.d.ts.map +1 -0
  527. package/script/js/packages/trellis/transfer.js +363 -0
  528. package/script/js/packages/trellis/trellis.d.ts +314 -0
  529. package/script/js/packages/trellis/trellis.d.ts.map +1 -0
  530. package/script/js/packages/trellis/trellis.js +1062 -0
  531. package/esm/contracts/canonical.d.ts.map +0 -1
  532. package/esm/contracts/mod.d.ts +0 -482
  533. package/esm/contracts/mod.d.ts.map +0 -1
  534. package/esm/contracts/mod.js +0 -558
  535. package/esm/contracts/protocol.d.ts.map +0 -1
  536. package/esm/contracts/protocol.js +0 -145
  537. package/esm/contracts/runtime.d.ts +0 -48
  538. package/esm/contracts/runtime.d.ts.map +0 -1
  539. package/esm/contracts/schema_pointers.d.ts.map +0 -1
  540. package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts +0 -12
  541. package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +0 -1
  542. package/esm/trellis/_sdk/activity/_dnt.polyfills.js +0 -15
  543. package/esm/trellis/_sdk/activity/api.d.ts.map +0 -1
  544. package/esm/trellis/_sdk/activity/api.js +0 -43
  545. package/esm/trellis/_sdk/activity/contract.d.ts +0 -8
  546. package/esm/trellis/_sdk/activity/contract.d.ts.map +0 -1
  547. package/esm/trellis/_sdk/activity/contract.js +0 -59
  548. package/esm/trellis/_sdk/activity/mod.d.ts +0 -7
  549. package/esm/trellis/_sdk/activity/mod.d.ts.map +0 -1
  550. package/esm/trellis/_sdk/activity/mod.js +0 -5
  551. package/esm/trellis/_sdk/activity/package.json +0 -3
  552. package/esm/trellis/_sdk/activity/schemas.d.ts +0 -607
  553. package/esm/trellis/_sdk/activity/schemas.d.ts.map +0 -1
  554. package/esm/trellis/_sdk/activity/schemas.js +0 -33
  555. package/esm/trellis/_sdk/activity/types.d.ts +0 -96
  556. package/esm/trellis/_sdk/activity/types.d.ts.map +0 -1
  557. package/esm/trellis/_sdk/activity/types.js +0 -3
  558. package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts +0 -12
  559. package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +0 -1
  560. package/esm/trellis/_sdk/auth/_dnt.polyfills.js +0 -15
  561. package/esm/trellis/_sdk/auth/api.d.ts +0 -10
  562. package/esm/trellis/_sdk/auth/api.d.ts.map +0 -1
  563. package/esm/trellis/_sdk/auth/api.js +0 -376
  564. package/esm/trellis/_sdk/auth/contract.d.ts +0 -28
  565. package/esm/trellis/_sdk/auth/contract.d.ts.map +0 -1
  566. package/esm/trellis/_sdk/auth/contract.js +0 -83
  567. package/esm/trellis/_sdk/auth/mod.d.ts +0 -7
  568. package/esm/trellis/_sdk/auth/mod.d.ts.map +0 -1
  569. package/esm/trellis/_sdk/auth/mod.js +0 -5
  570. package/esm/trellis/_sdk/auth/package.json +0 -3
  571. package/esm/trellis/_sdk/auth/schemas.d.ts +0 -10110
  572. package/esm/trellis/_sdk/auth/schemas.d.ts.map +0 -1
  573. package/esm/trellis/_sdk/auth/schemas.js +0 -325
  574. package/esm/trellis/_sdk/auth/types.d.ts +0 -1382
  575. package/esm/trellis/_sdk/auth/types.d.ts.map +0 -1
  576. package/esm/trellis/_sdk/auth/types.js +0 -3
  577. package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts +0 -12
  578. package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts.map +0 -1
  579. package/esm/trellis/_sdk/core/_dnt.polyfills.js +0 -15
  580. package/esm/trellis/_sdk/core/api.d.ts +0 -10
  581. package/esm/trellis/_sdk/core/api.d.ts.map +0 -1
  582. package/esm/trellis/_sdk/core/api.js +0 -36
  583. package/esm/trellis/_sdk/core/contract.d.ts +0 -8
  584. package/esm/trellis/_sdk/core/contract.d.ts.map +0 -1
  585. package/esm/trellis/_sdk/core/contract.js +0 -59
  586. package/esm/trellis/_sdk/core/mod.d.ts +0 -7
  587. package/esm/trellis/_sdk/core/mod.d.ts.map +0 -1
  588. package/esm/trellis/_sdk/core/mod.js +0 -5
  589. package/esm/trellis/_sdk/core/package.json +0 -3
  590. package/esm/trellis/_sdk/core/schemas.d.ts +0 -1266
  591. package/esm/trellis/_sdk/core/schemas.d.ts.map +0 -1
  592. package/esm/trellis/_sdk/core/schemas.js +0 -28
  593. package/esm/trellis/_sdk/core/types.d.ts +0 -193
  594. package/esm/trellis/_sdk/core/types.d.ts.map +0 -1
  595. package/esm/trellis/_sdk/core/types.js +0 -3
  596. package/esm/trellis/_sdk/state/_dnt.polyfills.d.ts +0 -12
  597. package/esm/trellis/_sdk/state/_dnt.polyfills.d.ts.map +0 -1
  598. package/esm/trellis/_sdk/state/_dnt.polyfills.js +0 -15
  599. package/esm/trellis/_sdk/state/api.d.ts +0 -10
  600. package/esm/trellis/_sdk/state/api.d.ts.map +0 -1
  601. package/esm/trellis/_sdk/state/api.js +0 -71
  602. package/esm/trellis/_sdk/state/contract.d.ts +0 -8
  603. package/esm/trellis/_sdk/state/contract.d.ts.map +0 -1
  604. package/esm/trellis/_sdk/state/contract.js +0 -59
  605. package/esm/trellis/_sdk/state/mod.d.ts +0 -7
  606. package/esm/trellis/_sdk/state/mod.d.ts.map +0 -1
  607. package/esm/trellis/_sdk/state/mod.js +0 -5
  608. package/esm/trellis/_sdk/state/package.json +0 -3
  609. package/esm/trellis/_sdk/state/schemas.d.ts +0 -1437
  610. package/esm/trellis/_sdk/state/schemas.d.ts.map +0 -1
  611. package/esm/trellis/_sdk/state/schemas.js +0 -62
  612. package/esm/trellis/_sdk/state/types.d.ts +0 -206
  613. package/esm/trellis/_sdk/state/types.d.ts.map +0 -1
  614. package/esm/trellis/_sdk/state/types.js +0 -3
  615. package/esm/trellis/auth/browser.d.ts +0 -3
  616. package/esm/trellis/auth/browser.d.ts.map +0 -1
  617. package/esm/trellis/auth/browser.js +0 -2
  618. package/esm/trellis/auth.d.ts +0 -3
  619. package/esm/trellis/auth.d.ts.map +0 -1
  620. package/esm/trellis/auth.js +0 -2
  621. package/esm/trellis/browser.d.ts +0 -6
  622. package/esm/trellis/browser.d.ts.map +0 -1
  623. package/esm/trellis/browser.js +0 -5
  624. package/esm/trellis/client.d.ts.map +0 -1
  625. package/esm/trellis/client_connect.d.ts +0 -53
  626. package/esm/trellis/client_connect.d.ts.map +0 -1
  627. package/esm/trellis/client_connect.js +0 -300
  628. package/esm/trellis/codec.d.ts.map +0 -1
  629. package/esm/trellis/contract.d.ts +0 -20
  630. package/esm/trellis/contract.d.ts.map +0 -1
  631. package/esm/trellis/contract.js +0 -4
  632. package/esm/trellis/contracts.d.ts +0 -5
  633. package/esm/trellis/contracts.d.ts.map +0 -1
  634. package/esm/trellis/contracts.js +0 -3
  635. package/esm/trellis/device.d.ts +0 -41
  636. package/esm/trellis/device.d.ts.map +0 -1
  637. package/esm/trellis/device.js +0 -209
  638. package/esm/trellis/env.d.ts +0 -2
  639. package/esm/trellis/env.d.ts.map +0 -1
  640. package/esm/trellis/env.js +0 -1
  641. package/esm/trellis/errors/AuthError.d.ts +0 -30
  642. package/esm/trellis/errors/AuthError.d.ts.map +0 -1
  643. package/esm/trellis/errors/AuthError.js +0 -76
  644. package/esm/trellis/errors/KVError.d.ts.map +0 -1
  645. package/esm/trellis/errors/RemoteError.d.ts +0 -47
  646. package/esm/trellis/errors/RemoteError.d.ts.map +0 -1
  647. package/esm/trellis/errors/RemoteError.js +0 -80
  648. package/esm/trellis/errors/StoreError.d.ts.map +0 -1
  649. package/esm/trellis/errors/TransferError.d.ts.map +0 -1
  650. package/esm/trellis/errors/TrellisError.d.ts.map +0 -1
  651. package/esm/trellis/errors/ValidationError.d.ts.map +0 -1
  652. package/esm/trellis/errors/index.d.ts +0 -47
  653. package/esm/trellis/errors/index.d.ts.map +0 -1
  654. package/esm/trellis/errors/index.js +0 -35
  655. package/esm/trellis/globals.d.ts.map +0 -1
  656. package/esm/trellis/helpers.d.ts +0 -13
  657. package/esm/trellis/helpers.d.ts.map +0 -1
  658. package/esm/trellis/helpers.js +0 -48
  659. package/esm/trellis/index.d.ts +0 -25
  660. package/esm/trellis/index.d.ts.map +0 -1
  661. package/esm/trellis/index.js +0 -13
  662. package/esm/trellis/kv.d.ts.map +0 -1
  663. package/esm/trellis/models/trellis/TrellisError.d.ts +0 -57
  664. package/esm/trellis/models/trellis/TrellisError.d.ts.map +0 -1
  665. package/esm/trellis/models/trellis/TrellisError.js +0 -20
  666. package/esm/trellis/operations.d.ts +0 -81
  667. package/esm/trellis/operations.d.ts.map +0 -1
  668. package/esm/trellis/operations.js +0 -206
  669. package/esm/trellis/runtime_transport.d.ts +0 -12
  670. package/esm/trellis/runtime_transport.d.ts.map +0 -1
  671. package/esm/trellis/runtime_transport.js +0 -35
  672. package/esm/trellis/sdk/activity.d.ts +0 -3
  673. package/esm/trellis/sdk/activity.d.ts.map +0 -1
  674. package/esm/trellis/sdk/activity.js +0 -2
  675. package/esm/trellis/sdk/auth.d.ts +0 -4
  676. package/esm/trellis/sdk/auth.d.ts.map +0 -1
  677. package/esm/trellis/sdk/auth.js +0 -3
  678. package/esm/trellis/sdk/core.d.ts +0 -4
  679. package/esm/trellis/sdk/core.d.ts.map +0 -1
  680. package/esm/trellis/sdk/core.js +0 -3
  681. package/esm/trellis/sdk/state.d.ts +0 -4
  682. package/esm/trellis/sdk/state.d.ts.map +0 -1
  683. package/esm/trellis/sdk/state.js +0 -3
  684. package/esm/trellis/server/deno.d.ts +0 -3
  685. package/esm/trellis/server/deno.d.ts.map +0 -1
  686. package/esm/trellis/server/deno.js +0 -2
  687. package/esm/trellis/server/health.d.ts +0 -5
  688. package/esm/trellis/server/health.d.ts.map +0 -1
  689. package/esm/trellis/server/health.js +0 -3
  690. package/esm/trellis/server/mod.d.ts +0 -3
  691. package/esm/trellis/server/mod.d.ts.map +0 -1
  692. package/esm/trellis/server/mod.js +0 -2
  693. package/esm/trellis/server/node.d.ts +0 -3
  694. package/esm/trellis/server/node.d.ts.map +0 -1
  695. package/esm/trellis/server/node.js +0 -2
  696. package/esm/trellis/server/runtime.d.ts +0 -4
  697. package/esm/trellis/server/runtime.d.ts.map +0 -1
  698. package/esm/trellis/server/runtime.js +0 -2
  699. package/esm/trellis/server.d.ts +0 -21
  700. package/esm/trellis/server.d.ts.map +0 -1
  701. package/esm/trellis/server.js +0 -536
  702. package/esm/trellis/server_logger.d.ts.map +0 -1
  703. package/esm/trellis/store.d.ts +0 -51
  704. package/esm/trellis/store.d.ts.map +0 -1
  705. package/esm/trellis/store.js +0 -310
  706. package/esm/trellis/tasks.d.ts.map +0 -1
  707. package/esm/trellis/tracing.d.ts +0 -5
  708. package/esm/trellis/tracing.d.ts.map +0 -1
  709. package/esm/trellis/tracing.js +0 -7
  710. package/esm/trellis/transfer.d.ts +0 -118
  711. package/esm/trellis/transfer.d.ts.map +0 -1
  712. package/esm/trellis/transfer.js +0 -357
  713. package/esm/trellis/trellis.d.ts +0 -210
  714. package/esm/trellis/trellis.d.ts.map +0 -1
  715. package/esm/trellis/trellis.js +0 -935
  716. package/script/auth/browser/login.d.ts +0 -27
  717. package/script/auth/browser/login.d.ts.map +0 -1
  718. package/script/auth/browser/login.js +0 -100
  719. package/script/auth/browser/portal.d.ts.map +0 -1
  720. package/script/auth/browser/portal.js +0 -40
  721. package/script/auth/browser/session.d.ts.map +0 -1
  722. package/script/auth/browser/session.js +0 -79
  723. package/script/auth/browser/storage.d.ts.map +0 -1
  724. package/script/auth/browser.d.ts +0 -13
  725. package/script/auth/browser.d.ts.map +0 -1
  726. package/script/auth/browser.js +0 -46
  727. package/script/auth/device_activation.d.ts +0 -194
  728. package/script/auth/device_activation.d.ts.map +0 -1
  729. package/script/auth/device_activation.js +0 -333
  730. package/script/auth/keys.d.ts.map +0 -1
  731. package/script/auth/keys.js +0 -56
  732. package/script/auth/mod.d.ts +0 -18
  733. package/script/auth/mod.d.ts.map +0 -1
  734. package/script/auth/mod.js +0 -180
  735. package/script/auth/proof.d.ts.map +0 -1
  736. package/script/auth/proof.js +0 -48
  737. package/script/auth/protocol.d.ts +0 -1315
  738. package/script/auth/protocol.d.ts.map +0 -1
  739. package/script/auth/protocol.js +0 -735
  740. package/script/auth/schemas.d.ts +0 -93
  741. package/script/auth/schemas.d.ts.map +0 -1
  742. package/script/auth/schemas.js +0 -67
  743. package/script/auth/session_auth.d.ts +0 -20
  744. package/script/auth/session_auth.d.ts.map +0 -1
  745. package/script/auth/session_auth.js +0 -45
  746. package/script/auth/trellis_id.d.ts.map +0 -1
  747. package/script/auth/trellis_id.js +0 -8
  748. package/script/auth/types.d.ts.map +0 -1
  749. package/script/auth/utils.d.ts.map +0 -1
  750. package/script/contracts/canonical.d.ts.map +0 -1
  751. package/script/contracts/mod.d.ts +0 -482
  752. package/script/contracts/mod.d.ts.map +0 -1
  753. package/script/contracts/mod.js +0 -583
  754. package/script/contracts/protocol.d.ts.map +0 -1
  755. package/script/contracts/protocol.js +0 -151
  756. package/script/contracts/runtime.d.ts +0 -48
  757. package/script/contracts/runtime.d.ts.map +0 -1
  758. package/script/contracts/schema_pointers.d.ts.map +0 -1
  759. package/script/telemetry/carrier.d.ts.map +0 -1
  760. package/script/telemetry/core.d.ts.map +0 -1
  761. package/script/telemetry/env.d.ts.map +0 -1
  762. package/script/telemetry/init.d.ts.map +0 -1
  763. package/script/telemetry/init.js +0 -11
  764. package/script/telemetry/mod.d.ts.map +0 -1
  765. package/script/telemetry/mod.js +0 -26
  766. package/script/telemetry/nats.d.ts.map +0 -1
  767. package/script/telemetry/result.d.ts.map +0 -1
  768. package/script/telemetry/runtime.d.ts.map +0 -1
  769. package/script/telemetry/runtime.js +0 -60
  770. package/script/telemetry/trace.d.ts.map +0 -1
  771. package/script/telemetry/trace.js +0 -31
  772. package/script/telemetry/trellis.d.ts.map +0 -1
  773. package/script/telemetry/trellis.js +0 -7
  774. package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts +0 -12
  775. package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +0 -1
  776. package/script/trellis/_sdk/activity/api.d.ts +0 -10
  777. package/script/trellis/_sdk/activity/api.d.ts.map +0 -1
  778. package/script/trellis/_sdk/activity/api.js +0 -46
  779. package/script/trellis/_sdk/activity/contract.d.ts +0 -8
  780. package/script/trellis/_sdk/activity/contract.d.ts.map +0 -1
  781. package/script/trellis/_sdk/activity/contract.js +0 -62
  782. package/script/trellis/_sdk/activity/mod.d.ts +0 -7
  783. package/script/trellis/_sdk/activity/mod.d.ts.map +0 -1
  784. package/script/trellis/_sdk/activity/mod.js +0 -30
  785. package/script/trellis/_sdk/activity/package.json +0 -3
  786. package/script/trellis/_sdk/activity/schemas.d.ts +0 -607
  787. package/script/trellis/_sdk/activity/schemas.d.ts.map +0 -1
  788. package/script/trellis/_sdk/activity/schemas.js +0 -36
  789. package/script/trellis/_sdk/activity/types.d.ts +0 -96
  790. package/script/trellis/_sdk/activity/types.d.ts.map +0 -1
  791. package/script/trellis/_sdk/activity/types.js +0 -6
  792. package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts +0 -12
  793. package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +0 -1
  794. package/script/trellis/_sdk/auth/_dnt.polyfills.js +0 -16
  795. package/script/trellis/_sdk/auth/api.d.ts +0 -10
  796. package/script/trellis/_sdk/auth/api.d.ts.map +0 -1
  797. package/script/trellis/_sdk/auth/api.js +0 -379
  798. package/script/trellis/_sdk/auth/contract.d.ts +0 -28
  799. package/script/trellis/_sdk/auth/contract.d.ts.map +0 -1
  800. package/script/trellis/_sdk/auth/contract.js +0 -86
  801. package/script/trellis/_sdk/auth/mod.d.ts +0 -7
  802. package/script/trellis/_sdk/auth/mod.d.ts.map +0 -1
  803. package/script/trellis/_sdk/auth/mod.js +0 -31
  804. package/script/trellis/_sdk/auth/package.json +0 -3
  805. package/script/trellis/_sdk/auth/schemas.d.ts +0 -10110
  806. package/script/trellis/_sdk/auth/schemas.d.ts.map +0 -1
  807. package/script/trellis/_sdk/auth/schemas.js +0 -328
  808. package/script/trellis/_sdk/auth/types.d.ts +0 -1382
  809. package/script/trellis/_sdk/auth/types.d.ts.map +0 -1
  810. package/script/trellis/_sdk/auth/types.js +0 -6
  811. package/script/trellis/_sdk/core/_dnt.polyfills.d.ts +0 -12
  812. package/script/trellis/_sdk/core/_dnt.polyfills.d.ts.map +0 -1
  813. package/script/trellis/_sdk/core/_dnt.polyfills.js +0 -16
  814. package/script/trellis/_sdk/core/api.d.ts +0 -10
  815. package/script/trellis/_sdk/core/api.d.ts.map +0 -1
  816. package/script/trellis/_sdk/core/api.js +0 -39
  817. package/script/trellis/_sdk/core/contract.d.ts +0 -8
  818. package/script/trellis/_sdk/core/contract.d.ts.map +0 -1
  819. package/script/trellis/_sdk/core/contract.js +0 -62
  820. package/script/trellis/_sdk/core/mod.d.ts +0 -7
  821. package/script/trellis/_sdk/core/mod.d.ts.map +0 -1
  822. package/script/trellis/_sdk/core/mod.js +0 -30
  823. package/script/trellis/_sdk/core/package.json +0 -3
  824. package/script/trellis/_sdk/core/schemas.d.ts +0 -1266
  825. package/script/trellis/_sdk/core/schemas.d.ts.map +0 -1
  826. package/script/trellis/_sdk/core/schemas.js +0 -31
  827. package/script/trellis/_sdk/core/types.d.ts +0 -193
  828. package/script/trellis/_sdk/core/types.d.ts.map +0 -1
  829. package/script/trellis/_sdk/core/types.js +0 -6
  830. package/script/trellis/_sdk/state/_dnt.polyfills.d.ts +0 -12
  831. package/script/trellis/_sdk/state/_dnt.polyfills.d.ts.map +0 -1
  832. package/script/trellis/_sdk/state/_dnt.polyfills.js +0 -16
  833. package/script/trellis/_sdk/state/api.d.ts +0 -10
  834. package/script/trellis/_sdk/state/api.d.ts.map +0 -1
  835. package/script/trellis/_sdk/state/api.js +0 -74
  836. package/script/trellis/_sdk/state/contract.d.ts +0 -8
  837. package/script/trellis/_sdk/state/contract.d.ts.map +0 -1
  838. package/script/trellis/_sdk/state/contract.js +0 -62
  839. package/script/trellis/_sdk/state/mod.d.ts +0 -7
  840. package/script/trellis/_sdk/state/mod.d.ts.map +0 -1
  841. package/script/trellis/_sdk/state/mod.js +0 -30
  842. package/script/trellis/_sdk/state/package.json +0 -3
  843. package/script/trellis/_sdk/state/schemas.d.ts +0 -1437
  844. package/script/trellis/_sdk/state/schemas.d.ts.map +0 -1
  845. package/script/trellis/_sdk/state/schemas.js +0 -65
  846. package/script/trellis/_sdk/state/types.d.ts +0 -206
  847. package/script/trellis/_sdk/state/types.d.ts.map +0 -1
  848. package/script/trellis/_sdk/state/types.js +0 -6
  849. package/script/trellis/auth.d.ts +0 -2
  850. package/script/trellis/auth.d.ts.map +0 -1
  851. package/script/trellis/auth.js +0 -17
  852. package/script/trellis/client.d.ts.map +0 -1
  853. package/script/trellis/client.js +0 -67
  854. package/script/trellis/client_connect.d.ts +0 -53
  855. package/script/trellis/client_connect.d.ts.map +0 -1
  856. package/script/trellis/client_connect.js +0 -304
  857. package/script/trellis/codec.d.ts.map +0 -1
  858. package/script/trellis/codec.js +0 -80
  859. package/script/trellis/contract.d.ts +0 -20
  860. package/script/trellis/contract.d.ts.map +0 -1
  861. package/script/trellis/contract.js +0 -7
  862. package/script/trellis/contracts.d.ts +0 -4
  863. package/script/trellis/contracts.d.ts.map +0 -1
  864. package/script/trellis/contracts.js +0 -20
  865. package/script/trellis/device.d.ts +0 -41
  866. package/script/trellis/device.d.ts.map +0 -1
  867. package/script/trellis/device.js +0 -213
  868. package/script/trellis/errors/AuthError.d.ts +0 -30
  869. package/script/trellis/errors/AuthError.d.ts.map +0 -1
  870. package/script/trellis/errors/AuthError.js +0 -83
  871. package/script/trellis/errors/KVError.d.ts.map +0 -1
  872. package/script/trellis/errors/KVError.js +0 -53
  873. package/script/trellis/errors/RemoteError.d.ts +0 -47
  874. package/script/trellis/errors/RemoteError.d.ts.map +0 -1
  875. package/script/trellis/errors/RemoteError.js +0 -87
  876. package/script/trellis/errors/StoreError.d.ts.map +0 -1
  877. package/script/trellis/errors/StoreError.js +0 -48
  878. package/script/trellis/errors/TransferError.d.ts.map +0 -1
  879. package/script/trellis/errors/TransferError.js +0 -48
  880. package/script/trellis/errors/TrellisError.d.ts +0 -16
  881. package/script/trellis/errors/TrellisError.d.ts.map +0 -1
  882. package/script/trellis/errors/TrellisError.js +0 -19
  883. package/script/trellis/errors/ValidationError.d.ts.map +0 -1
  884. package/script/trellis/errors/ValidationError.js +0 -84
  885. package/script/trellis/errors/index.d.ts +0 -46
  886. package/script/trellis/errors/index.d.ts.map +0 -1
  887. package/script/trellis/errors/index.js +0 -52
  888. package/script/trellis/globals.d.ts.map +0 -1
  889. package/script/trellis/helpers.d.ts +0 -12
  890. package/script/trellis/helpers.d.ts.map +0 -1
  891. package/script/trellis/helpers.js +0 -54
  892. package/script/trellis/index.d.ts +0 -24
  893. package/script/trellis/index.d.ts.map +0 -1
  894. package/script/trellis/index.js +0 -70
  895. package/script/trellis/kv.d.ts.map +0 -1
  896. package/script/trellis/kv.js +0 -383
  897. package/script/trellis/models/trellis/TrellisError.d.ts +0 -57
  898. package/script/trellis/models/trellis/TrellisError.d.ts.map +0 -1
  899. package/script/trellis/models/trellis/TrellisError.js +0 -26
  900. package/script/trellis/operations.d.ts +0 -81
  901. package/script/trellis/operations.d.ts.map +0 -1
  902. package/script/trellis/operations.js +0 -212
  903. package/script/trellis/runtime_transport.d.ts +0 -12
  904. package/script/trellis/runtime_transport.d.ts.map +0 -1
  905. package/script/trellis/runtime_transport.js +0 -37
  906. package/script/trellis/sdk/core.d.ts +0 -3
  907. package/script/trellis/sdk/core.d.ts.map +0 -1
  908. package/script/trellis/sdk/core.js +0 -20
  909. package/script/trellis/store.d.ts +0 -51
  910. package/script/trellis/store.d.ts.map +0 -1
  911. package/script/trellis/store.js +0 -316
  912. package/script/trellis/tasks.d.ts.map +0 -1
  913. package/script/trellis/tasks.js +0 -45
  914. package/script/trellis/tracing.d.ts +0 -4
  915. package/script/trellis/tracing.d.ts.map +0 -1
  916. package/script/trellis/tracing.js +0 -46
  917. package/script/trellis/transfer.d.ts +0 -118
  918. package/script/trellis/transfer.d.ts.map +0 -1
  919. package/script/trellis/transfer.js +0 -367
  920. package/script/trellis/trellis.d.ts +0 -210
  921. package/script/trellis/trellis.d.ts.map +0 -1
  922. package/script/trellis/trellis.js +0 -948
  923. /package/esm/{trellis/client.d.ts → client.d.ts} +0 -0
  924. /package/esm/{trellis/client.js → client.js} +0 -0
  925. /package/esm/{trellis/codec.d.ts → codec.d.ts} +0 -0
  926. /package/esm/{trellis/codec.js → codec.js} +0 -0
  927. /package/esm/{contracts → contract_support}/canonical.d.ts +0 -0
  928. /package/esm/{contracts → contract_support}/canonical.js +0 -0
  929. /package/esm/{contracts → contract_support}/protocol.d.ts +0 -0
  930. /package/esm/{contracts → contract_support}/runtime.js +0 -0
  931. /package/esm/{contracts → contract_support}/schema_pointers.d.ts +0 -0
  932. /package/esm/{contracts → contract_support}/schema_pointers.js +0 -0
  933. /package/esm/{trellis/errors → errors}/KVError.d.ts +0 -0
  934. /package/esm/{trellis/errors → errors}/KVError.js +0 -0
  935. /package/esm/{trellis/errors → errors}/StoreError.d.ts +0 -0
  936. /package/esm/{trellis/errors → errors}/StoreError.js +0 -0
  937. /package/esm/{trellis/errors → errors}/TransferError.d.ts +0 -0
  938. /package/esm/{trellis/errors → errors}/TransferError.js +0 -0
  939. /package/esm/{trellis/errors → errors}/TrellisError.d.ts +0 -0
  940. /package/esm/{trellis/errors → errors}/TrellisError.js +0 -0
  941. /package/esm/{trellis/errors → errors}/ValidationError.d.ts +0 -0
  942. /package/esm/{trellis/errors → errors}/ValidationError.js +0 -0
  943. /package/esm/{trellis/globals.d.ts → globals.d.ts} +0 -0
  944. /package/esm/{trellis/globals.js → globals.js} +0 -0
  945. /package/esm/{trellis/kv.d.ts → kv.d.ts} +0 -0
  946. /package/esm/{trellis/kv.js → kv.js} +0 -0
  947. /package/esm/{trellis/server_logger.d.ts → server_logger.d.ts} +0 -0
  948. /package/esm/{trellis/server_logger.js → server_logger.js} +0 -0
  949. /package/esm/{trellis/tasks.d.ts → tasks.d.ts} +0 -0
  950. /package/esm/{trellis/tasks.js → tasks.js} +0 -0
  951. /package/{esm/trellis/_sdk/activity → script/generated/js/sdks/trellis-core}/api.d.ts +0 -0
  952. /package/script/{auth → js/packages/trellis/auth}/browser/portal.d.ts +0 -0
  953. /package/script/{auth → js/packages/trellis/auth}/browser/session.d.ts +0 -0
  954. /package/script/{auth → js/packages/trellis/auth}/browser/storage.d.ts +0 -0
  955. /package/script/{auth → js/packages/trellis/auth}/browser/storage.js +0 -0
  956. /package/script/{auth → js/packages/trellis/auth}/keys.d.ts +0 -0
  957. /package/script/{auth → js/packages/trellis/auth}/proof.d.ts +0 -0
  958. /package/script/{auth → js/packages/trellis/auth}/trellis_id.d.ts +0 -0
  959. /package/script/{auth → js/packages/trellis/auth}/types.d.ts +0 -0
  960. /package/script/{auth → js/packages/trellis/auth}/types.js +0 -0
  961. /package/script/{auth → js/packages/trellis/auth}/utils.d.ts +0 -0
  962. /package/script/{auth → js/packages/trellis/auth}/utils.js +0 -0
  963. /package/script/{trellis → js/packages/trellis}/client.d.ts +0 -0
  964. /package/script/{trellis → js/packages/trellis}/codec.d.ts +0 -0
  965. /package/script/{contracts → js/packages/trellis/contract_support}/canonical.d.ts +0 -0
  966. /package/script/{contracts → js/packages/trellis/contract_support}/canonical.js +0 -0
  967. /package/script/{contracts → js/packages/trellis/contract_support}/protocol.d.ts +0 -0
  968. /package/script/{contracts → js/packages/trellis/contract_support}/runtime.js +0 -0
  969. /package/script/{contracts → js/packages/trellis/contract_support}/schema_pointers.d.ts +0 -0
  970. /package/script/{contracts → js/packages/trellis/contract_support}/schema_pointers.js +0 -0
  971. /package/script/{trellis → js/packages/trellis}/errors/KVError.d.ts +0 -0
  972. /package/script/{trellis → js/packages/trellis}/errors/StoreError.d.ts +0 -0
  973. /package/script/{trellis → js/packages/trellis}/errors/TransferError.d.ts +0 -0
  974. /package/script/{trellis → js/packages/trellis}/errors/ValidationError.d.ts +0 -0
  975. /package/script/{trellis → js/packages/trellis}/globals.d.ts +0 -0
  976. /package/script/{trellis → js/packages/trellis}/globals.js +0 -0
  977. /package/script/{trellis → js/packages/trellis}/kv.d.ts +0 -0
  978. /package/script/{trellis/_sdk/activity → js/packages/trellis/npm/src}/_dnt.polyfills.js +0 -0
  979. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/carrier.d.ts +0 -0
  980. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/carrier.js +0 -0
  981. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/core.d.ts +0 -0
  982. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/core.js +0 -0
  983. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/env.d.ts +0 -0
  984. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/nats.js +0 -0
  985. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/result.d.ts +0 -0
  986. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/result.js +0 -0
  987. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/runtime.d.ts +0 -0
  988. /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/trace.d.ts +0 -0
  989. /package/script/{trellis → js/packages/trellis}/tasks.d.ts +0 -0
  990. /package/script/{telemetry → js/packages/trellis/telemetry}/env.js +0 -0
  991. /package/script/{telemetry → js/packages/trellis/telemetry}/init.d.ts +0 -0
  992. /package/script/{telemetry → js/packages/trellis/telemetry}/mod.d.ts +0 -0
  993. /package/script/{telemetry → js/packages/trellis/telemetry}/nats.d.ts +0 -0
  994. /package/script/{telemetry → js/packages/trellis/telemetry}/trellis.d.ts +0 -0
@@ -0,0 +1,1062 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ 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");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Trellis_instances, _Trellis_log, _Trellis_tasks, _Trellis_hasExplicitApi, _Trellis_noResponderMaxRetries, _Trellis_noResponderRetryMs, _Trellis_authBypassMethods, _Trellis_operationStore, _Trellis_unknownApiError, _Trellis_handleRPC, _Trellis_processRPCMessage, _Trellis_respondWithError, _Trellis_startEphemeralEvent, _Trellis_handleDurableEvent, _Trellis_parseEventMessage, _Trellis_escapeSubjectToken, _Trellis_createProof, _Trellis_requestJson, _Trellis_watchJson;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Trellis = exports.DurableOperationRecordSchema = void 0;
16
+ exports.safeJson = safeJson;
17
+ exports.base64urlEncode = base64urlEncode;
18
+ exports.base64urlDecode = base64urlDecode;
19
+ exports.toArrayBuffer = toArrayBuffer;
20
+ exports.sha256 = sha256;
21
+ exports.buildProofInput = buildProofInput;
22
+ exports.isResultLike = isResultLike;
23
+ exports.buildRuntimeOperationSnapshot = buildRuntimeOperationSnapshot;
24
+ exports.isTerminalRuntimeOperationSnapshot = isTerminalRuntimeOperationSnapshot;
25
+ const jetstream_1 = require("@nats-io/jetstream");
26
+ const nats_core_1 = require("@nats-io/nats-core");
27
+ const result_1 = require("@qlever-llc/result");
28
+ const tracing_js_1 = require("./tracing.js");
29
+ const typebox_1 = require("typebox");
30
+ const value_1 = require("typebox/value");
31
+ const ulid_1 = require("ulid");
32
+ const codec_js_1 = require("./codec.js");
33
+ const index_js_1 = require("./errors/index.js");
34
+ const RemoteError_js_1 = require("./errors/RemoteError.js");
35
+ const globals_js_1 = require("./globals.js");
36
+ const kv_js_1 = require("./kv.js");
37
+ const TrellisError_js_1 = require("./models/trellis/TrellisError.js");
38
+ const operations_js_1 = require("./operations.js");
39
+ const transfer_js_1 = require("./transfer.js");
40
+ const tasks_js_1 = require("./tasks.js");
41
+ /**
42
+ * Safely extract JSON from a NATS message.
43
+ * The .json() method can throw if the message data is not valid JSON.
44
+ */
45
+ function safeJson(msg) {
46
+ return result_1.Result.try(() => msg.json());
47
+ }
48
+ function encodeRuntimeSchema(schema, data) {
49
+ return (0, codec_js_1.encodeSchema)(schema, data);
50
+ }
51
+ function parseRuntimeSchema(schema, data) {
52
+ return (0, codec_js_1.parseUnknownSchema)(schema, data);
53
+ }
54
+ function base64urlEncode(data) {
55
+ const b64 = btoa(String.fromCharCode(...data));
56
+ return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
57
+ }
58
+ function base64urlDecode(s) {
59
+ const normalized = s.replace(/-/g, "+").replace(/_/g, "/");
60
+ const padLen = (4 - (normalized.length % 4)) % 4;
61
+ const padded = normalized + "=".repeat(padLen);
62
+ const bin = atob(padded);
63
+ const out = new Uint8Array(bin.length);
64
+ for (let i = 0; i < bin.length; i++)
65
+ out[i] = bin.charCodeAt(i);
66
+ return out;
67
+ }
68
+ function toArrayBuffer(data) {
69
+ const buf = data.buffer;
70
+ if (buf instanceof ArrayBuffer) {
71
+ return buf.slice(data.byteOffset, data.byteOffset + data.byteLength);
72
+ }
73
+ const copy = new Uint8Array(data.byteLength);
74
+ copy.set(data);
75
+ return copy.buffer;
76
+ }
77
+ async function sha256(data) {
78
+ const digest = await crypto.subtle.digest("SHA-256", toArrayBuffer(data));
79
+ return new Uint8Array(digest);
80
+ }
81
+ function buildProofInput(sessionKey, subject, payloadHash) {
82
+ const enc = new TextEncoder();
83
+ const sessionKeyBytes = enc.encode(sessionKey);
84
+ const subjectBytes = enc.encode(subject);
85
+ const buf = new Uint8Array(4 +
86
+ sessionKeyBytes.length +
87
+ 4 +
88
+ subjectBytes.length +
89
+ 4 +
90
+ payloadHash.length);
91
+ const view = new DataView(buf.buffer);
92
+ let offset = 0;
93
+ view.setUint32(offset, sessionKeyBytes.length);
94
+ offset += 4;
95
+ buf.set(sessionKeyBytes, offset);
96
+ offset += sessionKeyBytes.length;
97
+ view.setUint32(offset, subjectBytes.length);
98
+ offset += 4;
99
+ buf.set(subjectBytes, offset);
100
+ offset += subjectBytes.length;
101
+ view.setUint32(offset, payloadHash.length);
102
+ offset += 4;
103
+ buf.set(payloadHash, offset);
104
+ return buf;
105
+ }
106
+ function isResultLike(value) {
107
+ return value instanceof result_1.Result;
108
+ }
109
+ const DurableOperationSnapshotSchema = typebox_1.Type.Object({
110
+ id: typebox_1.Type.String(),
111
+ service: typebox_1.Type.String(),
112
+ operation: typebox_1.Type.String(),
113
+ revision: typebox_1.Type.Number(),
114
+ state: typebox_1.Type.Union([
115
+ typebox_1.Type.Literal("pending"),
116
+ typebox_1.Type.Literal("running"),
117
+ typebox_1.Type.Literal("completed"),
118
+ typebox_1.Type.Literal("failed"),
119
+ typebox_1.Type.Literal("cancelled"),
120
+ ]),
121
+ createdAt: typebox_1.Type.String(),
122
+ updatedAt: typebox_1.Type.String(),
123
+ completedAt: typebox_1.Type.Optional(typebox_1.Type.String()),
124
+ progress: typebox_1.Type.Optional(typebox_1.Type.Any()),
125
+ transfer: typebox_1.Type.Optional(typebox_1.Type.Object({
126
+ chunkIndex: typebox_1.Type.Number(),
127
+ chunkBytes: typebox_1.Type.Number(),
128
+ transferredBytes: typebox_1.Type.Number(),
129
+ })),
130
+ output: typebox_1.Type.Optional(typebox_1.Type.Any()),
131
+ error: typebox_1.Type.Optional(typebox_1.Type.Object({
132
+ type: typebox_1.Type.String(),
133
+ message: typebox_1.Type.String(),
134
+ })),
135
+ });
136
+ exports.DurableOperationRecordSchema = typebox_1.Type.Object({
137
+ ownerSessionKey: typebox_1.Type.String(),
138
+ sequence: typebox_1.Type.Number(),
139
+ snapshot: DurableOperationSnapshotSchema,
140
+ });
141
+ function buildRuntimeOperationSnapshot(runtime, state, patch) {
142
+ const updatedAt = new Date().toISOString();
143
+ const completedAt = state === "completed" || state === "failed" || state === "cancelled"
144
+ ? (patch?.completedAt ?? updatedAt)
145
+ : patch?.completedAt;
146
+ return {
147
+ id: runtime.id,
148
+ service: runtime.service,
149
+ operation: runtime.operation,
150
+ revision: patch?.revision ?? runtime.snapshot.revision + 1,
151
+ state,
152
+ createdAt: patch?.createdAt ?? runtime.snapshot.createdAt,
153
+ updatedAt,
154
+ ...(completedAt ? { completedAt } : {}),
155
+ ...(patch?.progress !== undefined
156
+ ? { progress: patch.progress }
157
+ : runtime.snapshot.progress !== undefined
158
+ ? { progress: runtime.snapshot.progress }
159
+ : {}),
160
+ ...(patch?.transfer !== undefined
161
+ ? { transfer: patch.transfer }
162
+ : runtime.snapshot.transfer !== undefined
163
+ ? { transfer: runtime.snapshot.transfer }
164
+ : {}),
165
+ ...(patch?.output !== undefined
166
+ ? { output: patch.output }
167
+ : runtime.snapshot.output !== undefined
168
+ ? { output: runtime.snapshot.output }
169
+ : {}),
170
+ ...(patch?.error
171
+ ? { error: patch.error }
172
+ : runtime.snapshot.error
173
+ ? { error: runtime.snapshot.error }
174
+ : {}),
175
+ };
176
+ }
177
+ function isRuntimeOperationSnapshot(value) {
178
+ return !!value && typeof value === "object" &&
179
+ typeof value.id === "string" &&
180
+ typeof value.service === "string" &&
181
+ typeof value.operation === "string" &&
182
+ typeof value.revision === "number" &&
183
+ typeof value.state === "string" &&
184
+ typeof value.createdAt === "string" &&
185
+ typeof value.updatedAt === "string";
186
+ }
187
+ function isTerminalRuntimeOperationSnapshot(value) {
188
+ return isRuntimeOperationSnapshot(value) && (value.state === "completed" || value.state === "failed" ||
189
+ value.state === "cancelled");
190
+ }
191
+ const NATS_SUBJECT_TOKEN_FORBIDDEN = /[\u0000\s.*>~]/gu;
192
+ const DEFAULT_NO_RESPONDER_MAX_RETRIES = 2;
193
+ const DEFAULT_NO_RESPONDER_RETRY_MS = 200;
194
+ const DEFAULT_AUTH_VALIDATE_SESSION_RETRY_ATTEMPTS = 3;
195
+ const DEFAULT_AUTH_VALIDATE_SESSION_RETRY_MS = 25;
196
+ const EMPTY_TRELLIS_API = {
197
+ rpc: {},
198
+ operations: {},
199
+ events: {},
200
+ subjects: {},
201
+ };
202
+ function isTransientAuthValidateSessionError(error) {
203
+ if (error instanceof index_js_1.AuthError) {
204
+ return error.reason === "session_not_found";
205
+ }
206
+ if (error instanceof RemoteError_js_1.RemoteError &&
207
+ error.remoteError.type === "AuthError") {
208
+ const reason = Reflect.get(error.remoteError, "reason");
209
+ return typeof reason === "string" && reason === "session_not_found";
210
+ }
211
+ return false;
212
+ }
213
+ function isDeclaredRpcError(errorNames, type) {
214
+ return !!errorNames?.includes(type);
215
+ }
216
+ function isRuntimeRpcErrorDesc(value) {
217
+ return !!value && typeof value === "object" &&
218
+ typeof Reflect.get(value, "type") === "string" &&
219
+ typeof Reflect.get(value, "fromSerializable") === "function";
220
+ }
221
+ function reconstructDeclaredRpcError(errorNames, runtimeErrors, data, json) {
222
+ if (!isDeclaredRpcError(errorNames, data.type)) {
223
+ return null;
224
+ }
225
+ const runtimeError = (0, index_js_1.getBuiltinRpcError)(data.type) ??
226
+ runtimeErrors?.find((candidate) => candidate.type === data.type);
227
+ if (!runtimeError) {
228
+ return null;
229
+ }
230
+ const parsed = runtimeError.schema
231
+ ? parseRuntimeSchema(runtimeError.schema, json).take()
232
+ : data;
233
+ if ((0, result_1.isErr)(parsed)) {
234
+ return parsed.error instanceof index_js_1.ValidationError ||
235
+ parsed.error instanceof index_js_1.UnexpectedError
236
+ ? parsed.error
237
+ : new index_js_1.UnexpectedError({ cause: parsed.error });
238
+ }
239
+ try {
240
+ const reconstructed = runtimeError.fromSerializable(parsed);
241
+ if (reconstructed instanceof result_1.BaseError) {
242
+ return reconstructed;
243
+ }
244
+ return new index_js_1.UnexpectedError({
245
+ cause: new Error(`RPC error '${data.type}' reconstructed to a non-Trellis error instance`),
246
+ });
247
+ }
248
+ catch (cause) {
249
+ return new index_js_1.UnexpectedError({ cause });
250
+ }
251
+ }
252
+ async function sleep(ms) {
253
+ await new Promise((resolve) => setTimeout(resolve, ms));
254
+ }
255
+ class Trellis {
256
+ constructor(name, // Must be unique for a service
257
+ nats, auth, opts) {
258
+ _Trellis_instances.add(this);
259
+ Object.defineProperty(this, "name", {
260
+ enumerable: true,
261
+ configurable: true,
262
+ writable: true,
263
+ value: void 0
264
+ });
265
+ Object.defineProperty(this, "timeout", {
266
+ enumerable: true,
267
+ configurable: true,
268
+ writable: true,
269
+ value: void 0
270
+ });
271
+ Object.defineProperty(this, "stream", {
272
+ enumerable: true,
273
+ configurable: true,
274
+ writable: true,
275
+ value: void 0
276
+ });
277
+ Object.defineProperty(this, "nats", {
278
+ enumerable: true,
279
+ configurable: true,
280
+ writable: true,
281
+ value: void 0
282
+ });
283
+ Object.defineProperty(this, "js", {
284
+ enumerable: true,
285
+ configurable: true,
286
+ writable: true,
287
+ value: void 0
288
+ });
289
+ Object.defineProperty(this, "auth", {
290
+ enumerable: true,
291
+ configurable: true,
292
+ writable: true,
293
+ value: void 0
294
+ });
295
+ Object.defineProperty(this, "api", {
296
+ enumerable: true,
297
+ configurable: true,
298
+ writable: true,
299
+ value: void 0
300
+ });
301
+ _Trellis_log.set(this, void 0);
302
+ _Trellis_tasks.set(this, void 0);
303
+ _Trellis_hasExplicitApi.set(this, void 0);
304
+ _Trellis_noResponderMaxRetries.set(this, void 0);
305
+ _Trellis_noResponderRetryMs.set(this, void 0);
306
+ _Trellis_authBypassMethods.set(this, void 0);
307
+ _Trellis_operationStore.set(this, void 0);
308
+ const api = opts?.api;
309
+ this.name = name;
310
+ this.nats = nats;
311
+ this.js = (0, jetstream_1.jetstream)(this.nats);
312
+ this.auth = auth;
313
+ this.api = (api ?? EMPTY_TRELLIS_API);
314
+ __classPrivateFieldSet(this, _Trellis_log, (opts?.log ?? globals_js_1.logger).child({ lib: "trellis" }), "f");
315
+ this.timeout = opts?.timeout ?? 3000;
316
+ this.stream = opts?.stream ?? "trellis";
317
+ __classPrivateFieldSet(this, _Trellis_hasExplicitApi, api !== undefined, "f");
318
+ __classPrivateFieldSet(this, _Trellis_noResponderMaxRetries, opts?.noResponderRetry?.maxAttempts ??
319
+ DEFAULT_NO_RESPONDER_MAX_RETRIES, "f");
320
+ __classPrivateFieldSet(this, _Trellis_noResponderRetryMs, opts?.noResponderRetry?.baseDelayMs ??
321
+ DEFAULT_NO_RESPONDER_RETRY_MS, "f");
322
+ __classPrivateFieldSet(this, _Trellis_authBypassMethods, new Set(opts?.authBypassMethods ?? []), "f");
323
+ __classPrivateFieldSet(this, _Trellis_tasks, new tasks_js_1.TrellisTasks({ log: __classPrivateFieldGet(this, _Trellis_log, "f") }), "f");
324
+ }
325
+ /**
326
+ * Returns the underlying NATS connection.
327
+ */
328
+ get natsConnection() {
329
+ return this.nats;
330
+ }
331
+ async operationStoreHandle() {
332
+ if (!__classPrivateFieldGet(this, _Trellis_operationStore, "f")) {
333
+ const bucket = `trellis_operations_${this.auth.sessionKey.slice(0, 16)}`;
334
+ __classPrivateFieldSet(this, _Trellis_operationStore, (async () => {
335
+ const result = await kv_js_1.TypedKV.open(this.nats, bucket, exports.DurableOperationRecordSchema, {
336
+ history: 5,
337
+ ttl: 0,
338
+ });
339
+ const value = result.take();
340
+ if ((0, result_1.isErr)(value)) {
341
+ throw value.error;
342
+ }
343
+ return value;
344
+ })(), "f");
345
+ }
346
+ return __classPrivateFieldGet(this, _Trellis_operationStore, "f");
347
+ }
348
+ async loadOperationRecord(operationId) {
349
+ const store = await this.operationStoreHandle();
350
+ const entry = await store.get(operationId);
351
+ const value = entry.take();
352
+ if ((0, result_1.isErr)(value)) {
353
+ return null;
354
+ }
355
+ return value.value;
356
+ }
357
+ async saveOperationRecord(runtime) {
358
+ const store = await this.operationStoreHandle();
359
+ const record = {
360
+ ownerSessionKey: runtime.ownerSessionKey,
361
+ sequence: runtime.sequence,
362
+ snapshot: runtime.snapshot,
363
+ };
364
+ await store.put(runtime.id, record);
365
+ }
366
+ /**
367
+ * Makes an authenticated request to a Trellis RPC method.
368
+ *
369
+ * @template M The specific RPC method being called.
370
+ * @param method The name of the RPC method to call.
371
+ * @param input The input data for the method, conforming to its schema.
372
+ * @param opts Optional request-specific options.
373
+ * @returns A promise that resolves with a `Result` containing either the method's
374
+ * output or an error.
375
+ * @returns A `Result` object:
376
+ * ok: A validated reponse of method M
377
+ * err: declared RPC errors | RemoteError | ValidationError | UnexpectedError
378
+ */
379
+ async request(method, input, opts) {
380
+ __classPrivateFieldGet(this, _Trellis_log, "f").trace({ method: String(method) }, `Calling ${method.toString()}.`);
381
+ const methodName = method;
382
+ const ctx = this.api["rpc"][methodName];
383
+ if (!ctx) {
384
+ return (0, result_1.err)(new index_js_1.UnexpectedError({
385
+ cause: __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "RPC method", method.toString()),
386
+ context: { method: method.toString() },
387
+ }));
388
+ }
389
+ const msg = encodeRuntimeSchema(ctx.input, input).take();
390
+ if ((0, result_1.isErr)(msg)) {
391
+ return msg;
392
+ }
393
+ const subject = this.template(ctx.subject, input).take();
394
+ if ((0, result_1.isErr)(subject)) {
395
+ return subject;
396
+ }
397
+ // Start a client span for this RPC request
398
+ const span = (0, tracing_js_1.startClientSpan)(method, subject);
399
+ const attempt = async () => {
400
+ const proof = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_createProof).call(this, subject, msg);
401
+ const headers = (0, nats_core_1.headers)();
402
+ headers.set("session-key", this.auth.sessionKey);
403
+ headers.set("proof", proof);
404
+ // Inject trace context into NATS headers for propagation
405
+ (0, tracing_js_1.injectTraceContext)((0, tracing_js_1.createNatsHeaderCarrier)(headers), span);
406
+ // Attempt request with retry for transient "no responders" errors
407
+ const requestWithRetry = async () => {
408
+ for (let retry = 0; retry <= __classPrivateFieldGet(this, _Trellis_noResponderMaxRetries, "f"); retry++) {
409
+ const result = await result_1.AsyncResult.try(() => this.nats.request(subject, msg, {
410
+ headers,
411
+ timeout: opts?.timeout ?? this.timeout,
412
+ }));
413
+ if (result.isOk()) {
414
+ return (0, result_1.ok)((await result).take());
415
+ }
416
+ const cause = result.error.cause;
417
+ const message = cause instanceof Error
418
+ ? cause.message
419
+ : String(cause);
420
+ const isNoResponders = message.includes("no responders");
421
+ // If it's a no-responders error and we have retries left, retry
422
+ if (isNoResponders && retry < __classPrivateFieldGet(this, _Trellis_noResponderMaxRetries, "f")) {
423
+ __classPrivateFieldGet(this, _Trellis_log, "f").debug({ method, subject, retry }, "No responders, retrying...");
424
+ await new Promise((r) => setTimeout(r, __classPrivateFieldGet(this, _Trellis_noResponderRetryMs, "f") * (retry + 1)));
425
+ continue;
426
+ }
427
+ // Final attempt failed or non-retryable error
428
+ __classPrivateFieldGet(this, _Trellis_log, "f").warn({ method, subject, error: message }, "NATS request failed");
429
+ const isNatsPermission = message.includes("Permissions Violation");
430
+ const reason = isNatsPermission
431
+ ? `Permission denied. You need one of these capabilities: ${ctx.callerCapabilities.join(", ")}`
432
+ : message;
433
+ return (0, result_1.err)(new index_js_1.UnexpectedError({
434
+ cause,
435
+ context: {
436
+ method,
437
+ subject,
438
+ reason,
439
+ requiredCapabilities: ctx.callerCapabilities,
440
+ noResponders: isNoResponders,
441
+ },
442
+ }));
443
+ }
444
+ // Should be unreachable, but TypeScript needs explicit return
445
+ return (0, result_1.err)(new index_js_1.UnexpectedError({
446
+ context: { method, subject, reason: "retry loop exhausted" },
447
+ }));
448
+ };
449
+ const msgResult = await requestWithRetry();
450
+ const m = msgResult.take();
451
+ if ((0, result_1.isErr)(m)) {
452
+ return m;
453
+ }
454
+ if (m.headers?.get("status") === "error") {
455
+ const json = safeJson(m).take();
456
+ if ((0, result_1.isErr)(json)) {
457
+ return json;
458
+ }
459
+ const errorData = (0, codec_js_1.parse)(TrellisError_js_1.TrellisErrorDataSchema, json).take();
460
+ if ((0, result_1.isErr)(errorData)) {
461
+ return errorData;
462
+ }
463
+ const declaredErrorTypes = Array.isArray(ctx.declaredErrorTypes)
464
+ ? ctx.declaredErrorTypes.filter((value) => typeof value === "string")
465
+ : ctx.errors;
466
+ const runtimeErrors = Array.isArray(ctx.runtimeErrors)
467
+ ? ctx.runtimeErrors.filter(isRuntimeRpcErrorDesc)
468
+ : undefined;
469
+ const reconstructed = reconstructDeclaredRpcError(declaredErrorTypes, runtimeErrors, errorData, json);
470
+ if (reconstructed) {
471
+ return (0, result_1.err)(reconstructed);
472
+ }
473
+ return (0, result_1.err)(new RemoteError_js_1.RemoteError({ error: errorData }));
474
+ }
475
+ const json = safeJson(m).take();
476
+ if ((0, result_1.isErr)(json)) {
477
+ return json;
478
+ }
479
+ const outputResult = parseRuntimeSchema(ctx.output, json).take();
480
+ if ((0, result_1.isErr)(outputResult)) {
481
+ return (0, result_1.err)(outputResult.error);
482
+ }
483
+ return (0, result_1.ok)(outputResult);
484
+ };
485
+ return (0, tracing_js_1.withSpanAsync)(span, async () => {
486
+ try {
487
+ const result = await attempt();
488
+ const value = result.take();
489
+ if ((0, result_1.isErr)(value)) {
490
+ span.setStatus({
491
+ code: tracing_js_1.SpanStatusCode.ERROR,
492
+ message: value.error.message,
493
+ });
494
+ }
495
+ else {
496
+ span.setStatus({ code: tracing_js_1.SpanStatusCode.OK });
497
+ }
498
+ return result;
499
+ }
500
+ catch (cause) {
501
+ const unexpected = new index_js_1.UnexpectedError({ cause });
502
+ span.setStatus({
503
+ code: tracing_js_1.SpanStatusCode.ERROR,
504
+ message: unexpected.message,
505
+ });
506
+ span.recordException(unexpected);
507
+ return (0, result_1.err)(unexpected);
508
+ }
509
+ finally {
510
+ span.end();
511
+ }
512
+ });
513
+ }
514
+ async requestOrThrow(method, input, opts) {
515
+ const result = await this.request(method, input, opts);
516
+ const value = result.take();
517
+ if ((0, result_1.isErr)(value)) {
518
+ throw value.error;
519
+ }
520
+ return value;
521
+ }
522
+ operation(operation) {
523
+ const descriptor = this.api["operations"]?.[operation];
524
+ if (!descriptor) {
525
+ throw __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "operation", operation.toString());
526
+ }
527
+ const transport = {
528
+ requestJson: (subject, body) => __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_requestJson).call(this, subject, body),
529
+ watchJson: (subject, body) => __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_watchJson).call(this, subject, body),
530
+ putTransfer: async (grant, body) => {
531
+ const handle = (0, transfer_js_1.createTransferHandle)(this.nats, this.auth, this.timeout, grant);
532
+ if (!(handle instanceof Object) || !("put" in handle)) {
533
+ return (0, result_1.err)(new index_js_1.TransferError({
534
+ operation: "transfer",
535
+ context: { reason: "invalid_operation_transfer_grant" },
536
+ }));
537
+ }
538
+ return await handle.put(body);
539
+ },
540
+ };
541
+ return new operations_js_1.OperationInvoker(transport, descriptor);
542
+ }
543
+ /*
544
+ * Mount a handler to process requests made to a specific Trellis API
545
+ */
546
+ async mount(method, fn) {
547
+ const methodName = method;
548
+ const ctx = this.api["rpc"][methodName];
549
+ if (!ctx) {
550
+ throw __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "RPC method", method.toString());
551
+ }
552
+ const task = __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_handleRPC).call(this, methodName, fn);
553
+ __classPrivateFieldGet(this, _Trellis_tasks, "f").add(methodName, task);
554
+ }
555
+ respondWithError(msg, error) {
556
+ __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_respondWithError).call(this, msg, error);
557
+ }
558
+ async publish(event, data) {
559
+ const eventName = event;
560
+ const ctx = this.api["events"][eventName];
561
+ if (!ctx) {
562
+ return (0, result_1.err)(new index_js_1.UnexpectedError({
563
+ cause: __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "event", event.toString()),
564
+ context: { event: event.toString() },
565
+ }));
566
+ }
567
+ const subject = this.template(ctx.subject, data).take();
568
+ if ((0, result_1.isErr)(subject)) {
569
+ globals_js_1.logger.error({ err: subject.error }, "Failed to template event.");
570
+ return subject;
571
+ }
572
+ const payload = {
573
+ ...data,
574
+ header: {
575
+ id: (0, ulid_1.ulid)(),
576
+ time: new Date().toISOString(),
577
+ },
578
+ };
579
+ const msg = (0, codec_js_1.encodeSchema)(ctx.event, payload).take();
580
+ if ((0, result_1.isErr)(msg)) {
581
+ globals_js_1.logger.error({ err: msg.error }, "Failed to encode event.");
582
+ return (0, result_1.err)(new index_js_1.UnexpectedError({ cause: msg.error }));
583
+ }
584
+ globals_js_1.logger.trace({ subject }, `Publishing ${event.toString()} event.`);
585
+ await this.js.publish(subject, msg);
586
+ return (0, result_1.ok)(undefined);
587
+ }
588
+ async event(event, subjectData, fn, opts) {
589
+ const eventName = event;
590
+ const ctx = this.api["events"][eventName];
591
+ if (!ctx) {
592
+ return (0, result_1.err)(new index_js_1.UnexpectedError({
593
+ cause: __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "event", event.toString()),
594
+ context: { event: event.toString() },
595
+ }));
596
+ }
597
+ const subject = this.template(ctx.subject, subjectData, true).take();
598
+ if ((0, result_1.isErr)(subject))
599
+ return subject;
600
+ if (opts?.mode === "ephemeral") {
601
+ return __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_startEphemeralEvent).call(this, eventName, ctx, subject, fn, opts.signal);
602
+ }
603
+ const jsm = await (0, jetstream_1.jetstreamManager)(this.nats);
604
+ const consumerName = opts?.durableName ??
605
+ `${this.name}-${event.replaceAll(".", "_")}`;
606
+ const addResult = await result_1.AsyncResult.try(() => jsm.consumers.add(this.stream, {
607
+ durable_name: consumerName,
608
+ ack_policy: "explicit",
609
+ deliver_policy: opts?.replay === "new" ? "new" : "all",
610
+ filter_subjects: [subject],
611
+ }));
612
+ // If add failed (consumer already exists), try to get existing consumer info
613
+ const consumerInfoResult = addResult.isOk()
614
+ ? addResult
615
+ : await result_1.AsyncResult.try(() => jsm.consumers.info(this.stream, consumerName));
616
+ const info = consumerInfoResult.take();
617
+ if ((0, result_1.isErr)(info))
618
+ return info;
619
+ const consumer = this.js.consumers.getConsumerFromInfo(info);
620
+ const messages = await consumer.consume();
621
+ if (opts?.signal) {
622
+ if (opts.signal.aborted) {
623
+ messages.stop();
624
+ }
625
+ else {
626
+ opts.signal.addEventListener("abort", () => messages.stop(), {
627
+ once: true,
628
+ });
629
+ }
630
+ }
631
+ __classPrivateFieldGet(this, _Trellis_tasks, "f").add(`event:${eventName}:${(0, ulid_1.ulid)()}`, __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_handleDurableEvent).call(this, eventName, ctx, messages, fn));
632
+ return (0, result_1.ok)(undefined);
633
+ }
634
+ wait() {
635
+ return __classPrivateFieldGet(this, _Trellis_tasks, "f").wait();
636
+ }
637
+ // FIXME: If are validating things twice in most cases...
638
+ template(subject, data, allowWildcards = false) {
639
+ // Find all template placeholders and check if values exist
640
+ const placeholders = subject.match(/\{([^}]+)\}/g) || [];
641
+ for (const placeholder of placeholders) {
642
+ const key = placeholder.slice(1, -1); // Remove { and }
643
+ const value = value_1.Pointer.Get(data, key);
644
+ if ((value === undefined || value === null) && !allowWildcards) {
645
+ return (0, result_1.err)(new index_js_1.ValidationError({
646
+ errors: [
647
+ {
648
+ path: key,
649
+ message: "Missing required data for subject template",
650
+ },
651
+ ],
652
+ context: { key },
653
+ }));
654
+ }
655
+ }
656
+ const result = subject.replace(/\{([^}]+)\}/g, (_, key) => {
657
+ const value = value_1.Pointer.Get(data, key);
658
+ if (allowWildcards && value === "*") {
659
+ return "*";
660
+ }
661
+ if (allowWildcards && (value === undefined || value === null)) {
662
+ return "*";
663
+ }
664
+ return __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_escapeSubjectToken).call(this, `${value}`);
665
+ });
666
+ return (0, result_1.ok)(result);
667
+ }
668
+ async requestAuthValidate(input) {
669
+ const request = this.request.bind(this);
670
+ const result = await request("Auth.ValidateRequest", input);
671
+ return result;
672
+ }
673
+ }
674
+ exports.Trellis = Trellis;
675
+ _Trellis_log = new WeakMap(), _Trellis_tasks = new WeakMap(), _Trellis_hasExplicitApi = new WeakMap(), _Trellis_noResponderMaxRetries = new WeakMap(), _Trellis_noResponderRetryMs = new WeakMap(), _Trellis_authBypassMethods = new WeakMap(), _Trellis_operationStore = new WeakMap(), _Trellis_instances = new WeakSet(), _Trellis_unknownApiError = function _Trellis_unknownApiError(kind, name) {
676
+ const base = `Unknown ${kind} '${name}'.`;
677
+ if (__classPrivateFieldGet(this, _Trellis_hasExplicitApi, "f")) {
678
+ return new Error(`${base} Did you forget to include its API module?`);
679
+ }
680
+ return new Error(`${base} No API surface was provided. Pass opts.api, use createClient(contract, ...), or await createCoreClient(...) instead.`);
681
+ }, _Trellis_handleRPC = function _Trellis_handleRPC(method, fn, subjectData = {}) {
682
+ // Get API details
683
+ const ctx = this.api["rpc"][method];
684
+ const subject = this.template(ctx.subject, subjectData, true).take();
685
+ if ((0, result_1.isErr)(subject)) {
686
+ return result_1.AsyncResult.lift(subject);
687
+ }
688
+ const handlerTrellis = this;
689
+ __classPrivateFieldGet(this, _Trellis_log, "f").info({ method: String(method) }, `Mounting ${method.toString()} RPC handler`);
690
+ const sub = this.nats.subscribe(subject);
691
+ return result_1.AsyncResult.try(async () => {
692
+ for await (const msg of sub) {
693
+ const resultPromise = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_processRPCMessage).call(this, method, ctx, msg, fn, handlerTrellis);
694
+ const result = resultPromise.take();
695
+ if ((0, result_1.isErr)(result)) {
696
+ __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_respondWithError).call(this, msg, result.error);
697
+ continue;
698
+ }
699
+ msg.respond(result);
700
+ }
701
+ });
702
+ }, _Trellis_processRPCMessage = async function _Trellis_processRPCMessage(method, ctx, msg, fn, handlerTrellis) {
703
+ __classPrivateFieldGet(this, _Trellis_log, "f").debug({ method: String(method), subject: msg.subject }, "Processing RPC message");
704
+ // Extract trace context from incoming NATS headers
705
+ const parentContext = (0, tracing_js_1.extractTraceContext)((0, tracing_js_1.createNatsHeaderCarrier)({
706
+ get: (k) => msg.headers?.get(k) ?? undefined,
707
+ set: () => { }, // Server doesn't need to set headers on incoming messages
708
+ }));
709
+ // Start a server span for this RPC handler
710
+ const span = (0, tracing_js_1.startServerSpan)(method, msg.subject, parentContext);
711
+ // Execute the handler within the span's context
712
+ return (0, tracing_js_1.withSpanAsync)(span, async () => {
713
+ const execute = async () => {
714
+ const jsonData = safeJson(msg).take();
715
+ if ((0, result_1.isErr)(jsonData)) {
716
+ __classPrivateFieldGet(this, _Trellis_log, "f").warn({ method, error: jsonData.error.message }, "Failed to parse JSON");
717
+ span.setStatus({
718
+ code: tracing_js_1.SpanStatusCode.ERROR,
719
+ message: "Failed to parse JSON",
720
+ });
721
+ return jsonData;
722
+ }
723
+ const parsedInput = parseRuntimeSchema(ctx.input, jsonData).take();
724
+ if ((0, result_1.isErr)(parsedInput)) {
725
+ span.setStatus({
726
+ code: tracing_js_1.SpanStatusCode.ERROR,
727
+ message: "Input validation failed",
728
+ });
729
+ return parsedInput;
730
+ }
731
+ let caller;
732
+ const callerSessionKey = msg.headers?.get("session-key") ?? "";
733
+ const authRequired = ctx.authRequired ?? true;
734
+ if (!authRequired || __classPrivateFieldGet(this, _Trellis_authBypassMethods, "f").has(method)) {
735
+ caller = {
736
+ type: "service",
737
+ id: "system",
738
+ active: true,
739
+ name: "System",
740
+ capabilities: ["service"],
741
+ };
742
+ }
743
+ else {
744
+ const sessionKey = msg.headers?.get("session-key");
745
+ const proof = msg.headers?.get("proof");
746
+ if (!sessionKey) {
747
+ __classPrivateFieldGet(this, _Trellis_log, "f").warn({ method }, "Missing session-key header");
748
+ span.setStatus({
749
+ code: tracing_js_1.SpanStatusCode.ERROR,
750
+ message: "Missing session-key",
751
+ });
752
+ return (0, result_1.err)(new index_js_1.AuthError({ reason: "missing_session_key" }));
753
+ }
754
+ if (!proof) {
755
+ __classPrivateFieldGet(this, _Trellis_log, "f").warn({ method }, "Missing proof in request");
756
+ span.setStatus({
757
+ code: tracing_js_1.SpanStatusCode.ERROR,
758
+ message: "Missing proof",
759
+ });
760
+ return (0, result_1.err)(new index_js_1.AuthError({ reason: "missing_proof" }));
761
+ }
762
+ // Verify proof signature locally using the raw request bytes we received.
763
+ const payloadBytes = msg.data ?? new Uint8Array();
764
+ const payloadHash = await sha256(payloadBytes);
765
+ const proofInput = buildProofInput(sessionKey, msg.subject, payloadHash);
766
+ const digest = await sha256(proofInput);
767
+ const verifyResult = await result_1.AsyncResult.try(async () => {
768
+ const publicKeyRaw = base64urlDecode(sessionKey);
769
+ const pub = await crypto.subtle.importKey("raw", toArrayBuffer(publicKeyRaw), { name: "Ed25519" }, true, ["verify"]);
770
+ return crypto.subtle.verify({ name: "Ed25519" }, pub, toArrayBuffer(base64urlDecode(proof)), toArrayBuffer(digest));
771
+ });
772
+ const signatureOk = verifyResult.isOk() &&
773
+ (await verifyResult).take() === true;
774
+ if (!signatureOk) {
775
+ span.setStatus({
776
+ code: tracing_js_1.SpanStatusCode.ERROR,
777
+ message: "Invalid signature",
778
+ });
779
+ return (0, result_1.err)(new index_js_1.AuthError({
780
+ reason: "invalid_signature",
781
+ context: { sessionKey },
782
+ }));
783
+ }
784
+ let auth;
785
+ for (let attempt = 0; attempt < DEFAULT_AUTH_VALIDATE_SESSION_RETRY_ATTEMPTS; attempt++) {
786
+ const authResult = await this.requestAuthValidate({
787
+ sessionKey,
788
+ proof,
789
+ subject: msg.subject,
790
+ payloadHash: base64urlEncode(payloadHash),
791
+ capabilities: [...ctx.callerCapabilities],
792
+ });
793
+ const authValue = authResult.take();
794
+ if (!(0, result_1.isErr)(authValue)) {
795
+ auth = authValue;
796
+ break;
797
+ }
798
+ const authError = authValue.error;
799
+ if (!isTransientAuthValidateSessionError(authError) ||
800
+ attempt === DEFAULT_AUTH_VALIDATE_SESSION_RETRY_ATTEMPTS - 1) {
801
+ auth = authError;
802
+ break;
803
+ }
804
+ await sleep(DEFAULT_AUTH_VALIDATE_SESSION_RETRY_MS * (attempt + 1));
805
+ }
806
+ if (!auth) {
807
+ return (0, result_1.err)(new index_js_1.UnexpectedError({
808
+ context: { reason: "missing_auth_validate_result" },
809
+ }));
810
+ }
811
+ if (auth instanceof Error) {
812
+ __classPrivateFieldGet(this, _Trellis_log, "f").warn({
813
+ method,
814
+ error: auth.message,
815
+ errorType: auth.name,
816
+ remoteError: auth instanceof RemoteError_js_1.RemoteError
817
+ ? auth.toSerializable()
818
+ : undefined,
819
+ }, "Auth.ValidateRequest failed");
820
+ span.setStatus({
821
+ code: tracing_js_1.SpanStatusCode.ERROR,
822
+ message: "Auth.ValidateRequest failed",
823
+ });
824
+ if (auth instanceof result_1.BaseError) {
825
+ return (0, result_1.err)(auth);
826
+ }
827
+ return (0, result_1.err)(new index_js_1.UnexpectedError({ cause: auth }));
828
+ }
829
+ if (!auth.allowed) {
830
+ span.setStatus({
831
+ code: tracing_js_1.SpanStatusCode.ERROR,
832
+ message: "Insufficient permissions",
833
+ });
834
+ return (0, result_1.err)(new index_js_1.AuthError({
835
+ reason: "insufficient_permissions",
836
+ context: {
837
+ requiredCapabilities: ctx.callerCapabilities,
838
+ userCapabilities: auth.caller.capabilities,
839
+ },
840
+ }));
841
+ }
842
+ if (typeof msg.reply !== "string" ||
843
+ !msg.reply.startsWith(`${auth.inboxPrefix}.`)) {
844
+ span.setStatus({
845
+ code: tracing_js_1.SpanStatusCode.ERROR,
846
+ message: "Reply subject mismatch",
847
+ });
848
+ return (0, result_1.err)(new index_js_1.AuthError({
849
+ reason: "reply_subject_mismatch",
850
+ context: { expected: auth.inboxPrefix, actual: msg.reply },
851
+ }));
852
+ }
853
+ caller = auth.caller;
854
+ }
855
+ span.setAttribute("auth.caller.type", caller.type);
856
+ if (caller.type === "user") {
857
+ span.setAttribute("user.id", caller.id);
858
+ span.setAttribute("user.origin", caller.origin);
859
+ }
860
+ if (caller.type === "service") {
861
+ span.setAttribute("service.id", caller.id);
862
+ }
863
+ if (caller.type === "device") {
864
+ span.setAttribute("device.id", caller.deviceId);
865
+ span.setAttribute("device.profile_id", caller.profileId);
866
+ }
867
+ const invokeHandler = fn;
868
+ const handlerResultWrapped = await result_1.AsyncResult.try(async () => await Promise.resolve(invokeHandler(parsedInput, {
869
+ caller,
870
+ sessionKey: callerSessionKey,
871
+ }, handlerTrellis)));
872
+ if (handlerResultWrapped.isErr()) {
873
+ const error = handlerResultWrapped.error.withContext({ method });
874
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({
875
+ method,
876
+ error: error.message,
877
+ cause: error.cause instanceof Error
878
+ ? { message: error.cause.message, stack: error.cause.stack }
879
+ : error.cause,
880
+ }, "Handler threw unexpectedly.");
881
+ span.setStatus({
882
+ code: tracing_js_1.SpanStatusCode.ERROR,
883
+ message: error.message,
884
+ });
885
+ span.recordException(error);
886
+ return (0, result_1.err)(error);
887
+ }
888
+ const handlerResult = (await handlerResultWrapped).take();
889
+ const handlerOutcome = handlerResult.take();
890
+ if ((0, result_1.isErr)(handlerOutcome)) {
891
+ const handlerError = handlerOutcome.error;
892
+ const error = handlerError instanceof result_1.BaseError &&
893
+ !(handlerError instanceof RemoteError_js_1.RemoteError)
894
+ ? handlerError
895
+ : new index_js_1.UnexpectedError({ cause: handlerError });
896
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({
897
+ method,
898
+ error: error.message,
899
+ errorType: error.name,
900
+ cause: error.cause instanceof Error
901
+ ? { message: error.cause.message, stack: error.cause.stack }
902
+ : error.cause,
903
+ }, "Handler returned error.");
904
+ span.setStatus({
905
+ code: tracing_js_1.SpanStatusCode.ERROR,
906
+ message: error.message,
907
+ });
908
+ return (0, result_1.err)(error);
909
+ }
910
+ const encoded = (0, codec_js_1.encodeSchema)(ctx.output, handlerOutcome).take();
911
+ if ((0, result_1.isErr)(encoded)) {
912
+ span.setStatus({
913
+ code: tracing_js_1.SpanStatusCode.ERROR,
914
+ message: "Output encoding failed",
915
+ });
916
+ return encoded;
917
+ }
918
+ span.setStatus({ code: tracing_js_1.SpanStatusCode.OK });
919
+ return (0, result_1.ok)(encoded);
920
+ };
921
+ const result = await execute();
922
+ span.end();
923
+ return result;
924
+ });
925
+ }, _Trellis_respondWithError = function _Trellis_respondWithError(msg, error) {
926
+ const trellisError = error instanceof result_1.BaseError &&
927
+ !(error instanceof RemoteError_js_1.RemoteError)
928
+ ? error
929
+ : new index_js_1.UnexpectedError({ cause: error });
930
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({ error: trellisError.toSerializable() }, "RPC error");
931
+ const errorData = trellisError.toSerializable();
932
+ const hdrs = (0, nats_core_1.headers)();
933
+ hdrs.set("status", "error");
934
+ const serialized = result_1.Result.try(() => JSON.stringify(errorData));
935
+ if (serialized.isErr()) {
936
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({ error: serialized.error }, "Failed to serialize error response");
937
+ msg.respond('{"type":"UnexpectedError","message":"Failed to serialize error"}', { headers: hdrs });
938
+ return;
939
+ }
940
+ msg.respond(serialized.take(), { headers: hdrs });
941
+ }, _Trellis_startEphemeralEvent = function _Trellis_startEphemeralEvent(event, ctx, subject, fn, signal) {
942
+ const sub = this.nats.subscribe(subject);
943
+ if (signal) {
944
+ if (signal.aborted) {
945
+ sub.unsubscribe();
946
+ return (0, result_1.ok)(undefined);
947
+ }
948
+ signal.addEventListener("abort", () => sub.unsubscribe(), { once: true });
949
+ }
950
+ const task = result_1.AsyncResult.try(async () => {
951
+ for await (const msg of sub) {
952
+ const parsedEvent = __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_parseEventMessage).call(this, event, ctx, msg);
953
+ const m = parsedEvent.take();
954
+ if ((0, result_1.isErr)(m)) {
955
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({ error: m.error }, "Event validation failed");
956
+ continue;
957
+ }
958
+ const handlerResult = await result_1.AsyncResult.lift(fn(m));
959
+ if (handlerResult.isErr()) {
960
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({
961
+ error: handlerResult.error.toSerializable(),
962
+ event,
963
+ subject: msg.subject,
964
+ }, "Event handler failed");
965
+ }
966
+ }
967
+ });
968
+ __classPrivateFieldGet(this, _Trellis_tasks, "f").add(`event:${event}:${(0, ulid_1.ulid)()}`, task);
969
+ return (0, result_1.ok)(undefined);
970
+ }, _Trellis_handleDurableEvent = function _Trellis_handleDurableEvent(event, ctx, messages, fn) {
971
+ return result_1.AsyncResult.try(async () => {
972
+ for await (const msg of messages) {
973
+ const parsedEvent = __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_parseEventMessage).call(this, event, ctx, msg);
974
+ const m = parsedEvent.take();
975
+ if ((0, result_1.isErr)(m)) {
976
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({ error: m.error }, "Event validation failed");
977
+ msg.term();
978
+ continue;
979
+ }
980
+ const handlerResult = await result_1.AsyncResult.lift(fn(m));
981
+ if (handlerResult.isErr()) {
982
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({
983
+ error: handlerResult.error.toSerializable(),
984
+ event,
985
+ subject: msg.subject,
986
+ }, "Event handler failed");
987
+ msg.nak();
988
+ continue;
989
+ }
990
+ msg.ack();
991
+ }
992
+ });
993
+ }, _Trellis_parseEventMessage = function _Trellis_parseEventMessage(event, ctx, msg) {
994
+ const jsonData = result_1.Result.try(() => msg.json());
995
+ const json = jsonData.take();
996
+ if ((0, result_1.isErr)(json)) {
997
+ __classPrivateFieldGet(this, _Trellis_log, "f").error({ error: json.error, event, subject: msg.subject }, "Event parse failed");
998
+ return json;
999
+ }
1000
+ return parseRuntimeSchema(ctx.event, json);
1001
+ }, _Trellis_escapeSubjectToken = function _Trellis_escapeSubjectToken(token) {
1002
+ const out = token.replace(NATS_SUBJECT_TOKEN_FORBIDDEN, (ch) => `~${ch.codePointAt(0).toString(16).toUpperCase()}~`);
1003
+ // Protect stapRet with $ due to NATS internal use of it
1004
+ if (out.length === 0 || out.startsWith("$")) {
1005
+ return `_${out}`;
1006
+ }
1007
+ return out;
1008
+ }, _Trellis_createProof = async function _Trellis_createProof(subject, payload) {
1009
+ const payloadBytes = new TextEncoder().encode(payload);
1010
+ const payloadHash = await sha256(payloadBytes);
1011
+ const input = buildProofInput(this.auth.sessionKey, subject, payloadHash);
1012
+ const digest = await sha256(input);
1013
+ const sigBytes = await this.auth.sign(digest);
1014
+ return base64urlEncode(sigBytes);
1015
+ }, _Trellis_requestJson = async function _Trellis_requestJson(subject, body) {
1016
+ const payload = JSON.stringify(body);
1017
+ const proof = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_createProof).call(this, subject, payload);
1018
+ const headers = (0, nats_core_1.headers)();
1019
+ headers.set("session-key", this.auth.sessionKey);
1020
+ headers.set("proof", proof);
1021
+ const response = await result_1.AsyncResult.try(() => this.nats.request(subject, payload, {
1022
+ timeout: this.timeout,
1023
+ headers,
1024
+ })).take();
1025
+ if ((0, result_1.isErr)(response)) {
1026
+ return response;
1027
+ }
1028
+ return safeJson(response);
1029
+ }, _Trellis_watchJson = async function _Trellis_watchJson(subject, body) {
1030
+ const payload = JSON.stringify(body);
1031
+ const proof = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_createProof).call(this, subject, payload);
1032
+ const headers = (0, nats_core_1.headers)();
1033
+ headers.set("session-key", this.auth.sessionKey);
1034
+ headers.set("proof", proof);
1035
+ const inbox = (0, nats_core_1.createInbox)(`_INBOX.${this.auth.sessionKey.slice(0, 16)}`);
1036
+ const sub = this.nats.subscribe(inbox);
1037
+ try {
1038
+ this.nats.publish(subject, payload, {
1039
+ headers,
1040
+ reply: inbox,
1041
+ });
1042
+ await this.nats.flush();
1043
+ }
1044
+ catch (cause) {
1045
+ sub.unsubscribe();
1046
+ return (0, result_1.err)(new index_js_1.UnexpectedError({ cause }));
1047
+ }
1048
+ return (0, result_1.ok)((async function* () {
1049
+ try {
1050
+ for await (const msg of sub) {
1051
+ if (msg.headers?.get("status") === "error") {
1052
+ yield (0, result_1.err)(new index_js_1.UnexpectedError({ cause: new Error(msg.string()) }));
1053
+ continue;
1054
+ }
1055
+ yield safeJson(msg);
1056
+ }
1057
+ }
1058
+ finally {
1059
+ sub.unsubscribe();
1060
+ }
1061
+ })());
1062
+ };