@qlever-llc/trellis 0.10.2 → 0.10.3-rc.4

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 (1127) hide show
  1. package/esm/_dnt.polyfills.d.ts.map +1 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/auth/browser/login.d.ts +3 -3
  4. package/esm/auth/browser/login.d.ts.map +1 -1
  5. package/esm/auth/browser/portal.d.ts +5 -5
  6. package/esm/auth/browser/portal.d.ts.map +1 -1
  7. package/esm/auth/browser/session.d.ts.map +1 -1
  8. package/esm/auth/browser/storage.d.ts.map +1 -1
  9. package/esm/auth/browser.d.ts +8 -7
  10. package/esm/auth/browser.d.ts.map +1 -1
  11. package/esm/auth/browser.js +1 -0
  12. package/esm/auth/device_activation.d.ts +3 -3
  13. package/esm/auth/device_activation.d.ts.map +1 -1
  14. package/esm/auth/keys.d.ts.map +1 -1
  15. package/esm/auth/mod.d.ts +9 -9
  16. package/esm/auth/mod.d.ts.map +1 -1
  17. package/esm/auth/proof.d.ts.map +1 -1
  18. package/esm/auth/protocol.d.ts +245 -5
  19. package/esm/auth/protocol.d.ts.map +1 -1
  20. package/esm/auth/protocol.js +1 -1
  21. package/esm/auth/schemas.d.ts.map +1 -1
  22. package/esm/auth/session_auth.d.ts.map +1 -1
  23. package/esm/auth/time.d.ts.map +1 -1
  24. package/esm/auth/trellis_id.d.ts.map +1 -1
  25. package/esm/auth/types.d.ts +1 -1
  26. package/esm/auth/types.d.ts.map +1 -1
  27. package/esm/auth/utils.d.ts.map +1 -1
  28. package/esm/auth.d.ts +2 -1
  29. package/esm/auth.d.ts.map +1 -1
  30. package/esm/auth.js +1 -0
  31. package/esm/browser.d.ts.map +1 -0
  32. package/esm/client.d.ts +6 -6
  33. package/esm/client.d.ts.map +1 -1
  34. package/esm/client.js +1 -1
  35. package/esm/client_connect.d.ts +8 -8
  36. package/esm/client_connect.d.ts.map +1 -1
  37. package/esm/client_connect.js +4 -3
  38. package/esm/codec.d.ts +2 -2
  39. package/esm/codec.d.ts.map +1 -1
  40. package/esm/connection.d.ts +1 -1
  41. package/esm/connection.d.ts.map +1 -1
  42. package/esm/contract.d.ts +2 -2
  43. package/esm/contract.d.ts.map +1 -1
  44. package/esm/contract_support/canonical.d.ts.map +1 -1
  45. package/esm/contract_support/mod.d.ts +13 -13
  46. package/esm/contract_support/mod.d.ts.map +1 -1
  47. package/esm/contract_support/protocol.d.ts.map +1 -1
  48. package/esm/contract_support/runtime.d.ts +1 -1
  49. package/esm/contract_support/runtime.d.ts.map +1 -1
  50. package/esm/contract_support/schema_pointers.d.ts.map +1 -1
  51. package/esm/contracts.d.ts +4 -3
  52. package/esm/contracts.d.ts.map +1 -1
  53. package/esm/contracts.js +1 -0
  54. package/esm/device/deno.d.ts.map +1 -0
  55. package/esm/device.d.ts +9 -8
  56. package/esm/device.d.ts.map +1 -1
  57. package/esm/device.js +1 -0
  58. package/esm/env.d.ts.map +1 -0
  59. package/esm/errors/AuthError.d.ts +1 -1
  60. package/esm/errors/AuthError.d.ts.map +1 -1
  61. package/esm/errors/KVError.d.ts +1 -1
  62. package/esm/errors/KVError.d.ts.map +1 -1
  63. package/esm/errors/OperationLifecycleError.d.ts +1 -1
  64. package/esm/errors/OperationLifecycleError.d.ts.map +1 -1
  65. package/esm/errors/RemoteError.d.ts +10 -10
  66. package/esm/errors/RemoteError.d.ts.map +1 -1
  67. package/esm/errors/StoreError.d.ts +1 -1
  68. package/esm/errors/StoreError.d.ts.map +1 -1
  69. package/esm/errors/TransferError.d.ts +1 -1
  70. package/esm/errors/TransferError.d.ts.map +1 -1
  71. package/esm/errors/TransportError.d.ts +1 -1
  72. package/esm/errors/TransportError.d.ts.map +1 -1
  73. package/esm/errors/TrellisError.d.ts.map +1 -1
  74. package/esm/errors/ValidationError.d.ts +1 -1
  75. package/esm/errors/ValidationError.d.ts.map +1 -1
  76. package/esm/errors/index.d.ts +33 -32
  77. package/esm/errors/index.d.ts.map +1 -1
  78. package/esm/errors/index.js +1 -0
  79. package/esm/generate.d.ts.map +1 -0
  80. package/esm/{npm/src/generate.js → generate.js} +1 -0
  81. package/esm/generated-sdk/auth/api.d.ts +604 -3
  82. package/esm/generated-sdk/auth/api.d.ts.map +1 -1
  83. package/esm/generated-sdk/auth/api.js +4 -1
  84. package/esm/generated-sdk/auth/client.d.ts +8 -0
  85. package/esm/generated-sdk/auth/client.d.ts.map +1 -1
  86. package/esm/generated-sdk/auth/contract.d.ts +600 -2
  87. package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
  88. package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
  89. package/esm/generated-sdk/auth/owned_api.d.ts +601 -2
  90. package/esm/generated-sdk/auth/owned_api.d.ts.map +1 -1
  91. package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
  92. package/esm/generated-sdk/auth/types.d.ts.map +1 -1
  93. package/esm/generated-sdk/health/api.d.ts +14 -2
  94. package/esm/generated-sdk/health/api.d.ts.map +1 -1
  95. package/esm/generated-sdk/health/client.d.ts.map +1 -1
  96. package/esm/generated-sdk/health/contract.d.ts +14 -2
  97. package/esm/generated-sdk/health/contract.d.ts.map +1 -1
  98. package/esm/generated-sdk/health/mod.d.ts.map +1 -1
  99. package/esm/generated-sdk/health/owned_api.d.ts +15 -2
  100. package/esm/generated-sdk/health/owned_api.d.ts.map +1 -1
  101. package/esm/generated-sdk/health/schemas.d.ts.map +1 -1
  102. package/esm/generated-sdk/health/types.d.ts.map +1 -1
  103. package/esm/generated-sdk/jobs/api.d.ts +105 -2
  104. package/esm/generated-sdk/jobs/api.d.ts.map +1 -1
  105. package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
  106. package/esm/generated-sdk/jobs/contract.d.ts +105 -2
  107. package/esm/generated-sdk/jobs/contract.d.ts.map +1 -1
  108. package/esm/generated-sdk/jobs/mod.d.ts.map +1 -1
  109. package/esm/generated-sdk/jobs/owned_api.d.ts +106 -2
  110. package/esm/generated-sdk/jobs/owned_api.d.ts.map +1 -1
  111. package/esm/generated-sdk/jobs/schemas.d.ts.map +1 -1
  112. package/esm/generated-sdk/jobs/types.d.ts.map +1 -1
  113. package/esm/generated-sdk/state/api.d.ts +64 -2
  114. package/esm/generated-sdk/state/api.d.ts.map +1 -1
  115. package/esm/generated-sdk/state/client.d.ts.map +1 -1
  116. package/esm/generated-sdk/state/contract.d.ts +64 -2
  117. package/esm/generated-sdk/state/contract.d.ts.map +1 -1
  118. package/esm/generated-sdk/state/mod.d.ts.map +1 -1
  119. package/esm/generated-sdk/state/owned_api.d.ts +65 -2
  120. package/esm/generated-sdk/state/owned_api.d.ts.map +1 -1
  121. package/esm/generated-sdk/state/schemas.d.ts.map +1 -1
  122. package/esm/generated-sdk/state/types.d.ts.map +1 -1
  123. package/esm/generated-sdk/trellis-core/api.d.ts +44 -3
  124. package/esm/generated-sdk/trellis-core/api.d.ts.map +1 -1
  125. package/esm/generated-sdk/trellis-core/api.js +4 -1
  126. package/esm/generated-sdk/trellis-core/client.d.ts +14 -2
  127. package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
  128. package/esm/generated-sdk/trellis-core/contract.d.ts +40 -2
  129. package/esm/generated-sdk/trellis-core/contract.d.ts.map +1 -1
  130. package/esm/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  131. package/esm/generated-sdk/trellis-core/owned_api.d.ts +41 -2
  132. package/esm/generated-sdk/trellis-core/owned_api.d.ts.map +1 -1
  133. package/esm/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
  134. package/esm/generated-sdk/trellis-core/types.d.ts.map +1 -1
  135. package/esm/globals.d.ts.map +1 -1
  136. package/esm/health.d.ts +4 -3
  137. package/esm/health.d.ts.map +1 -1
  138. package/esm/health.js +1 -0
  139. package/esm/helpers.d.ts.map +1 -1
  140. package/esm/host/mod.d.ts.map +1 -0
  141. package/esm/host/node.d.ts.map +1 -0
  142. package/esm/index.d.ts +33 -32
  143. package/esm/index.d.ts.map +1 -1
  144. package/esm/index.js +1 -0
  145. package/esm/jobs.d.ts.map +1 -1
  146. package/esm/kv.d.ts +1 -1
  147. package/esm/kv.d.ts.map +1 -1
  148. package/esm/models/auth/rpc/Logout.d.ts.map +1 -1
  149. package/esm/models/trellis/Page.d.ts +1 -1
  150. package/esm/models/trellis/Page.d.ts.map +1 -1
  151. package/esm/models/trellis/State.d.ts +1 -1
  152. package/esm/models/trellis/State.d.ts.map +1 -1
  153. package/esm/models/trellis/TrellisError.d.ts.map +1 -1
  154. package/esm/models/trellis/rpc/StateDelete.d.ts.map +1 -1
  155. package/esm/models/trellis/rpc/StateGet.d.ts +1 -1
  156. package/esm/models/trellis/rpc/StateGet.d.ts.map +1 -1
  157. package/esm/models/trellis/rpc/StateList.d.ts.map +1 -1
  158. package/esm/models/trellis/rpc/StatePut.d.ts +1 -1
  159. package/esm/models/trellis/rpc/StatePut.d.ts.map +1 -1
  160. package/esm/operations.d.ts +4 -4
  161. package/esm/operations.d.ts.map +1 -1
  162. package/esm/runtime_transport.d.ts.map +1 -1
  163. package/esm/runtime_transport.js +2 -1
  164. package/esm/sdk/auth.d.ts +2 -0
  165. package/esm/sdk/auth.d.ts.map +1 -0
  166. package/esm/sdk/auth.js +1 -0
  167. package/esm/sdk/core.d.ts +2 -0
  168. package/esm/sdk/core.d.ts.map +1 -0
  169. package/esm/sdk/core.js +1 -0
  170. package/esm/sdk/health.d.ts +2 -0
  171. package/esm/sdk/health.d.ts.map +1 -0
  172. package/esm/sdk/health.js +1 -0
  173. package/esm/sdk/jobs.d.ts +2 -0
  174. package/esm/sdk/jobs.d.ts.map +1 -0
  175. package/esm/sdk/jobs.js +1 -0
  176. package/esm/sdk/state.d.ts +2 -0
  177. package/esm/sdk/state.d.ts.map +1 -0
  178. package/esm/sdk/state.js +1 -0
  179. package/esm/server/health.d.ts +2 -11
  180. package/esm/server/health.d.ts.map +1 -1
  181. package/esm/server/health.js +12 -11
  182. package/{script/npm/src → esm}/server/health_rpc.d.ts +1 -1
  183. package/esm/server/health_rpc.d.ts.map +1 -0
  184. package/esm/server/health_schemas.d.ts.map +1 -1
  185. package/esm/server/internal_jobs/active-job.d.ts.map +1 -0
  186. package/esm/server/internal_jobs/bindings.d.ts.map +1 -0
  187. package/esm/server/internal_jobs/cancellation-registry.d.ts.map +1 -0
  188. package/esm/server/internal_jobs/heartbeat.d.ts.map +1 -0
  189. package/esm/server/internal_jobs/job-manager.d.ts.map +1 -0
  190. package/esm/server/internal_jobs/projection.d.ts.map +1 -0
  191. package/esm/server/internal_jobs/runtime-worker.d.ts.map +1 -0
  192. package/esm/server/internal_jobs/types.d.ts.map +1 -0
  193. package/esm/server/runtime.d.ts.map +1 -0
  194. package/{script/npm/src → esm}/server/service.d.ts +4 -4
  195. package/esm/server/service.d.ts.map +1 -0
  196. package/esm/{npm/src/server → server}/service.js +3 -3
  197. package/esm/{npm/src/server → server}/subscription.d.ts +1 -1
  198. package/esm/server/subscription.d.ts.map +1 -0
  199. package/esm/server/transfer.d.ts.map +1 -0
  200. package/esm/server.d.ts.map +1 -0
  201. package/esm/server_logger.d.ts.map +1 -0
  202. package/esm/service/deno.d.ts.map +1 -0
  203. package/esm/service/mod.d.ts.map +1 -0
  204. package/esm/service/node.d.ts.map +1 -0
  205. package/esm/service/outbox_inbox.d.ts.map +1 -0
  206. package/esm/store.d.ts +2 -2
  207. package/esm/store.d.ts.map +1 -1
  208. package/esm/tasks.d.ts +1 -1
  209. package/esm/tasks.d.ts.map +1 -1
  210. package/esm/telemetry/carrier.d.ts.map +1 -1
  211. package/esm/telemetry/core.d.ts.map +1 -1
  212. package/esm/telemetry/env.d.ts.map +1 -1
  213. package/esm/telemetry/env.js +3 -2
  214. package/esm/telemetry/mod.d.ts +9 -9
  215. package/esm/telemetry/mod.d.ts.map +1 -1
  216. package/esm/telemetry/nats.d.ts +1 -1
  217. package/esm/telemetry/nats.d.ts.map +1 -1
  218. package/esm/telemetry/result.d.ts.map +1 -1
  219. package/esm/telemetry/trace.d.ts.map +1 -1
  220. package/esm/telemetry/trellis.d.ts +1 -1
  221. package/esm/telemetry/trellis.d.ts.map +1 -1
  222. package/esm/tracing.d.ts +3 -2
  223. package/esm/tracing.d.ts.map +1 -1
  224. package/esm/tracing.js +3 -0
  225. package/esm/transfer.d.ts +1 -1
  226. package/esm/transfer.d.ts.map +1 -1
  227. package/esm/trellis.d.ts +13 -13
  228. package/esm/trellis.d.ts.map +1 -1
  229. package/package.json +28 -28
  230. package/script/_dnt.polyfills.d.ts.map +1 -0
  231. package/script/_dnt.shims.d.ts.map +1 -0
  232. package/script/auth/browser/login.d.ts +3 -3
  233. package/script/auth/browser/login.d.ts.map +1 -1
  234. package/script/auth/browser/login.js +12 -12
  235. package/script/auth/browser/portal.d.ts +5 -5
  236. package/script/auth/browser/portal.d.ts.map +1 -1
  237. package/script/auth/browser/portal.js +3 -3
  238. package/script/auth/browser/session.d.ts.map +1 -1
  239. package/script/auth/browser/session.js +21 -21
  240. package/script/auth/browser/storage.d.ts.map +1 -1
  241. package/script/auth/browser.d.ts +8 -7
  242. package/script/auth/browser.d.ts.map +1 -1
  243. package/script/auth/browser.js +47 -46
  244. package/script/auth/device_activation.d.ts +3 -3
  245. package/script/auth/device_activation.d.ts.map +1 -1
  246. package/script/auth/device_activation.js +36 -36
  247. package/script/auth/keys.d.ts.map +1 -1
  248. package/script/auth/keys.js +6 -6
  249. package/script/auth/mod.d.ts +9 -9
  250. package/script/auth/mod.d.ts.map +1 -1
  251. package/script/auth/mod.js +232 -232
  252. package/script/auth/proof.d.ts.map +1 -1
  253. package/script/auth/proof.js +13 -13
  254. package/script/auth/protocol.d.ts +245 -5
  255. package/script/auth/protocol.d.ts.map +1 -1
  256. package/script/auth/protocol.js +29 -29
  257. package/script/auth/schemas.d.ts.map +1 -1
  258. package/script/auth/session_auth.d.ts.map +1 -1
  259. package/script/auth/session_auth.js +15 -15
  260. package/script/auth/time.d.ts.map +1 -1
  261. package/script/auth/trellis_id.d.ts.map +1 -1
  262. package/script/auth/trellis_id.js +3 -3
  263. package/script/auth/types.d.ts +1 -1
  264. package/script/auth/types.d.ts.map +1 -1
  265. package/script/auth/utils.d.ts.map +1 -1
  266. package/script/auth.d.ts +2 -1
  267. package/script/auth.d.ts.map +1 -1
  268. package/script/auth.js +1 -0
  269. package/script/browser.d.ts.map +1 -0
  270. package/script/client.d.ts +6 -6
  271. package/script/client.d.ts.map +1 -1
  272. package/script/client.js +6 -6
  273. package/script/client_connect.d.ts +8 -8
  274. package/script/client_connect.d.ts.map +1 -1
  275. package/script/client_connect.js +88 -54
  276. package/script/codec.d.ts +2 -2
  277. package/script/codec.d.ts.map +1 -1
  278. package/script/codec.js +15 -15
  279. package/script/connection.d.ts +1 -1
  280. package/script/connection.d.ts.map +1 -1
  281. package/script/connection.js +2 -2
  282. package/script/contract.d.ts +2 -2
  283. package/script/contract.d.ts.map +1 -1
  284. package/script/contract.js +5 -5
  285. package/script/contract_support/canonical.d.ts.map +1 -1
  286. package/script/contract_support/mod.d.ts +13 -13
  287. package/script/contract_support/mod.d.ts.map +1 -1
  288. package/script/contract_support/mod.js +64 -64
  289. package/script/contract_support/protocol.d.ts.map +1 -1
  290. package/script/contract_support/runtime.d.ts +1 -1
  291. package/script/contract_support/runtime.d.ts.map +1 -1
  292. package/script/contract_support/schema_pointers.d.ts.map +1 -1
  293. package/script/contracts.d.ts +4 -3
  294. package/script/contracts.d.ts.map +1 -1
  295. package/script/contracts.js +6 -5
  296. package/script/device/deno.d.ts.map +1 -0
  297. package/script/device.d.ts +9 -8
  298. package/script/device.d.ts.map +1 -1
  299. package/script/device.js +41 -40
  300. package/script/env.d.ts.map +1 -0
  301. package/script/errors/AuthError.d.ts +1 -1
  302. package/script/errors/AuthError.d.ts.map +1 -1
  303. package/script/errors/AuthError.js +2 -2
  304. package/script/errors/KVError.d.ts +1 -1
  305. package/script/errors/KVError.d.ts.map +1 -1
  306. package/script/errors/KVError.js +2 -2
  307. package/script/errors/OperationLifecycleError.d.ts +1 -1
  308. package/script/errors/OperationLifecycleError.d.ts.map +1 -1
  309. package/script/errors/OperationLifecycleError.js +4 -4
  310. package/script/errors/RemoteError.d.ts +10 -10
  311. package/script/errors/RemoteError.d.ts.map +1 -1
  312. package/script/errors/RemoteError.js +7 -7
  313. package/script/errors/StoreError.d.ts +1 -1
  314. package/script/errors/StoreError.d.ts.map +1 -1
  315. package/script/errors/StoreError.js +2 -2
  316. package/script/errors/TransferError.d.ts +1 -1
  317. package/script/errors/TransferError.d.ts.map +1 -1
  318. package/script/errors/TransferError.js +2 -2
  319. package/script/errors/TransportError.d.ts +1 -1
  320. package/script/errors/TransportError.d.ts.map +1 -1
  321. package/script/errors/TransportError.js +2 -2
  322. package/script/errors/TrellisError.d.ts.map +1 -1
  323. package/script/errors/ValidationError.d.ts +1 -1
  324. package/script/errors/ValidationError.d.ts.map +1 -1
  325. package/script/errors/ValidationError.js +2 -2
  326. package/script/errors/index.d.ts +33 -32
  327. package/script/errors/index.d.ts.map +1 -1
  328. package/script/errors/index.js +84 -83
  329. package/script/generate.d.ts.map +1 -0
  330. package/script/{npm/src/generate.js → generate.js} +1 -0
  331. package/script/generated-sdk/auth/api.d.ts +604 -3
  332. package/script/generated-sdk/auth/api.d.ts.map +1 -1
  333. package/script/generated-sdk/auth/api.js +4 -1
  334. package/script/generated-sdk/auth/client.d.ts +8 -0
  335. package/script/generated-sdk/auth/client.d.ts.map +1 -1
  336. package/script/generated-sdk/auth/contract.d.ts +600 -1
  337. package/script/generated-sdk/auth/contract.d.ts.map +1 -1
  338. package/script/generated-sdk/auth/mod.d.ts.map +1 -1
  339. package/script/generated-sdk/auth/owned_api.d.ts +601 -2
  340. package/script/generated-sdk/auth/owned_api.d.ts.map +1 -1
  341. package/script/generated-sdk/auth/owned_api.js +144 -144
  342. package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
  343. package/script/generated-sdk/auth/types.d.ts.map +1 -1
  344. package/script/generated-sdk/health/api.d.ts +14 -2
  345. package/script/generated-sdk/health/api.d.ts.map +1 -1
  346. package/script/generated-sdk/health/client.d.ts.map +1 -1
  347. package/script/generated-sdk/health/contract.d.ts +14 -1
  348. package/script/generated-sdk/health/contract.d.ts.map +1 -1
  349. package/script/generated-sdk/health/mod.d.ts.map +1 -1
  350. package/script/generated-sdk/health/owned_api.d.ts +15 -2
  351. package/script/generated-sdk/health/owned_api.d.ts.map +1 -1
  352. package/script/generated-sdk/health/owned_api.js +2 -2
  353. package/script/generated-sdk/health/schemas.d.ts.map +1 -1
  354. package/script/generated-sdk/health/types.d.ts.map +1 -1
  355. package/script/generated-sdk/jobs/api.d.ts +105 -2
  356. package/script/generated-sdk/jobs/api.d.ts.map +1 -1
  357. package/script/generated-sdk/jobs/api.js +7 -7
  358. package/script/generated-sdk/jobs/client.d.ts.map +1 -1
  359. package/script/generated-sdk/jobs/contract.d.ts +105 -1
  360. package/script/generated-sdk/jobs/contract.d.ts.map +1 -1
  361. package/script/generated-sdk/jobs/mod.d.ts.map +1 -1
  362. package/script/generated-sdk/jobs/owned_api.d.ts +106 -2
  363. package/script/generated-sdk/jobs/owned_api.d.ts.map +1 -1
  364. package/script/generated-sdk/jobs/owned_api.js +24 -24
  365. package/script/generated-sdk/jobs/schemas.d.ts.map +1 -1
  366. package/script/generated-sdk/jobs/types.d.ts.map +1 -1
  367. package/script/generated-sdk/jobs/types.js +2 -2
  368. package/script/generated-sdk/state/api.d.ts +64 -2
  369. package/script/generated-sdk/state/api.d.ts.map +1 -1
  370. package/script/generated-sdk/state/api.js +2 -2
  371. package/script/generated-sdk/state/client.d.ts.map +1 -1
  372. package/script/generated-sdk/state/contract.d.ts +64 -1
  373. package/script/generated-sdk/state/contract.d.ts.map +1 -1
  374. package/script/generated-sdk/state/mod.d.ts.map +1 -1
  375. package/script/generated-sdk/state/owned_api.d.ts +65 -2
  376. package/script/generated-sdk/state/owned_api.d.ts.map +1 -1
  377. package/script/generated-sdk/state/owned_api.js +15 -15
  378. package/script/generated-sdk/state/schemas.d.ts.map +1 -1
  379. package/script/generated-sdk/state/types.d.ts.map +1 -1
  380. package/script/generated-sdk/trellis-core/api.d.ts +44 -3
  381. package/script/generated-sdk/trellis-core/api.d.ts.map +1 -1
  382. package/script/generated-sdk/trellis-core/api.js +4 -1
  383. package/script/generated-sdk/trellis-core/client.d.ts +14 -2
  384. package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
  385. package/script/generated-sdk/trellis-core/contract.d.ts +40 -1
  386. package/script/generated-sdk/trellis-core/contract.d.ts.map +1 -1
  387. package/script/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  388. package/script/generated-sdk/trellis-core/owned_api.d.ts +41 -2
  389. package/script/generated-sdk/trellis-core/owned_api.d.ts.map +1 -1
  390. package/script/generated-sdk/trellis-core/owned_api.js +9 -9
  391. package/script/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
  392. package/script/generated-sdk/trellis-core/types.d.ts.map +1 -1
  393. package/script/globals.d.ts.map +1 -1
  394. package/script/health.d.ts +4 -3
  395. package/script/health.d.ts.map +1 -1
  396. package/script/health.js +16 -15
  397. package/script/helpers.d.ts.map +1 -1
  398. package/script/host/mod.d.ts.map +1 -0
  399. package/script/host/node.d.ts.map +1 -0
  400. package/script/index.d.ts +33 -32
  401. package/script/index.d.ts.map +1 -1
  402. package/script/index.js +86 -85
  403. package/script/jobs.d.ts.map +1 -1
  404. package/script/jobs.js +3 -3
  405. package/script/kv.d.ts +1 -1
  406. package/script/kv.d.ts.map +1 -1
  407. package/script/kv.js +22 -22
  408. package/script/models/auth/rpc/Logout.d.ts.map +1 -1
  409. package/script/models/trellis/Page.d.ts +1 -1
  410. package/script/models/trellis/Page.d.ts.map +1 -1
  411. package/script/models/trellis/Page.js +3 -3
  412. package/script/models/trellis/State.d.ts +1 -1
  413. package/script/models/trellis/State.d.ts.map +1 -1
  414. package/script/models/trellis/TrellisError.d.ts.map +1 -1
  415. package/script/models/trellis/rpc/StateDelete.d.ts.map +1 -1
  416. package/script/models/trellis/rpc/StateGet.d.ts +1 -1
  417. package/script/models/trellis/rpc/StateGet.d.ts.map +1 -1
  418. package/script/models/trellis/rpc/StateGet.js +3 -3
  419. package/script/models/trellis/rpc/StateList.d.ts.map +1 -1
  420. package/script/models/trellis/rpc/StateList.js +3 -3
  421. package/script/models/trellis/rpc/StatePut.d.ts +1 -1
  422. package/script/models/trellis/rpc/StatePut.d.ts.map +1 -1
  423. package/script/models/trellis/rpc/StatePut.js +5 -5
  424. package/script/operations.d.ts +4 -4
  425. package/script/operations.d.ts.map +1 -1
  426. package/script/operations.js +16 -16
  427. package/script/runtime_transport.d.ts.map +1 -1
  428. package/script/runtime_transport.js +2 -1
  429. package/script/sdk/auth.d.ts +2 -0
  430. package/script/sdk/auth.d.ts.map +1 -0
  431. package/script/{npm/src/sdk → sdk}/auth.js +1 -1
  432. package/script/sdk/core.d.ts +2 -0
  433. package/script/sdk/core.d.ts.map +1 -0
  434. package/script/{npm/src/sdk/health.js → sdk/core.js} +1 -1
  435. package/script/sdk/health.d.ts +2 -0
  436. package/script/sdk/health.d.ts.map +1 -0
  437. package/script/sdk/health.js +17 -0
  438. package/script/sdk/jobs.d.ts +2 -0
  439. package/script/sdk/jobs.d.ts.map +1 -0
  440. package/script/{npm/src/sdk → sdk}/jobs.js +1 -1
  441. package/script/sdk/state.d.ts +2 -0
  442. package/script/sdk/state.d.ts.map +1 -0
  443. package/script/{npm/src/sdk → sdk}/state.js +1 -1
  444. package/script/server/health.d.ts +2 -11
  445. package/script/server/health.d.ts.map +1 -1
  446. package/script/server/health.js +45 -11
  447. package/{esm/npm/src → script}/server/health_rpc.d.ts +1 -1
  448. package/script/server/health_rpc.d.ts.map +1 -0
  449. package/script/server/health_schemas.d.ts.map +1 -1
  450. package/script/server/internal_jobs/active-job.d.ts.map +1 -0
  451. package/script/server/internal_jobs/bindings.d.ts.map +1 -0
  452. package/script/server/internal_jobs/cancellation-registry.d.ts.map +1 -0
  453. package/script/server/internal_jobs/heartbeat.d.ts.map +1 -0
  454. package/script/server/internal_jobs/job-manager.d.ts.map +1 -0
  455. package/script/server/internal_jobs/projection.d.ts.map +1 -0
  456. package/script/server/internal_jobs/runtime-worker.d.ts.map +1 -0
  457. package/script/server/internal_jobs/types.d.ts.map +1 -0
  458. package/script/server/runtime.d.ts.map +1 -0
  459. package/{esm/npm/src → script}/server/service.d.ts +4 -4
  460. package/script/server/service.d.ts.map +1 -0
  461. package/script/{npm/src/server → server}/service.js +19 -19
  462. package/script/{npm/src/server → server}/subscription.d.ts +1 -1
  463. package/script/server/subscription.d.ts.map +1 -0
  464. package/script/server/transfer.d.ts.map +1 -0
  465. package/script/server.d.ts.map +1 -0
  466. package/script/server_logger.d.ts.map +1 -0
  467. package/script/service/deno.d.ts.map +1 -0
  468. package/script/service/mod.d.ts.map +1 -0
  469. package/script/service/node.d.ts.map +1 -0
  470. package/script/service/outbox_inbox.d.ts.map +1 -0
  471. package/script/store.d.ts +2 -2
  472. package/script/store.d.ts.map +1 -1
  473. package/script/store.js +20 -20
  474. package/script/tasks.d.ts +1 -1
  475. package/script/tasks.d.ts.map +1 -1
  476. package/script/tasks.js +2 -2
  477. package/script/telemetry/carrier.d.ts.map +1 -1
  478. package/script/telemetry/core.d.ts.map +1 -1
  479. package/script/telemetry/env.d.ts.map +1 -1
  480. package/script/telemetry/env.js +36 -2
  481. package/script/telemetry/mod.d.ts +9 -9
  482. package/script/telemetry/mod.d.ts.map +1 -1
  483. package/script/telemetry/mod.js +23 -23
  484. package/script/telemetry/nats.d.ts +1 -1
  485. package/script/telemetry/nats.d.ts.map +1 -1
  486. package/script/telemetry/result.d.ts.map +1 -1
  487. package/script/telemetry/trace.d.ts.map +1 -1
  488. package/script/telemetry/trace.js +2 -2
  489. package/script/telemetry/trellis.d.ts +1 -1
  490. package/script/telemetry/trellis.d.ts.map +1 -1
  491. package/script/telemetry/trellis.js +4 -4
  492. package/script/tracing.d.ts +3 -2
  493. package/script/tracing.d.ts.map +1 -1
  494. package/script/tracing.js +19 -16
  495. package/script/transfer.d.ts +1 -1
  496. package/script/transfer.d.ts.map +1 -1
  497. package/script/transfer.js +26 -26
  498. package/script/trellis.d.ts +13 -13
  499. package/script/trellis.d.ts.map +1 -1
  500. package/script/trellis.js +127 -127
  501. package/src/auth/protocol.ts +1 -1
  502. package/src/generate.ts +1 -0
  503. package/src/sdk/_generated/auth/api.ts +3 -0
  504. package/src/sdk/_generated/auth/client.ts +5 -1
  505. package/src/sdk/_generated/auth/contract.ts +1 -1
  506. package/src/sdk/_generated/auth/owned_api.ts +2 -2
  507. package/src/sdk/_generated/auth/types.ts +1 -1
  508. package/src/sdk/_generated/core/api.ts +3 -0
  509. package/src/sdk/_generated/core/client.ts +7 -2
  510. package/src/sdk/_generated/core/contract.ts +1 -1
  511. package/src/sdk/_generated/core/owned_api.ts +2 -2
  512. package/src/sdk/_generated/core/types.ts +1 -1
  513. package/src/sdk/_generated/health/client.ts +1 -1
  514. package/src/sdk/_generated/health/contract.ts +1 -1
  515. package/src/sdk/_generated/health/owned_api.ts +2 -2
  516. package/src/sdk/_generated/jobs/api.ts +3 -3
  517. package/src/sdk/_generated/jobs/client.ts +4 -4
  518. package/src/sdk/_generated/jobs/contract.ts +1 -1
  519. package/src/sdk/_generated/jobs/owned_api.ts +2 -2
  520. package/src/sdk/_generated/jobs/types.ts +2 -2
  521. package/src/sdk/_generated/state/api.ts +1 -1
  522. package/src/sdk/_generated/state/client.ts +2 -2
  523. package/src/sdk/_generated/state/contract.ts +1 -1
  524. package/src/sdk/_generated/state/owned_api.ts +2 -2
  525. package/src/sdk/_generated/state/types.ts +1 -1
  526. package/src/server/health.ts +2 -2
  527. package/src/server/health_rpc.ts +1 -1
  528. package/src/server/service.ts +5 -5
  529. package/src/server/subscription.ts +1 -4
  530. package/esm/npm/src/_dnt.polyfills.d.ts.map +0 -1
  531. package/esm/npm/src/_dnt.shims.d.ts.map +0 -1
  532. package/esm/npm/src/auth/browser/login.d.ts +0 -34
  533. package/esm/npm/src/auth/browser/login.d.ts.map +0 -1
  534. package/esm/npm/src/auth/browser/login.js +0 -141
  535. package/esm/npm/src/auth/browser/portal.d.ts +0 -11
  536. package/esm/npm/src/auth/browser/portal.d.ts.map +0 -1
  537. package/esm/npm/src/auth/browser/portal.js +0 -37
  538. package/esm/npm/src/auth/browser/session.d.ts +0 -29
  539. package/esm/npm/src/auth/browser/session.d.ts.map +0 -1
  540. package/esm/npm/src/auth/browser/session.js +0 -109
  541. package/esm/npm/src/auth/browser/storage.d.ts +0 -17
  542. package/esm/npm/src/auth/browser/storage.d.ts.map +0 -1
  543. package/esm/npm/src/auth/browser/storage.js +0 -73
  544. package/esm/npm/src/auth/browser.d.ts +0 -14
  545. package/esm/npm/src/auth/browser.d.ts.map +0 -1
  546. package/esm/npm/src/auth/browser.js +0 -12
  547. package/esm/npm/src/auth/device_activation.d.ts +0 -146
  548. package/esm/npm/src/auth/device_activation.d.ts.map +0 -1
  549. package/esm/npm/src/auth/device_activation.js +0 -369
  550. package/esm/npm/src/auth/keys.d.ts +0 -8
  551. package/esm/npm/src/auth/keys.d.ts.map +0 -1
  552. package/esm/npm/src/auth/keys.js +0 -70
  553. package/esm/npm/src/auth/mod.d.ts +0 -19
  554. package/esm/npm/src/auth/mod.d.ts.map +0 -1
  555. package/esm/npm/src/auth/mod.js +0 -18
  556. package/esm/npm/src/auth/proof.d.ts +0 -11
  557. package/esm/npm/src/auth/proof.d.ts.map +0 -1
  558. package/esm/npm/src/auth/proof.js +0 -49
  559. package/esm/npm/src/auth/protocol.d.ts +0 -3108
  560. package/esm/npm/src/auth/protocol.d.ts.map +0 -1
  561. package/esm/npm/src/auth/protocol.js +0 -1329
  562. package/esm/npm/src/auth/schemas.d.ts +0 -163
  563. package/esm/npm/src/auth/schemas.d.ts.map +0 -1
  564. package/esm/npm/src/auth/schemas.js +0 -89
  565. package/esm/npm/src/auth/session_auth.d.ts +0 -26
  566. package/esm/npm/src/auth/session_auth.d.ts.map +0 -1
  567. package/esm/npm/src/auth/session_auth.js +0 -70
  568. package/esm/npm/src/auth/time.d.ts +0 -7
  569. package/esm/npm/src/auth/time.d.ts.map +0 -1
  570. package/esm/npm/src/auth/time.js +0 -7
  571. package/esm/npm/src/auth/trellis_id.d.ts +0 -2
  572. package/esm/npm/src/auth/trellis_id.d.ts.map +0 -1
  573. package/esm/npm/src/auth/trellis_id.js +0 -5
  574. package/esm/npm/src/auth/types.d.ts +0 -4
  575. package/esm/npm/src/auth/types.d.ts.map +0 -1
  576. package/esm/npm/src/auth/types.js +0 -1
  577. package/esm/npm/src/auth/utils.d.ts +0 -11
  578. package/esm/npm/src/auth/utils.d.ts.map +0 -1
  579. package/esm/npm/src/auth/utils.js +0 -69
  580. package/esm/npm/src/auth.d.ts +0 -3
  581. package/esm/npm/src/auth.d.ts.map +0 -1
  582. package/esm/npm/src/auth.js +0 -2
  583. package/esm/npm/src/browser.d.ts.map +0 -1
  584. package/esm/npm/src/client.d.ts +0 -60
  585. package/esm/npm/src/client.d.ts.map +0 -1
  586. package/esm/npm/src/client.js +0 -39
  587. package/esm/npm/src/client_connect.d.ts +0 -87
  588. package/esm/npm/src/client_connect.d.ts.map +0 -1
  589. package/esm/npm/src/client_connect.js +0 -839
  590. package/esm/npm/src/codec.d.ts +0 -13
  591. package/esm/npm/src/codec.d.ts.map +0 -1
  592. package/esm/npm/src/codec.js +0 -73
  593. package/esm/npm/src/connection.d.ts +0 -91
  594. package/esm/npm/src/connection.d.ts.map +0 -1
  595. package/esm/npm/src/connection.js +0 -305
  596. package/esm/npm/src/contract.d.ts +0 -23
  597. package/esm/npm/src/contract.d.ts.map +0 -1
  598. package/esm/npm/src/contract.js +0 -1
  599. package/esm/npm/src/contract_support/canonical.d.ts +0 -14
  600. package/esm/npm/src/contract_support/canonical.d.ts.map +0 -1
  601. package/esm/npm/src/contract_support/canonical.js +0 -190
  602. package/esm/npm/src/contract_support/mod.d.ts +0 -1188
  603. package/esm/npm/src/contract_support/mod.d.ts.map +0 -1
  604. package/esm/npm/src/contract_support/mod.js +0 -2182
  605. package/esm/npm/src/contract_support/protocol.d.ts +0 -384
  606. package/esm/npm/src/contract_support/protocol.d.ts.map +0 -1
  607. package/esm/npm/src/contract_support/protocol.js +0 -164
  608. package/esm/npm/src/contract_support/runtime.d.ts +0 -84
  609. package/esm/npm/src/contract_support/runtime.d.ts.map +0 -1
  610. package/esm/npm/src/contract_support/runtime.js +0 -9
  611. package/esm/npm/src/contract_support/schema_pointers.d.ts +0 -18
  612. package/esm/npm/src/contract_support/schema_pointers.d.ts.map +0 -1
  613. package/esm/npm/src/contract_support/schema_pointers.js +0 -79
  614. package/esm/npm/src/contracts.d.ts +0 -5
  615. package/esm/npm/src/contracts.d.ts.map +0 -1
  616. package/esm/npm/src/contracts.js +0 -3
  617. package/esm/npm/src/device/deno.d.ts.map +0 -1
  618. package/esm/npm/src/device.d.ts +0 -150
  619. package/esm/npm/src/device.d.ts.map +0 -1
  620. package/esm/npm/src/device.js +0 -549
  621. package/esm/npm/src/env.d.ts.map +0 -1
  622. package/esm/npm/src/errors/AuthError.d.ts +0 -31
  623. package/esm/npm/src/errors/AuthError.d.ts.map +0 -1
  624. package/esm/npm/src/errors/AuthError.js +0 -79
  625. package/esm/npm/src/errors/KVError.d.ts +0 -31
  626. package/esm/npm/src/errors/KVError.d.ts.map +0 -1
  627. package/esm/npm/src/errors/KVError.js +0 -46
  628. package/esm/npm/src/errors/OperationLifecycleError.d.ts +0 -111
  629. package/esm/npm/src/errors/OperationLifecycleError.d.ts.map +0 -1
  630. package/esm/npm/src/errors/OperationLifecycleError.js +0 -207
  631. package/esm/npm/src/errors/RemoteError.d.ts +0 -55
  632. package/esm/npm/src/errors/RemoteError.d.ts.map +0 -1
  633. package/esm/npm/src/errors/RemoteError.js +0 -81
  634. package/esm/npm/src/errors/StoreError.d.ts +0 -22
  635. package/esm/npm/src/errors/StoreError.d.ts.map +0 -1
  636. package/esm/npm/src/errors/StoreError.js +0 -41
  637. package/esm/npm/src/errors/TransferError.d.ts +0 -22
  638. package/esm/npm/src/errors/TransferError.d.ts.map +0 -1
  639. package/esm/npm/src/errors/TransferError.js +0 -41
  640. package/esm/npm/src/errors/TransportError.d.ts +0 -30
  641. package/esm/npm/src/errors/TransportError.d.ts.map +0 -1
  642. package/esm/npm/src/errors/TransportError.js +0 -48
  643. package/esm/npm/src/errors/TrellisError.d.ts +0 -16
  644. package/esm/npm/src/errors/TrellisError.d.ts.map +0 -1
  645. package/esm/npm/src/errors/TrellisError.js +0 -15
  646. package/esm/npm/src/errors/ValidationError.d.ts +0 -51
  647. package/esm/npm/src/errors/ValidationError.d.ts.map +0 -1
  648. package/esm/npm/src/errors/ValidationError.js +0 -77
  649. package/esm/npm/src/errors/index.d.ts +0 -212
  650. package/esm/npm/src/errors/index.d.ts.map +0 -1
  651. package/esm/npm/src/errors/index.js +0 -190
  652. package/esm/npm/src/generate.d.ts.map +0 -1
  653. package/esm/npm/src/globals.d.ts +0 -10
  654. package/esm/npm/src/globals.d.ts.map +0 -1
  655. package/esm/npm/src/globals.js +0 -16
  656. package/esm/npm/src/health.d.ts +0 -5
  657. package/esm/npm/src/health.d.ts.map +0 -1
  658. package/esm/npm/src/health.js +0 -3
  659. package/esm/npm/src/helpers.d.ts +0 -10
  660. package/esm/npm/src/helpers.d.ts.map +0 -1
  661. package/esm/npm/src/helpers.js +0 -38
  662. package/esm/npm/src/host/mod.d.ts.map +0 -1
  663. package/esm/npm/src/host/node.d.ts.map +0 -1
  664. package/esm/npm/src/index.d.ts +0 -37
  665. package/esm/npm/src/index.d.ts.map +0 -1
  666. package/esm/npm/src/index.js +0 -18
  667. package/esm/npm/src/jobs.d.ts +0 -145
  668. package/esm/npm/src/jobs.d.ts.map +0 -1
  669. package/esm/npm/src/jobs.js +0 -220
  670. package/esm/npm/src/kv.d.ts +0 -82
  671. package/esm/npm/src/kv.d.ts.map +0 -1
  672. package/esm/npm/src/kv.js +0 -448
  673. package/esm/npm/src/models/auth/rpc/Logout.d.ts +0 -8
  674. package/esm/npm/src/models/auth/rpc/Logout.d.ts.map +0 -1
  675. package/esm/npm/src/models/auth/rpc/Logout.js +0 -5
  676. package/esm/npm/src/models/trellis/Page.d.ts +0 -2
  677. package/esm/npm/src/models/trellis/Page.d.ts.map +0 -1
  678. package/esm/npm/src/models/trellis/Page.js +0 -1
  679. package/esm/npm/src/models/trellis/State.d.ts +0 -49
  680. package/esm/npm/src/models/trellis/State.d.ts.map +0 -1
  681. package/esm/npm/src/models/trellis/State.js +0 -29
  682. package/esm/npm/src/models/trellis/TrellisError.d.ts +0 -20
  683. package/esm/npm/src/models/trellis/TrellisError.d.ts.map +0 -1
  684. package/esm/npm/src/models/trellis/TrellisError.js +0 -15
  685. package/esm/npm/src/models/trellis/rpc/StateDelete.d.ts +0 -12
  686. package/esm/npm/src/models/trellis/rpc/StateDelete.d.ts.map +0 -1
  687. package/esm/npm/src/models/trellis/rpc/StateDelete.js +0 -9
  688. package/esm/npm/src/models/trellis/rpc/StateGet.d.ts +0 -38
  689. package/esm/npm/src/models/trellis/rpc/StateGet.d.ts.map +0 -1
  690. package/esm/npm/src/models/trellis/rpc/StateGet.js +0 -16
  691. package/esm/npm/src/models/trellis/rpc/StateList.d.ts +0 -35
  692. package/esm/npm/src/models/trellis/rpc/StateList.d.ts.map +0 -1
  693. package/esm/npm/src/models/trellis/rpc/StateList.js +0 -18
  694. package/esm/npm/src/models/trellis/rpc/StatePut.d.ts +0 -51
  695. package/esm/npm/src/models/trellis/rpc/StatePut.d.ts.map +0 -1
  696. package/esm/npm/src/models/trellis/rpc/StatePut.js +0 -26
  697. package/esm/npm/src/operations.d.ts +0 -171
  698. package/esm/npm/src/operations.d.ts.map +0 -1
  699. package/esm/npm/src/operations.js +0 -775
  700. package/esm/npm/src/runtime_transport.d.ts +0 -25
  701. package/esm/npm/src/runtime_transport.d.ts.map +0 -1
  702. package/esm/npm/src/runtime_transport.js +0 -84
  703. package/esm/npm/src/sdk/auth.d.ts +0 -2
  704. package/esm/npm/src/sdk/auth.d.ts.map +0 -1
  705. package/esm/npm/src/sdk/auth.js +0 -1
  706. package/esm/npm/src/sdk/core.d.ts +0 -2
  707. package/esm/npm/src/sdk/core.d.ts.map +0 -1
  708. package/esm/npm/src/sdk/core.js +0 -1
  709. package/esm/npm/src/sdk/health.d.ts +0 -2
  710. package/esm/npm/src/sdk/health.d.ts.map +0 -1
  711. package/esm/npm/src/sdk/health.js +0 -1
  712. package/esm/npm/src/sdk/jobs.d.ts +0 -2
  713. package/esm/npm/src/sdk/jobs.d.ts.map +0 -1
  714. package/esm/npm/src/sdk/jobs.js +0 -1
  715. package/esm/npm/src/sdk/state.d.ts +0 -2
  716. package/esm/npm/src/sdk/state.d.ts.map +0 -1
  717. package/esm/npm/src/sdk/state.js +0 -1
  718. package/esm/npm/src/server/health.d.ts +0 -161
  719. package/esm/npm/src/server/health.d.ts.map +0 -1
  720. package/esm/npm/src/server/health.js +0 -262
  721. package/esm/npm/src/server/health_rpc.d.ts.map +0 -1
  722. package/esm/npm/src/server/health_schemas.d.ts +0 -71
  723. package/esm/npm/src/server/health_schemas.d.ts.map +0 -1
  724. package/esm/npm/src/server/health_schemas.js +0 -54
  725. package/esm/npm/src/server/internal_jobs/active-job.d.ts.map +0 -1
  726. package/esm/npm/src/server/internal_jobs/bindings.d.ts.map +0 -1
  727. package/esm/npm/src/server/internal_jobs/cancellation-registry.d.ts.map +0 -1
  728. package/esm/npm/src/server/internal_jobs/heartbeat.d.ts.map +0 -1
  729. package/esm/npm/src/server/internal_jobs/job-manager.d.ts.map +0 -1
  730. package/esm/npm/src/server/internal_jobs/projection.d.ts.map +0 -1
  731. package/esm/npm/src/server/internal_jobs/runtime-worker.d.ts.map +0 -1
  732. package/esm/npm/src/server/internal_jobs/types.d.ts.map +0 -1
  733. package/esm/npm/src/server/runtime.d.ts.map +0 -1
  734. package/esm/npm/src/server/service.d.ts.map +0 -1
  735. package/esm/npm/src/server/subscription.d.ts.map +0 -1
  736. package/esm/npm/src/server/transfer.d.ts.map +0 -1
  737. package/esm/npm/src/server.d.ts.map +0 -1
  738. package/esm/npm/src/server_logger.d.ts.map +0 -1
  739. package/esm/npm/src/service/deno.d.ts.map +0 -1
  740. package/esm/npm/src/service/mod.d.ts.map +0 -1
  741. package/esm/npm/src/service/node.d.ts.map +0 -1
  742. package/esm/npm/src/service/outbox_inbox.d.ts.map +0 -1
  743. package/esm/npm/src/store.d.ts +0 -67
  744. package/esm/npm/src/store.d.ts.map +0 -1
  745. package/esm/npm/src/store.js +0 -474
  746. package/esm/npm/src/tasks.d.ts +0 -11
  747. package/esm/npm/src/tasks.d.ts.map +0 -1
  748. package/esm/npm/src/tasks.js +0 -41
  749. package/esm/npm/src/telemetry/carrier.d.ts +0 -9
  750. package/esm/npm/src/telemetry/carrier.d.ts.map +0 -1
  751. package/esm/npm/src/telemetry/carrier.js +0 -20
  752. package/esm/npm/src/telemetry/core.d.ts +0 -8
  753. package/esm/npm/src/telemetry/core.d.ts.map +0 -1
  754. package/esm/npm/src/telemetry/core.js +0 -14
  755. package/esm/npm/src/telemetry/env.d.ts +0 -2
  756. package/esm/npm/src/telemetry/env.d.ts.map +0 -1
  757. package/esm/npm/src/telemetry/env.js +0 -10
  758. package/esm/npm/src/telemetry/mod.d.ts +0 -10
  759. package/esm/npm/src/telemetry/mod.d.ts.map +0 -1
  760. package/esm/npm/src/telemetry/mod.js +0 -6
  761. package/esm/npm/src/telemetry/nats.d.ts +0 -7
  762. package/esm/npm/src/telemetry/nats.d.ts.map +0 -1
  763. package/esm/npm/src/telemetry/nats.js +0 -6
  764. package/esm/npm/src/telemetry/result.d.ts +0 -2
  765. package/esm/npm/src/telemetry/result.d.ts.map +0 -1
  766. package/esm/npm/src/telemetry/result.js +0 -18
  767. package/esm/npm/src/telemetry/trace.d.ts +0 -5
  768. package/esm/npm/src/telemetry/trace.d.ts.map +0 -1
  769. package/esm/npm/src/telemetry/trace.js +0 -26
  770. package/esm/npm/src/telemetry/trellis.d.ts +0 -2
  771. package/esm/npm/src/telemetry/trellis.d.ts.map +0 -1
  772. package/esm/npm/src/telemetry/trellis.js +0 -1
  773. package/esm/npm/src/tracing.d.ts +0 -5
  774. package/esm/npm/src/tracing.d.ts.map +0 -1
  775. package/esm/npm/src/tracing.js +0 -8
  776. package/esm/npm/src/transfer.d.ts +0 -118
  777. package/esm/npm/src/transfer.d.ts.map +0 -1
  778. package/esm/npm/src/transfer.js +0 -407
  779. package/esm/npm/src/trellis.d.ts +0 -678
  780. package/esm/npm/src/trellis.d.ts.map +0 -1
  781. package/esm/npm/src/trellis.js +0 -2284
  782. package/script/npm/src/_dnt.polyfills.d.ts.map +0 -1
  783. package/script/npm/src/_dnt.shims.d.ts.map +0 -1
  784. package/script/npm/src/auth/browser/login.d.ts +0 -34
  785. package/script/npm/src/auth/browser/login.d.ts.map +0 -1
  786. package/script/npm/src/auth/browser/login.js +0 -147
  787. package/script/npm/src/auth/browser/portal.d.ts +0 -11
  788. package/script/npm/src/auth/browser/portal.d.ts.map +0 -1
  789. package/script/npm/src/auth/browser/portal.js +0 -44
  790. package/script/npm/src/auth/browser/session.d.ts +0 -29
  791. package/script/npm/src/auth/browser/session.d.ts.map +0 -1
  792. package/script/npm/src/auth/browser/session.js +0 -122
  793. package/script/npm/src/auth/browser/storage.d.ts +0 -17
  794. package/script/npm/src/auth/browser/storage.d.ts.map +0 -1
  795. package/script/npm/src/auth/browser/storage.js +0 -79
  796. package/script/npm/src/auth/browser.d.ts +0 -14
  797. package/script/npm/src/auth/browser.d.ts.map +0 -1
  798. package/script/npm/src/auth/browser.js +0 -53
  799. package/script/npm/src/auth/device_activation.d.ts +0 -146
  800. package/script/npm/src/auth/device_activation.d.ts.map +0 -1
  801. package/script/npm/src/auth/device_activation.js +0 -387
  802. package/script/npm/src/auth/keys.d.ts +0 -8
  803. package/script/npm/src/auth/keys.d.ts.map +0 -1
  804. package/script/npm/src/auth/keys.js +0 -82
  805. package/script/npm/src/auth/mod.d.ts +0 -19
  806. package/script/npm/src/auth/mod.d.ts.map +0 -1
  807. package/script/npm/src/auth/mod.js +0 -248
  808. package/script/npm/src/auth/proof.d.ts +0 -11
  809. package/script/npm/src/auth/proof.d.ts.map +0 -1
  810. package/script/npm/src/auth/proof.js +0 -54
  811. package/script/npm/src/auth/protocol.d.ts +0 -3108
  812. package/script/npm/src/auth/protocol.d.ts.map +0 -1
  813. package/script/npm/src/auth/protocol.js +0 -1335
  814. package/script/npm/src/auth/schemas.d.ts +0 -163
  815. package/script/npm/src/auth/schemas.d.ts.map +0 -1
  816. package/script/npm/src/auth/schemas.js +0 -93
  817. package/script/npm/src/auth/session_auth.d.ts +0 -26
  818. package/script/npm/src/auth/session_auth.d.ts.map +0 -1
  819. package/script/npm/src/auth/session_auth.js +0 -74
  820. package/script/npm/src/auth/time.d.ts +0 -7
  821. package/script/npm/src/auth/time.d.ts.map +0 -1
  822. package/script/npm/src/auth/time.js +0 -11
  823. package/script/npm/src/auth/trellis_id.d.ts +0 -2
  824. package/script/npm/src/auth/trellis_id.d.ts.map +0 -1
  825. package/script/npm/src/auth/trellis_id.js +0 -8
  826. package/script/npm/src/auth/types.d.ts +0 -4
  827. package/script/npm/src/auth/types.d.ts.map +0 -1
  828. package/script/npm/src/auth/types.js +0 -2
  829. package/script/npm/src/auth/utils.d.ts +0 -11
  830. package/script/npm/src/auth/utils.d.ts.map +0 -1
  831. package/script/npm/src/auth/utils.js +0 -78
  832. package/script/npm/src/auth.d.ts +0 -3
  833. package/script/npm/src/auth.d.ts.map +0 -1
  834. package/script/npm/src/auth.js +0 -18
  835. package/script/npm/src/browser.d.ts.map +0 -1
  836. package/script/npm/src/client.d.ts +0 -60
  837. package/script/npm/src/client.d.ts.map +0 -1
  838. package/script/npm/src/client.js +0 -76
  839. package/script/npm/src/client_connect.d.ts +0 -87
  840. package/script/npm/src/client_connect.d.ts.map +0 -1
  841. package/script/npm/src/client_connect.js +0 -878
  842. package/script/npm/src/codec.d.ts +0 -13
  843. package/script/npm/src/codec.d.ts.map +0 -1
  844. package/script/npm/src/codec.js +0 -80
  845. package/script/npm/src/connection.d.ts +0 -91
  846. package/script/npm/src/connection.d.ts.map +0 -1
  847. package/script/npm/src/connection.js +0 -311
  848. package/script/npm/src/contract.d.ts +0 -23
  849. package/script/npm/src/contract.d.ts.map +0 -1
  850. package/script/npm/src/contract.js +0 -8
  851. package/script/npm/src/contract_support/canonical.d.ts +0 -14
  852. package/script/npm/src/contract_support/canonical.d.ts.map +0 -1
  853. package/script/npm/src/contract_support/canonical.js +0 -199
  854. package/script/npm/src/contract_support/mod.d.ts +0 -1188
  855. package/script/npm/src/contract_support/mod.d.ts.map +0 -1
  856. package/script/npm/src/contract_support/mod.js +0 -2225
  857. package/script/npm/src/contract_support/protocol.d.ts +0 -384
  858. package/script/npm/src/contract_support/protocol.d.ts.map +0 -1
  859. package/script/npm/src/contract_support/protocol.js +0 -171
  860. package/script/npm/src/contract_support/runtime.d.ts +0 -84
  861. package/script/npm/src/contract_support/runtime.d.ts.map +0 -1
  862. package/script/npm/src/contract_support/runtime.js +0 -13
  863. package/script/npm/src/contract_support/schema_pointers.d.ts +0 -18
  864. package/script/npm/src/contract_support/schema_pointers.d.ts.map +0 -1
  865. package/script/npm/src/contract_support/schema_pointers.js +0 -83
  866. package/script/npm/src/contracts.d.ts +0 -5
  867. package/script/npm/src/contracts.d.ts.map +0 -1
  868. package/script/npm/src/contracts.js +0 -24
  869. package/script/npm/src/device/deno.d.ts.map +0 -1
  870. package/script/npm/src/device.d.ts +0 -150
  871. package/script/npm/src/device.d.ts.map +0 -1
  872. package/script/npm/src/device.js +0 -555
  873. package/script/npm/src/env.d.ts.map +0 -1
  874. package/script/npm/src/errors/AuthError.d.ts +0 -31
  875. package/script/npm/src/errors/AuthError.d.ts.map +0 -1
  876. package/script/npm/src/errors/AuthError.js +0 -86
  877. package/script/npm/src/errors/KVError.d.ts +0 -31
  878. package/script/npm/src/errors/KVError.d.ts.map +0 -1
  879. package/script/npm/src/errors/KVError.js +0 -53
  880. package/script/npm/src/errors/OperationLifecycleError.d.ts +0 -111
  881. package/script/npm/src/errors/OperationLifecycleError.d.ts.map +0 -1
  882. package/script/npm/src/errors/OperationLifecycleError.js +0 -216
  883. package/script/npm/src/errors/RemoteError.d.ts +0 -55
  884. package/script/npm/src/errors/RemoteError.d.ts.map +0 -1
  885. package/script/npm/src/errors/RemoteError.js +0 -88
  886. package/script/npm/src/errors/StoreError.d.ts +0 -22
  887. package/script/npm/src/errors/StoreError.d.ts.map +0 -1
  888. package/script/npm/src/errors/StoreError.js +0 -48
  889. package/script/npm/src/errors/TransferError.d.ts +0 -22
  890. package/script/npm/src/errors/TransferError.d.ts.map +0 -1
  891. package/script/npm/src/errors/TransferError.js +0 -48
  892. package/script/npm/src/errors/TransportError.d.ts +0 -30
  893. package/script/npm/src/errors/TransportError.d.ts.map +0 -1
  894. package/script/npm/src/errors/TransportError.js +0 -55
  895. package/script/npm/src/errors/TrellisError.d.ts +0 -16
  896. package/script/npm/src/errors/TrellisError.d.ts.map +0 -1
  897. package/script/npm/src/errors/TrellisError.js +0 -19
  898. package/script/npm/src/errors/ValidationError.d.ts +0 -51
  899. package/script/npm/src/errors/ValidationError.d.ts.map +0 -1
  900. package/script/npm/src/errors/ValidationError.js +0 -84
  901. package/script/npm/src/errors/index.d.ts +0 -212
  902. package/script/npm/src/errors/index.d.ts.map +0 -1
  903. package/script/npm/src/errors/index.js +0 -217
  904. package/script/npm/src/generate.d.ts.map +0 -1
  905. package/script/npm/src/globals.d.ts +0 -10
  906. package/script/npm/src/globals.d.ts.map +0 -1
  907. package/script/npm/src/globals.js +0 -19
  908. package/script/npm/src/health.d.ts +0 -5
  909. package/script/npm/src/health.d.ts.map +0 -1
  910. package/script/npm/src/health.js +0 -19
  911. package/script/npm/src/helpers.d.ts +0 -10
  912. package/script/npm/src/helpers.d.ts.map +0 -1
  913. package/script/npm/src/helpers.js +0 -44
  914. package/script/npm/src/host/mod.d.ts.map +0 -1
  915. package/script/npm/src/host/node.d.ts.map +0 -1
  916. package/script/npm/src/index.d.ts +0 -37
  917. package/script/npm/src/index.d.ts.map +0 -1
  918. package/script/npm/src/index.js +0 -98
  919. package/script/npm/src/jobs.d.ts +0 -145
  920. package/script/npm/src/jobs.d.ts.map +0 -1
  921. package/script/npm/src/jobs.js +0 -227
  922. package/script/npm/src/kv.d.ts +0 -82
  923. package/script/npm/src/kv.d.ts.map +0 -1
  924. package/script/npm/src/kv.js +0 -486
  925. package/script/npm/src/models/auth/rpc/Logout.d.ts +0 -8
  926. package/script/npm/src/models/auth/rpc/Logout.d.ts.map +0 -1
  927. package/script/npm/src/models/auth/rpc/Logout.js +0 -11
  928. package/script/npm/src/models/trellis/Page.d.ts +0 -2
  929. package/script/npm/src/models/trellis/Page.d.ts.map +0 -1
  930. package/script/npm/src/models/trellis/Page.js +0 -6
  931. package/script/npm/src/models/trellis/State.d.ts +0 -49
  932. package/script/npm/src/models/trellis/State.d.ts.map +0 -1
  933. package/script/npm/src/models/trellis/State.js +0 -35
  934. package/script/npm/src/models/trellis/TrellisError.d.ts +0 -20
  935. package/script/npm/src/models/trellis/TrellisError.d.ts.map +0 -1
  936. package/script/npm/src/models/trellis/TrellisError.js +0 -21
  937. package/script/npm/src/models/trellis/rpc/StateDelete.d.ts +0 -12
  938. package/script/npm/src/models/trellis/rpc/StateDelete.d.ts.map +0 -1
  939. package/script/npm/src/models/trellis/rpc/StateDelete.js +0 -15
  940. package/script/npm/src/models/trellis/rpc/StateGet.d.ts +0 -38
  941. package/script/npm/src/models/trellis/rpc/StateGet.d.ts.map +0 -1
  942. package/script/npm/src/models/trellis/rpc/StateGet.js +0 -22
  943. package/script/npm/src/models/trellis/rpc/StateList.d.ts +0 -35
  944. package/script/npm/src/models/trellis/rpc/StateList.d.ts.map +0 -1
  945. package/script/npm/src/models/trellis/rpc/StateList.js +0 -24
  946. package/script/npm/src/models/trellis/rpc/StatePut.d.ts +0 -51
  947. package/script/npm/src/models/trellis/rpc/StatePut.d.ts.map +0 -1
  948. package/script/npm/src/models/trellis/rpc/StatePut.js +0 -32
  949. package/script/npm/src/operations.d.ts +0 -171
  950. package/script/npm/src/operations.d.ts.map +0 -1
  951. package/script/npm/src/operations.js +0 -780
  952. package/script/npm/src/runtime_transport.d.ts +0 -25
  953. package/script/npm/src/runtime_transport.d.ts.map +0 -1
  954. package/script/npm/src/runtime_transport.js +0 -122
  955. package/script/npm/src/sdk/auth.d.ts +0 -2
  956. package/script/npm/src/sdk/auth.d.ts.map +0 -1
  957. package/script/npm/src/sdk/core.d.ts +0 -2
  958. package/script/npm/src/sdk/core.d.ts.map +0 -1
  959. package/script/npm/src/sdk/core.js +0 -17
  960. package/script/npm/src/sdk/health.d.ts +0 -2
  961. package/script/npm/src/sdk/health.d.ts.map +0 -1
  962. package/script/npm/src/sdk/jobs.d.ts +0 -2
  963. package/script/npm/src/sdk/jobs.d.ts.map +0 -1
  964. package/script/npm/src/sdk/state.d.ts +0 -2
  965. package/script/npm/src/sdk/state.d.ts.map +0 -1
  966. package/script/npm/src/server/health.d.ts +0 -161
  967. package/script/npm/src/server/health.d.ts.map +0 -1
  968. package/script/npm/src/server/health.js +0 -304
  969. package/script/npm/src/server/health_rpc.d.ts.map +0 -1
  970. package/script/npm/src/server/health_schemas.d.ts +0 -71
  971. package/script/npm/src/server/health_schemas.d.ts.map +0 -1
  972. package/script/npm/src/server/health_schemas.js +0 -57
  973. package/script/npm/src/server/internal_jobs/active-job.d.ts.map +0 -1
  974. package/script/npm/src/server/internal_jobs/bindings.d.ts.map +0 -1
  975. package/script/npm/src/server/internal_jobs/cancellation-registry.d.ts.map +0 -1
  976. package/script/npm/src/server/internal_jobs/heartbeat.d.ts.map +0 -1
  977. package/script/npm/src/server/internal_jobs/job-manager.d.ts.map +0 -1
  978. package/script/npm/src/server/internal_jobs/projection.d.ts.map +0 -1
  979. package/script/npm/src/server/internal_jobs/runtime-worker.d.ts.map +0 -1
  980. package/script/npm/src/server/internal_jobs/types.d.ts.map +0 -1
  981. package/script/npm/src/server/runtime.d.ts.map +0 -1
  982. package/script/npm/src/server/service.d.ts.map +0 -1
  983. package/script/npm/src/server/subscription.d.ts.map +0 -1
  984. package/script/npm/src/server/transfer.d.ts.map +0 -1
  985. package/script/npm/src/server.d.ts.map +0 -1
  986. package/script/npm/src/server_logger.d.ts.map +0 -1
  987. package/script/npm/src/service/deno.d.ts.map +0 -1
  988. package/script/npm/src/service/mod.d.ts.map +0 -1
  989. package/script/npm/src/service/node.d.ts.map +0 -1
  990. package/script/npm/src/service/outbox_inbox.d.ts.map +0 -1
  991. package/script/npm/src/store.d.ts +0 -67
  992. package/script/npm/src/store.d.ts.map +0 -1
  993. package/script/npm/src/store.js +0 -480
  994. package/script/npm/src/tasks.d.ts +0 -11
  995. package/script/npm/src/tasks.d.ts.map +0 -1
  996. package/script/npm/src/tasks.js +0 -45
  997. package/script/npm/src/telemetry/carrier.d.ts +0 -9
  998. package/script/npm/src/telemetry/carrier.d.ts.map +0 -1
  999. package/script/npm/src/telemetry/carrier.js +0 -25
  1000. package/script/npm/src/telemetry/core.d.ts +0 -8
  1001. package/script/npm/src/telemetry/core.d.ts.map +0 -1
  1002. package/script/npm/src/telemetry/core.js +0 -24
  1003. package/script/npm/src/telemetry/env.d.ts +0 -2
  1004. package/script/npm/src/telemetry/env.d.ts.map +0 -1
  1005. package/script/npm/src/telemetry/env.js +0 -46
  1006. package/script/npm/src/telemetry/mod.d.ts +0 -10
  1007. package/script/npm/src/telemetry/mod.d.ts.map +0 -1
  1008. package/script/npm/src/telemetry/mod.js +0 -26
  1009. package/script/npm/src/telemetry/nats.d.ts +0 -7
  1010. package/script/npm/src/telemetry/nats.d.ts.map +0 -1
  1011. package/script/npm/src/telemetry/nats.js +0 -9
  1012. package/script/npm/src/telemetry/result.d.ts +0 -2
  1013. package/script/npm/src/telemetry/result.d.ts.map +0 -1
  1014. package/script/npm/src/telemetry/result.js +0 -21
  1015. package/script/npm/src/telemetry/trace.d.ts +0 -5
  1016. package/script/npm/src/telemetry/trace.d.ts.map +0 -1
  1017. package/script/npm/src/telemetry/trace.js +0 -31
  1018. package/script/npm/src/telemetry/trellis.d.ts +0 -2
  1019. package/script/npm/src/telemetry/trellis.d.ts.map +0 -1
  1020. package/script/npm/src/telemetry/trellis.js +0 -7
  1021. package/script/npm/src/tracing.d.ts +0 -5
  1022. package/script/npm/src/tracing.d.ts.map +0 -1
  1023. package/script/npm/src/tracing.js +0 -27
  1024. package/script/npm/src/transfer.d.ts +0 -118
  1025. package/script/npm/src/transfer.d.ts.map +0 -1
  1026. package/script/npm/src/transfer.js +0 -417
  1027. package/script/npm/src/trellis.d.ts +0 -678
  1028. package/script/npm/src/trellis.d.ts.map +0 -1
  1029. package/script/npm/src/trellis.js +0 -2299
  1030. /package/esm/{npm/src/_dnt.polyfills.d.ts → _dnt.polyfills.d.ts} +0 -0
  1031. /package/esm/{npm/src/_dnt.polyfills.js → _dnt.polyfills.js} +0 -0
  1032. /package/esm/{npm/src/_dnt.shims.d.ts → _dnt.shims.d.ts} +0 -0
  1033. /package/esm/{npm/src/_dnt.shims.js → _dnt.shims.js} +0 -0
  1034. /package/esm/{npm/src/browser.d.ts → browser.d.ts} +0 -0
  1035. /package/esm/{npm/src/browser.js → browser.js} +0 -0
  1036. /package/esm/{npm/src/device → device}/deno.d.ts +0 -0
  1037. /package/esm/{npm/src/device → device}/deno.js +0 -0
  1038. /package/esm/{npm/src/env.d.ts → env.d.ts} +0 -0
  1039. /package/esm/{npm/src/env.js → env.js} +0 -0
  1040. /package/esm/{npm/src/generate.d.ts → generate.d.ts} +0 -0
  1041. /package/esm/{npm/src/host → host}/mod.d.ts +0 -0
  1042. /package/esm/{npm/src/host → host}/mod.js +0 -0
  1043. /package/esm/{npm/src/host → host}/node.d.ts +0 -0
  1044. /package/esm/{npm/src/host → host}/node.js +0 -0
  1045. /package/esm/{npm/src/server → server}/health_rpc.js +0 -0
  1046. /package/esm/{npm/src/server → server}/internal_jobs/active-job.d.ts +0 -0
  1047. /package/esm/{npm/src/server → server}/internal_jobs/active-job.js +0 -0
  1048. /package/esm/{npm/src/server → server}/internal_jobs/bindings.d.ts +0 -0
  1049. /package/esm/{npm/src/server → server}/internal_jobs/bindings.js +0 -0
  1050. /package/esm/{npm/src/server → server}/internal_jobs/cancellation-registry.d.ts +0 -0
  1051. /package/esm/{npm/src/server → server}/internal_jobs/cancellation-registry.js +0 -0
  1052. /package/esm/{npm/src/server → server}/internal_jobs/heartbeat.d.ts +0 -0
  1053. /package/esm/{npm/src/server → server}/internal_jobs/heartbeat.js +0 -0
  1054. /package/esm/{npm/src/server → server}/internal_jobs/job-manager.d.ts +0 -0
  1055. /package/esm/{npm/src/server → server}/internal_jobs/job-manager.js +0 -0
  1056. /package/esm/{npm/src/server → server}/internal_jobs/projection.d.ts +0 -0
  1057. /package/esm/{npm/src/server → server}/internal_jobs/projection.js +0 -0
  1058. /package/esm/{npm/src/server → server}/internal_jobs/runtime-worker.d.ts +0 -0
  1059. /package/esm/{npm/src/server → server}/internal_jobs/runtime-worker.js +0 -0
  1060. /package/esm/{npm/src/server → server}/internal_jobs/types.d.ts +0 -0
  1061. /package/esm/{npm/src/server → server}/internal_jobs/types.js +0 -0
  1062. /package/esm/{npm/src/server → server}/runtime.d.ts +0 -0
  1063. /package/esm/{npm/src/server → server}/runtime.js +0 -0
  1064. /package/esm/{npm/src/server → server}/subscription.js +0 -0
  1065. /package/esm/{npm/src/server → server}/transfer.d.ts +0 -0
  1066. /package/esm/{npm/src/server → server}/transfer.js +0 -0
  1067. /package/esm/{npm/src/server.d.ts → server.d.ts} +0 -0
  1068. /package/esm/{npm/src/server.js → server.js} +0 -0
  1069. /package/esm/{npm/src/server_logger.d.ts → server_logger.d.ts} +0 -0
  1070. /package/esm/{npm/src/server_logger.js → server_logger.js} +0 -0
  1071. /package/esm/{npm/src/service → service}/deno.d.ts +0 -0
  1072. /package/esm/{npm/src/service → service}/deno.js +0 -0
  1073. /package/esm/{npm/src/service → service}/mod.d.ts +0 -0
  1074. /package/esm/{npm/src/service → service}/mod.js +0 -0
  1075. /package/esm/{npm/src/service → service}/node.d.ts +0 -0
  1076. /package/esm/{npm/src/service → service}/node.js +0 -0
  1077. /package/esm/{npm/src/service → service}/outbox_inbox.d.ts +0 -0
  1078. /package/esm/{npm/src/service → service}/outbox_inbox.js +0 -0
  1079. /package/script/{npm/src/_dnt.polyfills.d.ts → _dnt.polyfills.d.ts} +0 -0
  1080. /package/script/{npm/src/_dnt.polyfills.js → _dnt.polyfills.js} +0 -0
  1081. /package/script/{npm/src/_dnt.shims.d.ts → _dnt.shims.d.ts} +0 -0
  1082. /package/script/{npm/src/_dnt.shims.js → _dnt.shims.js} +0 -0
  1083. /package/script/{npm/src/browser.d.ts → browser.d.ts} +0 -0
  1084. /package/script/{npm/src/browser.js → browser.js} +0 -0
  1085. /package/script/{npm/src/device → device}/deno.d.ts +0 -0
  1086. /package/script/{npm/src/device → device}/deno.js +0 -0
  1087. /package/script/{npm/src/env.d.ts → env.d.ts} +0 -0
  1088. /package/script/{npm/src/env.js → env.js} +0 -0
  1089. /package/script/{npm/src/generate.d.ts → generate.d.ts} +0 -0
  1090. /package/script/{npm/src/host → host}/mod.d.ts +0 -0
  1091. /package/script/{npm/src/host → host}/mod.js +0 -0
  1092. /package/script/{npm/src/host → host}/node.d.ts +0 -0
  1093. /package/script/{npm/src/host → host}/node.js +0 -0
  1094. /package/script/{npm/src/server → server}/health_rpc.js +0 -0
  1095. /package/script/{npm/src/server → server}/internal_jobs/active-job.d.ts +0 -0
  1096. /package/script/{npm/src/server → server}/internal_jobs/active-job.js +0 -0
  1097. /package/script/{npm/src/server → server}/internal_jobs/bindings.d.ts +0 -0
  1098. /package/script/{npm/src/server → server}/internal_jobs/bindings.js +0 -0
  1099. /package/script/{npm/src/server → server}/internal_jobs/cancellation-registry.d.ts +0 -0
  1100. /package/script/{npm/src/server → server}/internal_jobs/cancellation-registry.js +0 -0
  1101. /package/script/{npm/src/server → server}/internal_jobs/heartbeat.d.ts +0 -0
  1102. /package/script/{npm/src/server → server}/internal_jobs/heartbeat.js +0 -0
  1103. /package/script/{npm/src/server → server}/internal_jobs/job-manager.d.ts +0 -0
  1104. /package/script/{npm/src/server → server}/internal_jobs/job-manager.js +0 -0
  1105. /package/script/{npm/src/server → server}/internal_jobs/projection.d.ts +0 -0
  1106. /package/script/{npm/src/server → server}/internal_jobs/projection.js +0 -0
  1107. /package/script/{npm/src/server → server}/internal_jobs/runtime-worker.d.ts +0 -0
  1108. /package/script/{npm/src/server → server}/internal_jobs/runtime-worker.js +0 -0
  1109. /package/script/{npm/src/server → server}/internal_jobs/types.d.ts +0 -0
  1110. /package/script/{npm/src/server → server}/internal_jobs/types.js +0 -0
  1111. /package/script/{npm/src/server → server}/runtime.d.ts +0 -0
  1112. /package/script/{npm/src/server → server}/runtime.js +0 -0
  1113. /package/script/{npm/src/server → server}/subscription.js +0 -0
  1114. /package/script/{npm/src/server → server}/transfer.d.ts +0 -0
  1115. /package/script/{npm/src/server → server}/transfer.js +0 -0
  1116. /package/script/{npm/src/server.d.ts → server.d.ts} +0 -0
  1117. /package/script/{npm/src/server.js → server.js} +0 -0
  1118. /package/script/{npm/src/server_logger.d.ts → server_logger.d.ts} +0 -0
  1119. /package/script/{npm/src/server_logger.js → server_logger.js} +0 -0
  1120. /package/script/{npm/src/service → service}/deno.d.ts +0 -0
  1121. /package/script/{npm/src/service → service}/deno.js +0 -0
  1122. /package/script/{npm/src/service → service}/mod.d.ts +0 -0
  1123. /package/script/{npm/src/service → service}/mod.js +0 -0
  1124. /package/script/{npm/src/service → service}/node.d.ts +0 -0
  1125. /package/script/{npm/src/service → service}/node.js +0 -0
  1126. /package/script/{npm/src/service → service}/outbox_inbox.d.ts +0 -0
  1127. /package/script/{npm/src/service → service}/outbox_inbox.js +0 -0
@@ -1,2225 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.unwrapSchema = exports.schema = exports.isJsonValue = exports.digestJson = exports.canonicalizeJson = exports.CONTRACT_STATE_METADATA = exports.CONTRACT_KV_METADATA = exports.CONTRACT_JOBS_METADATA = exports.TrellisCatalogV1Schema = exports.TrellisContractV1Schema = exports.ContractUsesSchema = exports.ContractExportsSchema = exports.ContractCapabilitiesSchema = exports.ContractCapabilityMetadataSchema = exports.ContractDocsSchema = exports.CATALOG_FORMAT_V1 = exports.CONTRACT_FORMAT_V1 = exports.StoreResourceBindingSchema = exports.PageResponseSchema = exports.PageRequestSchema = exports.KvResourceBindingSchema = exports.JobsResourceBindingSchema = exports.JobsQueueBindingSchema = exports.IsoDateSchema = exports.InstalledServiceContractSchema = exports.EventHeaderSchema = exports.EventConsumerResourceBindingSchema = exports.ContractStoreResourceSchema = exports.ContractStateStoreSchema = exports.ContractStateSchema = exports.ContractSchemaRefSchema = exports.ContractResourcesSchema = exports.ContractResourceBindingsSchema = exports.ContractKvResourceSchema = exports.ContractJobsSchema = exports.ContractJobQueueSchema = exports.ContractEventConsumersSchema = exports.ContractEventConsumerGroupSchema = exports.ContractEventConsumerEventSchema = void 0;
7
- exports.contractCapabilityNamespace = contractCapabilityNamespace;
8
- exports.globalCapabilityName = globalCapabilityName;
9
- exports.normalizeContractManifest = normalizeContractManifest;
10
- exports.parseContractManifest = parseContractManifest;
11
- exports.projectContractDigestManifest = projectContractDigestManifest;
12
- exports.digestContractManifest = digestContractManifest;
13
- exports.defineError = defineError;
14
- exports.defineServiceContract = defineServiceContract;
15
- exports.defineAppContract = defineAppContract;
16
- exports.defineAgentContract = defineAgentContract;
17
- exports.defineDeviceContract = defineDeviceContract;
18
- const typebox_1 = __importDefault(require("typebox"));
19
- const value_1 = require("typebox/value");
20
- const TrellisError_js_1 = require("../errors/TrellisError.js");
21
- const canonical_js_1 = require("./canonical.js");
22
- Object.defineProperty(exports, "canonicalizeJson", { enumerable: true, get: function () { return canonical_js_1.canonicalizeJson; } });
23
- Object.defineProperty(exports, "digestJson", { enumerable: true, get: function () { return canonical_js_1.digestJson; } });
24
- Object.defineProperty(exports, "isJsonValue", { enumerable: true, get: function () { return canonical_js_1.isJsonValue; } });
25
- const runtime_js_1 = require("./runtime.js");
26
- Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return runtime_js_1.schema; } });
27
- Object.defineProperty(exports, "unwrapSchema", { enumerable: true, get: function () { return runtime_js_1.unwrapSchema; } });
28
- const schema_pointers_js_1 = require("./schema_pointers.js");
29
- const protocol_js_1 = require("./protocol.js");
30
- var protocol_js_2 = require("./protocol.js");
31
- Object.defineProperty(exports, "ContractEventConsumerEventSchema", { enumerable: true, get: function () { return protocol_js_2.ContractEventConsumerEventSchema; } });
32
- Object.defineProperty(exports, "ContractEventConsumerGroupSchema", { enumerable: true, get: function () { return protocol_js_2.ContractEventConsumerGroupSchema; } });
33
- Object.defineProperty(exports, "ContractEventConsumersSchema", { enumerable: true, get: function () { return protocol_js_2.ContractEventConsumersSchema; } });
34
- Object.defineProperty(exports, "ContractJobQueueSchema", { enumerable: true, get: function () { return protocol_js_2.ContractJobQueueSchema; } });
35
- Object.defineProperty(exports, "ContractJobsSchema", { enumerable: true, get: function () { return protocol_js_2.ContractJobsSchema; } });
36
- Object.defineProperty(exports, "ContractKvResourceSchema", { enumerable: true, get: function () { return protocol_js_2.ContractKvResourceSchema; } });
37
- Object.defineProperty(exports, "ContractResourceBindingsSchema", { enumerable: true, get: function () { return protocol_js_2.ContractResourceBindingsSchema; } });
38
- Object.defineProperty(exports, "ContractResourcesSchema", { enumerable: true, get: function () { return protocol_js_2.ContractResourcesSchema; } });
39
- Object.defineProperty(exports, "ContractSchemaRefSchema", { enumerable: true, get: function () { return protocol_js_2.ContractSchemaRefSchema; } });
40
- Object.defineProperty(exports, "ContractStateSchema", { enumerable: true, get: function () { return protocol_js_2.ContractStateSchema; } });
41
- Object.defineProperty(exports, "ContractStateStoreSchema", { enumerable: true, get: function () { return protocol_js_2.ContractStateStoreSchema; } });
42
- Object.defineProperty(exports, "ContractStoreResourceSchema", { enumerable: true, get: function () { return protocol_js_2.ContractStoreResourceSchema; } });
43
- Object.defineProperty(exports, "EventConsumerResourceBindingSchema", { enumerable: true, get: function () { return protocol_js_2.EventConsumerResourceBindingSchema; } });
44
- Object.defineProperty(exports, "EventHeaderSchema", { enumerable: true, get: function () { return protocol_js_2.EventHeaderSchema; } });
45
- Object.defineProperty(exports, "InstalledServiceContractSchema", { enumerable: true, get: function () { return protocol_js_2.InstalledServiceContractSchema; } });
46
- Object.defineProperty(exports, "IsoDateSchema", { enumerable: true, get: function () { return protocol_js_2.IsoDateSchema; } });
47
- Object.defineProperty(exports, "JobsQueueBindingSchema", { enumerable: true, get: function () { return protocol_js_2.JobsQueueBindingSchema; } });
48
- Object.defineProperty(exports, "JobsResourceBindingSchema", { enumerable: true, get: function () { return protocol_js_2.JobsResourceBindingSchema; } });
49
- Object.defineProperty(exports, "KvResourceBindingSchema", { enumerable: true, get: function () { return protocol_js_2.KvResourceBindingSchema; } });
50
- Object.defineProperty(exports, "PageRequestSchema", { enumerable: true, get: function () { return protocol_js_2.PageRequestSchema; } });
51
- Object.defineProperty(exports, "PageResponseSchema", { enumerable: true, get: function () { return protocol_js_2.PageResponseSchema; } });
52
- Object.defineProperty(exports, "StoreResourceBindingSchema", { enumerable: true, get: function () { return protocol_js_2.StoreResourceBindingSchema; } });
53
- exports.CONTRACT_FORMAT_V1 = "trellis.contract.v1";
54
- exports.CATALOG_FORMAT_V1 = "trellis.catalog.v1";
55
- const NonEmptyStringSchema = typebox_1.default.String({ minLength: 1 });
56
- const VersionSchema = typebox_1.default.String({ pattern: "^v[0-9]+$" });
57
- const PointerStringSchema = typebox_1.default.String({ pattern: "^/.*" });
58
- const CapabilityListSchema = typebox_1.default.Array(NonEmptyStringSchema);
59
- const JsonSchemaValueSchema = typebox_1.default.Union([
60
- typebox_1.default.Object({}, { additionalProperties: true }),
61
- typebox_1.default.Boolean(),
62
- ]);
63
- exports.ContractDocsSchema = typebox_1.default.Object({
64
- summary: typebox_1.default.Optional(typebox_1.default.String()),
65
- markdown: typebox_1.default.String(),
66
- });
67
- exports.ContractCapabilityMetadataSchema = typebox_1.default.Object({
68
- displayName: NonEmptyStringSchema,
69
- description: NonEmptyStringSchema,
70
- consequence: typebox_1.default.Optional(NonEmptyStringSchema),
71
- });
72
- exports.ContractCapabilitiesSchema = typebox_1.default.Record(NonEmptyStringSchema, exports.ContractCapabilityMetadataSchema);
73
- exports.ContractExportsSchema = typebox_1.default.Object({
74
- schemas: typebox_1.default.Optional(typebox_1.default.Array(NonEmptyStringSchema, { uniqueItems: true })),
75
- });
76
- const ContractUseRpcSchema = typebox_1.default.Object({
77
- call: typebox_1.default.Optional(CapabilityListSchema),
78
- });
79
- const ContractUsePubSubSchema = typebox_1.default.Object({
80
- publish: typebox_1.default.Optional(CapabilityListSchema),
81
- subscribe: typebox_1.default.Optional(CapabilityListSchema),
82
- });
83
- const ContractUseFeedSchema = typebox_1.default.Object({
84
- subscribe: typebox_1.default.Optional(CapabilityListSchema),
85
- });
86
- const ContractUseSchema = typebox_1.default.Object({
87
- contract: NonEmptyStringSchema,
88
- rpc: typebox_1.default.Optional(ContractUseRpcSchema),
89
- operations: typebox_1.default.Optional(ContractUseRpcSchema),
90
- events: typebox_1.default.Optional(ContractUsePubSubSchema),
91
- feeds: typebox_1.default.Optional(ContractUseFeedSchema),
92
- });
93
- const ContractUsesFlatSchema = typebox_1.default.Record(NonEmptyStringSchema, ContractUseSchema);
94
- exports.ContractUsesSchema = typebox_1.default.Object({
95
- required: typebox_1.default.Optional(ContractUsesFlatSchema),
96
- optional: typebox_1.default.Optional(ContractUsesFlatSchema),
97
- });
98
- const ContractErrorDeclSchema = typebox_1.default.Object({
99
- type: NonEmptyStringSchema,
100
- schema: typebox_1.default.Optional(protocol_js_1.ContractSchemaRefSchema),
101
- });
102
- const ContractErrorRefSchema = typebox_1.default.Object({
103
- type: NonEmptyStringSchema,
104
- });
105
- const ContractOperationSignalSchema = typebox_1.default.Object({
106
- input: protocol_js_1.ContractSchemaRefSchema,
107
- docs: typebox_1.default.Optional(exports.ContractDocsSchema),
108
- });
109
- const RpcCapabilitiesSchema = typebox_1.default.Object({
110
- call: typebox_1.default.Optional(CapabilityListSchema),
111
- });
112
- const OperationCapabilitiesSchema = typebox_1.default.Object({
113
- call: typebox_1.default.Optional(CapabilityListSchema),
114
- observe: typebox_1.default.Optional(CapabilityListSchema),
115
- cancel: typebox_1.default.Optional(CapabilityListSchema),
116
- control: typebox_1.default.Optional(CapabilityListSchema),
117
- });
118
- const PubSubCapabilitiesSchema = typebox_1.default.Object({
119
- publish: typebox_1.default.Optional(CapabilityListSchema),
120
- subscribe: typebox_1.default.Optional(CapabilityListSchema),
121
- });
122
- const FeedCapabilitiesSchema = typebox_1.default.Object({
123
- subscribe: typebox_1.default.Optional(CapabilityListSchema),
124
- });
125
- const RpcTransferSchema = typebox_1.default.Object({
126
- direction: typebox_1.default.Literal("receive"),
127
- });
128
- const OperationTransferSchema = typebox_1.default.Object({
129
- direction: typebox_1.default.Literal("send"),
130
- store: NonEmptyStringSchema,
131
- key: PointerStringSchema,
132
- contentType: typebox_1.default.Optional(PointerStringSchema),
133
- metadata: typebox_1.default.Optional(PointerStringSchema),
134
- expiresInMs: typebox_1.default.Optional(typebox_1.default.Integer({ minimum: 1 })),
135
- maxBytes: typebox_1.default.Optional(typebox_1.default.Integer({ minimum: 1 })),
136
- });
137
- const ContractRpcMethodSchema = typebox_1.default.Object({
138
- version: VersionSchema,
139
- subject: NonEmptyStringSchema,
140
- input: protocol_js_1.ContractSchemaRefSchema,
141
- output: protocol_js_1.ContractSchemaRefSchema,
142
- capabilities: typebox_1.default.Optional(RpcCapabilitiesSchema),
143
- errors: typebox_1.default.Optional(typebox_1.default.Array(ContractErrorRefSchema)),
144
- transfer: typebox_1.default.Optional(RpcTransferSchema),
145
- internal: typebox_1.default.Optional(typebox_1.default.Boolean()),
146
- docs: typebox_1.default.Optional(exports.ContractDocsSchema),
147
- });
148
- const ContractOperationSchema = typebox_1.default.Object({
149
- version: VersionSchema,
150
- subject: NonEmptyStringSchema,
151
- input: protocol_js_1.ContractSchemaRefSchema,
152
- progress: typebox_1.default.Optional(protocol_js_1.ContractSchemaRefSchema),
153
- output: protocol_js_1.ContractSchemaRefSchema,
154
- transfer: typebox_1.default.Optional(OperationTransferSchema),
155
- capabilities: typebox_1.default.Optional(OperationCapabilitiesSchema),
156
- signals: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, ContractOperationSignalSchema)),
157
- cancel: typebox_1.default.Optional(typebox_1.default.Boolean()),
158
- docs: typebox_1.default.Optional(exports.ContractDocsSchema),
159
- });
160
- const ContractEventSchema = typebox_1.default.Object({
161
- version: VersionSchema,
162
- subject: NonEmptyStringSchema,
163
- params: typebox_1.default.Optional(typebox_1.default.Array(PointerStringSchema)),
164
- event: protocol_js_1.ContractSchemaRefSchema,
165
- capabilities: typebox_1.default.Optional(PubSubCapabilitiesSchema),
166
- docs: typebox_1.default.Optional(exports.ContractDocsSchema),
167
- });
168
- const ContractFeedSchema = typebox_1.default.Object({
169
- version: VersionSchema,
170
- subject: NonEmptyStringSchema,
171
- input: protocol_js_1.ContractSchemaRefSchema,
172
- event: protocol_js_1.ContractSchemaRefSchema,
173
- capabilities: typebox_1.default.Optional(FeedCapabilitiesSchema),
174
- docs: typebox_1.default.Optional(exports.ContractDocsSchema),
175
- });
176
- exports.TrellisContractV1Schema = typebox_1.default.Object({
177
- format: typebox_1.default.Literal(exports.CONTRACT_FORMAT_V1),
178
- id: NonEmptyStringSchema,
179
- displayName: NonEmptyStringSchema,
180
- description: NonEmptyStringSchema,
181
- docs: typebox_1.default.Optional(exports.ContractDocsSchema),
182
- kind: typebox_1.default.Union([
183
- typebox_1.default.Literal("service"),
184
- typebox_1.default.Literal("app"),
185
- typebox_1.default.Literal("device"),
186
- typebox_1.default.Literal("agent"),
187
- ]),
188
- capabilities: typebox_1.default.Optional(exports.ContractCapabilitiesSchema),
189
- schemas: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, JsonSchemaValueSchema)),
190
- exports: typebox_1.default.Optional(exports.ContractExportsSchema),
191
- uses: typebox_1.default.Optional(exports.ContractUsesSchema),
192
- state: typebox_1.default.Optional(protocol_js_1.ContractStateSchema),
193
- rpc: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, ContractRpcMethodSchema)),
194
- operations: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, ContractOperationSchema)),
195
- events: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, ContractEventSchema)),
196
- feeds: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, ContractFeedSchema)),
197
- errors: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, ContractErrorDeclSchema)),
198
- jobs: typebox_1.default.Optional(typebox_1.default.Record(NonEmptyStringSchema, protocol_js_1.ContractJobQueueSchema)),
199
- eventConsumers: typebox_1.default.Optional(protocol_js_1.ContractEventConsumersSchema),
200
- resources: typebox_1.default.Optional(protocol_js_1.ContractResourcesSchema),
201
- });
202
- exports.TrellisCatalogV1Schema = typebox_1.default.Object({
203
- format: typebox_1.default.Literal(exports.CATALOG_FORMAT_V1),
204
- contracts: typebox_1.default.Array(typebox_1.default.Object({
205
- id: NonEmptyStringSchema,
206
- digest: typebox_1.default.String({ pattern: "^[A-Za-z0-9_-]+$" }),
207
- displayName: NonEmptyStringSchema,
208
- description: NonEmptyStringSchema,
209
- })),
210
- });
211
- const CONTRACT_MODULE_METADATA = Symbol.for("@qlever-llc/trellis/contracts/contract-module");
212
- exports.CONTRACT_JOBS_METADATA = Symbol.for("@qlever-llc/trellis/contracts/jobs");
213
- exports.CONTRACT_KV_METADATA = Symbol.for("@qlever-llc/trellis/contracts/kv");
214
- exports.CONTRACT_STATE_METADATA = Symbol.for("@qlever-llc/trellis/contracts/state");
215
- const CONTRACT_ERROR_RUNTIME_METADATA = Symbol.for("@qlever-llc/trellis/contracts/error-runtime");
216
- const RESERVED_DEFINED_ERROR_FIELD_NAMES = new Set([
217
- "id",
218
- "type",
219
- "message",
220
- "context",
221
- "traceId",
222
- "cause",
223
- ]);
224
- const DEFINED_ERROR_PAYLOAD = Symbol.for("@qlever-llc/trellis/contracts/defined-error-payload");
225
- function createSchemaRef(_schemas) {
226
- void _schemas;
227
- return (schemaName) => ({ schema: schemaName });
228
- }
229
- function getContractErrorType(errorClass) {
230
- const explicitType = Reflect.get(errorClass, "type");
231
- return typeof explicitType === "string" ? explicitType : errorClass.name;
232
- }
233
- function isSerializableErrorData(value) {
234
- return !!value && typeof value === "object" &&
235
- typeof value.id === "string" &&
236
- typeof value.type === "string" &&
237
- typeof value.message === "string";
238
- }
239
- function isErrorClass(value) {
240
- return typeof value === "function" &&
241
- typeof Reflect.get(value, "name") === "string" &&
242
- typeof Reflect.get(value, "fromSerializable") === "function" &&
243
- typeof Reflect.get(value, "schema") === "object";
244
- }
245
- function assertNoReservedDefinedErrorFieldNames(fields) {
246
- for (const fieldName of Object.keys(fields)) {
247
- if (RESERVED_DEFINED_ERROR_FIELD_NAMES.has(fieldName)) {
248
- throw new Error(`Defined error field '${fieldName}' is reserved`);
249
- }
250
- }
251
- }
252
- function createDefinedErrorSchema(type, fields) {
253
- return typebox_1.default.Object({
254
- id: typebox_1.default.String(),
255
- type: typebox_1.default.Literal(type),
256
- message: typebox_1.default.String(),
257
- ...fields,
258
- context: typebox_1.default.Optional(typebox_1.default.Record(typebox_1.default.String(), typebox_1.default.Unknown())),
259
- traceId: typebox_1.default.Optional(typebox_1.default.String()),
260
- });
261
- }
262
- function definedErrorPayloadFieldNames(fields) {
263
- return Object.keys(fields);
264
- }
265
- function pickDefinedErrorPayload(fieldNames, source) {
266
- return Object.fromEntries(fieldNames.map((fieldName) => [fieldName, source[fieldName]]));
267
- }
268
- function definedErrorBaseOptions(options) {
269
- const baseOptions = {};
270
- if (options.cause !== undefined) {
271
- baseOptions.cause = options.cause;
272
- }
273
- if (options.context !== undefined) {
274
- baseOptions.context = options.context;
275
- }
276
- if (options.id !== undefined) {
277
- baseOptions.id = options.id;
278
- }
279
- if (options.traceId !== undefined) {
280
- baseOptions.traceId = options.traceId;
281
- }
282
- return baseOptions;
283
- }
284
- function attachDefinedErrorPayload(error, payload) {
285
- error[DEFINED_ERROR_PAYLOAD] = payload;
286
- return Object.assign(error, payload);
287
- }
288
- const TRELLIS_AUTH_CONTRACT_ID = "trellis.auth@v1";
289
- const TRELLIS_STATE_CONTRACT_ID = "trellis.state@v1";
290
- const TRELLIS_HEALTH_CONTRACT_ID = "trellis.health@v1";
291
- const BASELINE_AUTH_RPC_CALL = [
292
- "Auth.Sessions.Me",
293
- "Auth.Sessions.Logout",
294
- ];
295
- const BASELINE_STATE_RPC_CALL = [
296
- "State.Get",
297
- "State.Put",
298
- "State.Delete",
299
- "State.List",
300
- ];
301
- const BASELINE_HEALTH_EVENTS_PUBLISH = ["Health.Heartbeat"];
302
- const UnknownRuntimeSchema = (0, runtime_js_1.schema)(typebox_1.default.Unknown());
303
- function typedUnknownRuntimeSchema() {
304
- return UnknownRuntimeSchema;
305
- }
306
- function trellisRpcDesc(name) {
307
- return {
308
- subject: rpcSubject(name, "v1"),
309
- input: typedUnknownRuntimeSchema(),
310
- output: typedUnknownRuntimeSchema(),
311
- callerCapabilities: [],
312
- };
313
- }
314
- function trellisEventDesc(name) {
315
- return {
316
- subject: eventSubject(name, "v1", undefined),
317
- event: typedUnknownRuntimeSchema(),
318
- publishCapabilities: [],
319
- subscribeCapabilities: [],
320
- };
321
- }
322
- const BASELINE_AUTH_API = {
323
- rpc: {
324
- "Auth.Sessions.Me": trellisRpcDesc("Auth.Sessions.Me"),
325
- "Auth.Sessions.Logout": trellisRpcDesc("Auth.Sessions.Logout"),
326
- },
327
- operations: {},
328
- events: {},
329
- feeds: {},
330
- subjects: {},
331
- };
332
- const BASELINE_STATE_API = {
333
- rpc: {
334
- "State.Get": trellisRpcDesc("State.Get"),
335
- "State.Put": trellisRpcDesc("State.Put"),
336
- "State.Delete": trellisRpcDesc("State.Delete"),
337
- "State.List": trellisRpcDesc("State.List"),
338
- },
339
- operations: {},
340
- events: {},
341
- feeds: {},
342
- subjects: {},
343
- };
344
- const BASELINE_HEALTH_API = {
345
- rpc: {},
346
- operations: {},
347
- events: {
348
- "Health.Heartbeat": trellisEventDesc("Health.Heartbeat"),
349
- },
350
- feeds: {},
351
- subjects: {},
352
- };
353
- function createContractRefBuilder(registry) {
354
- const schemaRef = registry.schemas
355
- ? createSchemaRef(registry.schemas)
356
- : undefined;
357
- return {
358
- schema(schemaName) {
359
- if (!schemaRef) {
360
- throw new Error(`Contract builder ref.schema('${schemaName}') requires a schemas registry`);
361
- }
362
- return schemaRef(schemaName);
363
- },
364
- error(errorName) {
365
- return errorName;
366
- },
367
- capability(capabilityName) {
368
- return capabilityName;
369
- },
370
- };
371
- }
372
- function cloneSchema(schemaValue) {
373
- const cloned = JSON.parse(JSON.stringify(schemaValue));
374
- if (!(0, canonical_js_1.isJsonValue)(cloned)) {
375
- throw new Error("Contract schema is not JSON-serializable");
376
- }
377
- return cloned;
378
- }
379
- function cloneSchemas(schemas) {
380
- if (!schemas) {
381
- return undefined;
382
- }
383
- return Object.fromEntries(Object.entries(schemas).map(([name, schemaValue]) => [name, cloneSchema(schemaValue)]));
384
- }
385
- function cloneContractExports(contractExports) {
386
- if (!contractExports) {
387
- return undefined;
388
- }
389
- return {
390
- ...(contractExports.schemas
391
- ? { schemas: [...contractExports.schemas] }
392
- : {}),
393
- };
394
- }
395
- function getErrorRuntimeSchema(errorDecl) {
396
- const errorClass = getContractErrorRuntimeClass(errorDecl);
397
- const runtimeSchema = errorClass
398
- ? Reflect.get(errorClass, "schema")
399
- : undefined;
400
- if (!runtimeSchema || typeof runtimeSchema !== "object") {
401
- return undefined;
402
- }
403
- return runtimeSchema;
404
- }
405
- function createContractErrorDecl(errorClass) {
406
- const errorDecl = {
407
- type: getContractErrorType(errorClass),
408
- };
409
- return attachContractErrorRuntimeMetadata(errorDecl, errorClass);
410
- }
411
- function normalizeErrorRegistry(errors) {
412
- if (!errors) {
413
- return undefined;
414
- }
415
- const normalizedEntries = Object.entries(errors).flatMap(([key, value]) => isErrorClass(value) ? [[key, createContractErrorDecl(value)]] : []);
416
- if (normalizedEntries.length === 0) {
417
- return undefined;
418
- }
419
- return Object.fromEntries(normalizedEntries);
420
- }
421
- function getErrorClassRegistry(errors) {
422
- if (!errors) {
423
- return undefined;
424
- }
425
- const classEntries = Object.entries(errors).flatMap(([key, value]) => isErrorClass(value) ? [[key, value]] : []);
426
- if (classEntries.length === 0) {
427
- return undefined;
428
- }
429
- return Object.fromEntries(classEntries);
430
- }
431
- function findMatchingSchemaName(schemas, targetSchema) {
432
- if (!schemas) {
433
- return undefined;
434
- }
435
- const targetDigest = digestCanonicalJson(cloneSchema(targetSchema));
436
- for (const [schemaName, schemaValue] of Object.entries(schemas)) {
437
- if (schemaValue === targetSchema) {
438
- return schemaName;
439
- }
440
- if (digestCanonicalJson(cloneSchema(schemaValue)) === targetDigest) {
441
- return schemaName;
442
- }
443
- }
444
- return undefined;
445
- }
446
- function chooseDerivedErrorSchemaName(schemas, errorName, errorType) {
447
- const baseNames = [`${errorType}Data`, `${errorName}Data`];
448
- for (const baseName of baseNames) {
449
- if (!Object.hasOwn(schemas, baseName)) {
450
- return baseName;
451
- }
452
- }
453
- let suffix = 2;
454
- while (true) {
455
- const candidate = `${errorType}Data${suffix}`;
456
- if (!Object.hasOwn(schemas, candidate)) {
457
- return candidate;
458
- }
459
- suffix += 1;
460
- }
461
- }
462
- function materializeErrorSchemas(schemas, errors) {
463
- if (!errors) {
464
- return schemas;
465
- }
466
- let mergedSchemas = schemas;
467
- for (const [errorName, errorDecl] of Object.entries(errors)) {
468
- if (errorDecl.schema) {
469
- continue;
470
- }
471
- const runtimeSchema = getErrorRuntimeSchema(errorDecl);
472
- if (!runtimeSchema) {
473
- continue;
474
- }
475
- if (findMatchingSchemaName(mergedSchemas, runtimeSchema)) {
476
- continue;
477
- }
478
- mergedSchemas = { ...(mergedSchemas ?? {}) };
479
- const derivedSchemaName = chooseDerivedErrorSchemaName(mergedSchemas, errorName, errorDecl.type);
480
- mergedSchemas[derivedSchemaName] = runtimeSchema;
481
- }
482
- return mergedSchemas;
483
- }
484
- function assertSchemaRefExists(schemas, ref, context) {
485
- if (!schemas || !Object.hasOwn(schemas, ref.schema)) {
486
- throw new Error(`${context} references unknown schema '${ref.schema}'`);
487
- }
488
- }
489
- function assertExportedSchemasExist(schemas, contractExports) {
490
- for (const schemaName of contractExports?.schemas ?? []) {
491
- if (!schemas || !Object.hasOwn(schemas, schemaName)) {
492
- throw new Error(`contract exports reference unknown schema '${schemaName}'`);
493
- }
494
- }
495
- }
496
- function assertRegistryDoesNotDeclareExports(registry) {
497
- if (Object.hasOwn(registry, "exports")) {
498
- throw new Error("contract exports must be declared in the callback body, not the registry argument");
499
- }
500
- }
501
- function assertRegistryDoesNotDeclareCapabilities(registry) {
502
- if (Object.hasOwn(registry, "capabilities")) {
503
- throw new Error("contract capabilities must be declared in the callback body, not the registry argument");
504
- }
505
- }
506
- function resolveSchemaRef(schemas, ref, context) {
507
- assertSchemaRefExists(schemas, ref, context);
508
- const schema = schemas?.[ref.schema];
509
- if (!schema) {
510
- throw new Error(`${context} references missing schema '${ref.schema}'`);
511
- }
512
- return cloneSchema(schema);
513
- }
514
- function digestCanonicalJson(value) {
515
- return (0, canonical_js_1.sha256Base64urlSync)((0, canonical_js_1.canonicalizeJson)(value));
516
- }
517
- function sortedUnique(values) {
518
- return [...new Set(values)].sort();
519
- }
520
- /** Return the global capability namespace for a contract id. */
521
- function contractCapabilityNamespace(contractId) {
522
- return contractId.replace(/@v\d+$/, "");
523
- }
524
- /** Return the globally qualified name for a contract-local capability. */
525
- function globalCapabilityName(contractId, localCapability) {
526
- assertLocalCapabilityDoesNotDuplicateNamespace(contractId, localCapability);
527
- return `${contractCapabilityNamespace(contractId)}::${localCapability}`;
528
- }
529
- function assertLocalCapabilityDoesNotDuplicateNamespace(contractId, localCapability) {
530
- for (const prefix of localCapabilityNamespacePrefixes(contractId)) {
531
- if (localCapability.startsWith(prefix)) {
532
- throw new Error(`local capability '${localCapability}' must not start with contract namespace prefix '${prefix}'`);
533
- }
534
- }
535
- }
536
- function localCapabilityNamespacePrefixes(contractId) {
537
- const namespace = contractCapabilityNamespace(contractId);
538
- const prefixes = [`${namespace}.`];
539
- const namespaceSegments = namespace.split(".");
540
- const leaf = namespaceSegments[namespaceSegments.length - 1];
541
- if (leaf && leaf !== namespace)
542
- prefixes.push(`${leaf}.`);
543
- return prefixes;
544
- }
545
- function projectCapabilities(capabilities, contractId, declaredCapabilities, context) {
546
- if (!capabilities) {
547
- return undefined;
548
- }
549
- return sortedUnique(capabilities.map((capability) => {
550
- if (declaredCapabilities && Object.hasOwn(declaredCapabilities, capability)) {
551
- return globalCapabilityName(contractId, capability);
552
- }
553
- if (capability === "admin" || capability === "service" ||
554
- capability.includes("::")) {
555
- return capability;
556
- }
557
- throw new Error(`${context} references undeclared local capability '${capability}'`);
558
- }));
559
- }
560
- function emitCapabilities(contractId, capabilities) {
561
- if (!capabilities) {
562
- return undefined;
563
- }
564
- const entries = Object.entries(capabilities)
565
- .map(([localCapability, metadata]) => [
566
- globalCapabilityName(contractId, localCapability),
567
- { ...metadata },
568
- ]);
569
- entries.sort(([left], [right]) => left.localeCompare(right));
570
- return Object.fromEntries(entries);
571
- }
572
- function collectSchemaRef(reachableSchemas, ref) {
573
- if (ref) {
574
- reachableSchemas.add(ref.schema);
575
- }
576
- }
577
- function collectReachableSchemaNames(contract) {
578
- const reachableSchemas = new Set();
579
- for (const store of Object.values(contract.state ?? {})) {
580
- collectSchemaRef(reachableSchemas, store.schema);
581
- for (const accepted of Object.values(store.acceptedVersions ?? {})) {
582
- collectSchemaRef(reachableSchemas, accepted);
583
- }
584
- }
585
- for (const method of Object.values(contract.rpc ?? {})) {
586
- collectSchemaRef(reachableSchemas, method.input);
587
- collectSchemaRef(reachableSchemas, method.output);
588
- for (const error of method.errors ?? []) {
589
- const declaration = Object.values(contract.errors ?? {}).find((decl) => decl.type === error.type);
590
- collectSchemaRef(reachableSchemas, declaration?.schema);
591
- }
592
- }
593
- for (const operation of Object.values(contract.operations ?? {})) {
594
- collectSchemaRef(reachableSchemas, operation.input);
595
- collectSchemaRef(reachableSchemas, operation.progress);
596
- collectSchemaRef(reachableSchemas, operation.output);
597
- for (const signal of Object.values(operation.signals ?? {})) {
598
- collectSchemaRef(reachableSchemas, signal.input);
599
- }
600
- }
601
- for (const event of Object.values(contract.events ?? {})) {
602
- collectSchemaRef(reachableSchemas, event.event);
603
- }
604
- for (const feed of Object.values(contract.feeds ?? {})) {
605
- collectSchemaRef(reachableSchemas, feed.input);
606
- collectSchemaRef(reachableSchemas, feed.event);
607
- }
608
- for (const job of Object.values(contract.jobs ?? {})) {
609
- collectSchemaRef(reachableSchemas, job.payload);
610
- collectSchemaRef(reachableSchemas, job.result);
611
- }
612
- for (const resource of Object.values(contract.resources?.kv ?? {})) {
613
- collectSchemaRef(reachableSchemas, resource.schema);
614
- }
615
- return reachableSchemas;
616
- }
617
- function projectReachableSchemas(contract) {
618
- const reachableNames = collectReachableSchemaNames(contract);
619
- if (!contract.schemas || reachableNames.size === 0) {
620
- return undefined;
621
- }
622
- const entries = Object.entries(contract.schemas).filter(([name]) => reachableNames.has(name));
623
- return entries.length > 0 ? Object.fromEntries(entries) : undefined;
624
- }
625
- function projectRpcDeclaredErrors(contract) {
626
- if (!contract.errors) {
627
- return undefined;
628
- }
629
- const declaredErrorTypes = new Set();
630
- for (const method of Object.values(contract.rpc ?? {})) {
631
- for (const error of method.errors ?? []) {
632
- declaredErrorTypes.add(error.type);
633
- }
634
- }
635
- const entries = Object.entries(contract.errors).filter(([, error]) => declaredErrorTypes.has(error.type));
636
- return entries.length > 0 ? Object.fromEntries(entries) : undefined;
637
- }
638
- function projectDigestResources(resources) {
639
- if (!resources?.kv && !resources?.store) {
640
- return undefined;
641
- }
642
- return {
643
- ...(resources.kv
644
- ? {
645
- kv: mapValues(resources.kv, omitDocs),
646
- }
647
- : {}),
648
- ...(resources.store
649
- ? {
650
- store: mapValues(resources.store, omitDocs),
651
- }
652
- : {}),
653
- };
654
- }
655
- function projectDigestState(state) {
656
- return state ? mapValues(state, omitDocs) : undefined;
657
- }
658
- function projectDigestJobs(jobs) {
659
- return jobs ? mapValues(jobs, omitDocs) : undefined;
660
- }
661
- function projectDigestEventConsumers(eventConsumers) {
662
- return eventConsumers ? mapValues(eventConsumers, omitDocs) : undefined;
663
- }
664
- function projectDigestUsesFlat(uses) {
665
- if (!uses) {
666
- return undefined;
667
- }
668
- return Object.fromEntries(Object.entries(uses).map(([alias, use]) => [
669
- alias,
670
- {
671
- contract: use.contract,
672
- ...(use.rpc?.call ? { rpc: { call: sortedUnique(use.rpc.call) } } : {}),
673
- ...(use.operations?.call
674
- ? { operations: { call: sortedUnique(use.operations.call) } }
675
- : {}),
676
- ...((use.events?.publish || use.events?.subscribe)
677
- ? {
678
- events: {
679
- ...(use.events.publish
680
- ? { publish: sortedUnique(use.events.publish) }
681
- : {}),
682
- ...(use.events.subscribe
683
- ? { subscribe: sortedUnique(use.events.subscribe) }
684
- : {}),
685
- },
686
- }
687
- : {}),
688
- ...(use.feeds?.subscribe
689
- ? { feeds: { subscribe: sortedUnique(use.feeds.subscribe) } }
690
- : {}),
691
- },
692
- ]));
693
- }
694
- function omitRequiredUseAliases(optional, required) {
695
- if (!optional) {
696
- return undefined;
697
- }
698
- if (!required) {
699
- return optional;
700
- }
701
- const requiredAliases = new Set(Object.keys(required));
702
- const entries = Object.entries(optional).filter(([alias]) => !requiredAliases.has(alias));
703
- return entries.length > 0 ? Object.fromEntries(entries) : undefined;
704
- }
705
- function projectDigestUses(uses) {
706
- if (!uses) {
707
- return undefined;
708
- }
709
- const required = projectDigestUsesFlat(uses.required);
710
- const optional = omitRequiredUseAliases(projectDigestUsesFlat(uses.optional), required);
711
- if (!required && !optional) {
712
- return undefined;
713
- }
714
- return {
715
- ...(required ? { required } : {}),
716
- ...(optional ? { optional } : {}),
717
- };
718
- }
719
- function projectDigestRpc(rpc) {
720
- if (!rpc) {
721
- return undefined;
722
- }
723
- return Object.fromEntries(Object.entries(rpc).map(([name, method]) => {
724
- const projected = omitDocs(method);
725
- return [
726
- name,
727
- {
728
- ...projected,
729
- ...(method.capabilities?.call
730
- ? { capabilities: { call: sortedUnique(method.capabilities.call) } }
731
- : {}),
732
- ...(method.errors
733
- ? {
734
- errors: sortedUnique(method.errors.map((error) => error.type))
735
- .map((type) => ({ type })),
736
- }
737
- : {}),
738
- },
739
- ];
740
- }));
741
- }
742
- function projectDigestOperations(operations) {
743
- if (!operations) {
744
- return undefined;
745
- }
746
- return Object.fromEntries(Object.entries(operations).map(([name, operation]) => {
747
- const projected = omitDocs(operation);
748
- return [
749
- name,
750
- {
751
- ...projected,
752
- ...(operation.signals
753
- ? {
754
- signals: mapValues(operation.signals, omitDocs),
755
- }
756
- : {}),
757
- ...((operation.capabilities?.call ||
758
- operation.capabilities?.observe ||
759
- operation.capabilities?.cancel || operation.capabilities?.control)
760
- ? {
761
- capabilities: {
762
- ...(operation.capabilities.call
763
- ? { call: sortedUnique(operation.capabilities.call) }
764
- : {}),
765
- ...(operation.capabilities.observe
766
- ? { observe: sortedUnique(operation.capabilities.observe) }
767
- : {}),
768
- ...(operation.capabilities.cancel
769
- ? { cancel: sortedUnique(operation.capabilities.cancel) }
770
- : {}),
771
- ...(operation.capabilities.control
772
- ? { control: sortedUnique(operation.capabilities.control) }
773
- : {}),
774
- },
775
- }
776
- : {}),
777
- },
778
- ];
779
- }));
780
- }
781
- function projectDigestEvents(events) {
782
- if (!events) {
783
- return undefined;
784
- }
785
- return Object.fromEntries(Object.entries(events).map(([name, event]) => {
786
- const projected = omitDocs(event);
787
- return [
788
- name,
789
- {
790
- ...projected,
791
- ...((event.capabilities?.publish || event.capabilities?.subscribe)
792
- ? {
793
- capabilities: {
794
- ...(event.capabilities.publish
795
- ? { publish: sortedUnique(event.capabilities.publish) }
796
- : {}),
797
- ...(event.capabilities.subscribe
798
- ? { subscribe: sortedUnique(event.capabilities.subscribe) }
799
- : {}),
800
- },
801
- }
802
- : {}),
803
- },
804
- ];
805
- }));
806
- }
807
- function projectDigestFeeds(feeds) {
808
- if (!feeds) {
809
- return undefined;
810
- }
811
- return Object.fromEntries(Object.entries(feeds).map(([name, feed]) => {
812
- const projected = omitDocs(feed);
813
- return [
814
- name,
815
- {
816
- ...projected,
817
- ...(feed.capabilities?.subscribe
818
- ? {
819
- capabilities: {
820
- subscribe: sortedUnique(feed.capabilities.subscribe),
821
- },
822
- }
823
- : {}),
824
- },
825
- ];
826
- }));
827
- }
828
- function mapValues(values, map) {
829
- if (!values)
830
- return undefined;
831
- return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, map(value)]));
832
- }
833
- function omitDocs(value) {
834
- const projected = { ...value };
835
- delete projected.docs;
836
- return projected;
837
- }
838
- function contractDocs(docs) {
839
- if (!docs)
840
- return undefined;
841
- return {
842
- ...(docs.summary !== undefined ? { summary: docs.summary } : {}),
843
- markdown: docs.markdown,
844
- };
845
- }
846
- function schemaRef(ref) {
847
- return { schema: ref.schema };
848
- }
849
- function capabilityMetadata(metadata) {
850
- return {
851
- displayName: metadata.displayName,
852
- description: metadata.description,
853
- ...(metadata.consequence ? { consequence: metadata.consequence } : {}),
854
- };
855
- }
856
- function useRpc(use) {
857
- if (!use)
858
- return undefined;
859
- return {
860
- ...(use.call ? { call: [...use.call] } : {}),
861
- };
862
- }
863
- function usePubSub(use) {
864
- if (!use)
865
- return undefined;
866
- return {
867
- ...(use.publish ? { publish: [...use.publish] } : {}),
868
- ...(use.subscribe ? { subscribe: [...use.subscribe] } : {}),
869
- };
870
- }
871
- function contractUse(use) {
872
- return {
873
- contract: use.contract,
874
- ...(use.rpc ? { rpc: useRpc(use.rpc) } : {}),
875
- ...(use.operations ? { operations: useRpc(use.operations) } : {}),
876
- ...(use.events ? { events: usePubSub(use.events) } : {}),
877
- ...(use.feeds
878
- ? {
879
- feeds: {
880
- ...(use.feeds.subscribe
881
- ? { subscribe: [...use.feeds.subscribe] }
882
- : {}),
883
- },
884
- }
885
- : {}),
886
- };
887
- }
888
- function contractUses(uses) {
889
- if (!uses)
890
- return undefined;
891
- return {
892
- ...(uses.required
893
- ? { required: mapValues(uses.required, contractUse) }
894
- : {}),
895
- ...(uses.optional
896
- ? { optional: mapValues(uses.optional, contractUse) }
897
- : {}),
898
- };
899
- }
900
- function stateStore(store) {
901
- return {
902
- kind: store.kind,
903
- schema: schemaRef(store.schema),
904
- ...(store.stateVersion ? { stateVersion: store.stateVersion } : {}),
905
- ...(store.acceptedVersions
906
- ? { acceptedVersions: mapValues(store.acceptedVersions, schemaRef) }
907
- : {}),
908
- ...(store.docs ? { docs: contractDocs(store.docs) } : {}),
909
- };
910
- }
911
- function rpcMethod(method) {
912
- return {
913
- version: method.version,
914
- subject: method.subject,
915
- input: schemaRef(method.input),
916
- output: schemaRef(method.output),
917
- ...(method.transfer
918
- ? { transfer: { direction: method.transfer.direction } }
919
- : {}),
920
- ...(method.capabilities?.call
921
- ? { capabilities: { call: [...method.capabilities.call] } }
922
- : {}),
923
- ...(method.errors
924
- ? { errors: method.errors.map((error) => ({ type: error.type })) }
925
- : {}),
926
- ...(method.docs ? { docs: contractDocs(method.docs) } : {}),
927
- };
928
- }
929
- function operation(operation) {
930
- return {
931
- version: operation.version,
932
- subject: operation.subject,
933
- input: schemaRef(operation.input),
934
- ...(operation.progress ? { progress: schemaRef(operation.progress) } : {}),
935
- output: schemaRef(operation.output),
936
- ...(operation.transfer
937
- ? {
938
- transfer: {
939
- direction: operation.transfer.direction,
940
- store: operation.transfer.store,
941
- key: operation.transfer.key,
942
- ...(operation.transfer.contentType
943
- ? { contentType: operation.transfer.contentType }
944
- : {}),
945
- ...(operation.transfer.metadata
946
- ? { metadata: operation.transfer.metadata }
947
- : {}),
948
- ...(operation.transfer.expiresInMs !== undefined
949
- ? { expiresInMs: operation.transfer.expiresInMs }
950
- : {}),
951
- ...(operation.transfer.maxBytes !== undefined
952
- ? { maxBytes: operation.transfer.maxBytes }
953
- : {}),
954
- },
955
- }
956
- : {}),
957
- ...(operation.capabilities
958
- ? {
959
- capabilities: {
960
- ...(operation.capabilities.call
961
- ? { call: [...operation.capabilities.call] }
962
- : {}),
963
- ...(operation.capabilities.observe
964
- ? { observe: [...operation.capabilities.observe] }
965
- : {}),
966
- ...(operation.capabilities.cancel
967
- ? { cancel: [...operation.capabilities.cancel] }
968
- : {}),
969
- ...(operation.capabilities.control
970
- ? { control: [...operation.capabilities.control] }
971
- : {}),
972
- },
973
- }
974
- : {}),
975
- ...(operation.signals
976
- ? {
977
- signals: mapValues(operation.signals, (signal) => ({
978
- input: schemaRef(signal.input),
979
- ...(signal.docs ? { docs: contractDocs(signal.docs) } : {}),
980
- })),
981
- }
982
- : {}),
983
- ...(operation.cancel !== undefined ? { cancel: operation.cancel } : {}),
984
- ...(operation.docs ? { docs: contractDocs(operation.docs) } : {}),
985
- };
986
- }
987
- function event(event) {
988
- return {
989
- version: event.version,
990
- subject: event.subject,
991
- ...(event.params ? { params: [...event.params] } : {}),
992
- event: schemaRef(event.event),
993
- ...(event.capabilities
994
- ? {
995
- capabilities: {
996
- ...(event.capabilities.publish
997
- ? { publish: [...event.capabilities.publish] }
998
- : {}),
999
- ...(event.capabilities.subscribe
1000
- ? { subscribe: [...event.capabilities.subscribe] }
1001
- : {}),
1002
- },
1003
- }
1004
- : {}),
1005
- ...(event.docs ? { docs: contractDocs(event.docs) } : {}),
1006
- };
1007
- }
1008
- function feed(feed) {
1009
- return {
1010
- version: feed.version,
1011
- subject: feed.subject,
1012
- input: schemaRef(feed.input),
1013
- event: schemaRef(feed.event),
1014
- ...(feed.capabilities?.subscribe
1015
- ? { capabilities: { subscribe: [...feed.capabilities.subscribe] } }
1016
- : {}),
1017
- ...(feed.docs ? { docs: contractDocs(feed.docs) } : {}),
1018
- };
1019
- }
1020
- function eventConsumerEvent(event) {
1021
- return { use: event.use, event: event.event };
1022
- }
1023
- function sortEventConsumerEvents(events) {
1024
- return events.map(eventConsumerEvent).sort((left, right) => left.use.localeCompare(right.use) || left.event.localeCompare(right.event));
1025
- }
1026
- function eventConsumerGroup(group) {
1027
- return {
1028
- events: sortEventConsumerEvents(group.events),
1029
- replay: group.replay ?? "new",
1030
- ordering: group.ordering ?? "strict",
1031
- concurrency: group.concurrency ?? 1,
1032
- ...(group.ackWaitMs !== undefined ? { ackWaitMs: group.ackWaitMs } : {}),
1033
- ...(group.maxDeliver !== undefined ? { maxDeliver: group.maxDeliver } : {}),
1034
- ...(group.backoffMs ? { backoffMs: [...group.backoffMs] } : {}),
1035
- ...(group.docs ? { docs: contractDocs(group.docs) } : {}),
1036
- };
1037
- }
1038
- function errorDecl(error) {
1039
- return {
1040
- type: error.type,
1041
- ...(error.schema ? { schema: schemaRef(error.schema) } : {}),
1042
- };
1043
- }
1044
- function jobQueue(queue) {
1045
- return {
1046
- payload: schemaRef(queue.payload),
1047
- ...(queue.result ? { result: schemaRef(queue.result) } : {}),
1048
- ...(queue.maxDeliver !== undefined ? { maxDeliver: queue.maxDeliver } : {}),
1049
- ...(queue.backoffMs ? { backoffMs: [...queue.backoffMs] } : {}),
1050
- ...(queue.ackWaitMs !== undefined ? { ackWaitMs: queue.ackWaitMs } : {}),
1051
- ...(queue.defaultDeadlineMs !== undefined
1052
- ? { defaultDeadlineMs: queue.defaultDeadlineMs }
1053
- : {}),
1054
- ...(queue.progress !== undefined ? { progress: queue.progress } : {}),
1055
- ...(queue.logs !== undefined ? { logs: queue.logs } : {}),
1056
- ...(queue.dlq !== undefined ? { dlq: queue.dlq } : {}),
1057
- ...(queue.concurrency !== undefined
1058
- ? { concurrency: queue.concurrency }
1059
- : {}),
1060
- ...(queue.docs ? { docs: contractDocs(queue.docs) } : {}),
1061
- };
1062
- }
1063
- function kvResource(resource) {
1064
- return {
1065
- purpose: resource.purpose,
1066
- schema: schemaRef(resource.schema),
1067
- ...(resource.required !== undefined ? { required: resource.required } : {}),
1068
- ...(resource.history !== undefined ? { history: resource.history } : {}),
1069
- ...(resource.ttlMs !== undefined ? { ttlMs: resource.ttlMs } : {}),
1070
- ...(resource.maxValueBytes !== undefined
1071
- ? { maxValueBytes: resource.maxValueBytes }
1072
- : {}),
1073
- ...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
1074
- };
1075
- }
1076
- function storeResource(resource) {
1077
- return {
1078
- purpose: resource.purpose,
1079
- ...(resource.required !== undefined ? { required: resource.required } : {}),
1080
- ...(resource.ttlMs !== undefined ? { ttlMs: resource.ttlMs } : {}),
1081
- ...(resource.maxObjectBytes !== undefined
1082
- ? { maxObjectBytes: resource.maxObjectBytes }
1083
- : {}),
1084
- ...(resource.maxTotalBytes !== undefined
1085
- ? { maxTotalBytes: resource.maxTotalBytes }
1086
- : {}),
1087
- ...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
1088
- };
1089
- }
1090
- /**
1091
- * Return the canonical manifest shape used by Trellis runtimes before
1092
- * validation, persistence, and digesting.
1093
- *
1094
- * This is not the digest projection: human-facing fields such as
1095
- * `displayName` and `description` are preserved here even though they are not
1096
- * part of contract identity. Unknown extension fields are intentionally omitted
1097
- * until the runtime explicitly supports them.
1098
- */
1099
- function normalizeContractManifest(contract) {
1100
- return {
1101
- format: contract.format,
1102
- id: contract.id,
1103
- displayName: contract.displayName,
1104
- description: contract.description,
1105
- ...(contract.docs ? { docs: contractDocs(contract.docs) } : {}),
1106
- kind: contract.kind,
1107
- ...(contract.capabilities
1108
- ? { capabilities: mapValues(contract.capabilities, capabilityMetadata) }
1109
- : {}),
1110
- ...(contract.schemas ? { schemas: contract.schemas } : {}),
1111
- ...(contract.exports
1112
- ? {
1113
- exports: {
1114
- ...(contract.exports.schemas
1115
- ? { schemas: [...contract.exports.schemas] }
1116
- : {}),
1117
- },
1118
- }
1119
- : {}),
1120
- ...(contract.uses ? { uses: contractUses(contract.uses) } : {}),
1121
- ...(contract.state ? { state: mapValues(contract.state, stateStore) } : {}),
1122
- ...(contract.rpc ? { rpc: mapValues(contract.rpc, rpcMethod) } : {}),
1123
- ...(contract.operations
1124
- ? { operations: mapValues(contract.operations, operation) }
1125
- : {}),
1126
- ...(contract.events ? { events: mapValues(contract.events, event) } : {}),
1127
- ...(contract.feeds ? { feeds: mapValues(contract.feeds, feed) } : {}),
1128
- ...(contract.jobs ? { jobs: mapValues(contract.jobs, jobQueue) } : {}),
1129
- ...(contract.eventConsumers
1130
- ? {
1131
- eventConsumers: mapValues(contract.eventConsumers, eventConsumerGroup),
1132
- }
1133
- : {}),
1134
- ...(contract.resources
1135
- ? {
1136
- resources: {
1137
- ...(contract.resources.kv
1138
- ? { kv: mapValues(contract.resources.kv, kvResource) }
1139
- : {}),
1140
- ...(contract.resources.store
1141
- ? { store: mapValues(contract.resources.store, storeResource) }
1142
- : {}),
1143
- },
1144
- }
1145
- : {}),
1146
- ...(contract.errors
1147
- ? { errors: mapValues(contract.errors, errorDecl) }
1148
- : {}),
1149
- };
1150
- }
1151
- /**
1152
- * Parse untrusted contract JSON into the current Trellis v1 manifest shape.
1153
- *
1154
- * Unknown extension fields are accepted for forward compatibility but are not
1155
- * returned. Callers must use the returned value for persistence and digesting.
1156
- */
1157
- function parseContractManifest(value) {
1158
- let parsed;
1159
- try {
1160
- parsed = value_1.Value.Parse(exports.TrellisContractV1Schema, value);
1161
- }
1162
- catch (error) {
1163
- const details = [...value_1.Value.Errors(exports.TrellisContractV1Schema, value)].map((entry) => `${entry.instancePath || "#"}: ${entry.message}`);
1164
- throw new TypeError(`Invalid contract${details.length > 0 ? `:\n${details.join("\n")}` : ""}`, { cause: error });
1165
- }
1166
- const contract = normalizeContractManifest(parsed);
1167
- assertValidEventConsumers(contract.eventConsumers, contract.uses);
1168
- return contract;
1169
- }
1170
- /**
1171
- * Build the normalized runtime/interface projection used for contract identity.
1172
- */
1173
- function projectContractDigestManifest(contract) {
1174
- const schemas = projectReachableSchemas(contract);
1175
- const errors = projectRpcDeclaredErrors(contract);
1176
- const state = projectDigestState(contract.state);
1177
- const resources = projectDigestResources(contract.resources);
1178
- const jobs = projectDigestJobs(contract.jobs);
1179
- const eventConsumers = projectDigestEventConsumers(contract.eventConsumers);
1180
- const uses = projectDigestUses(contract.uses);
1181
- const rpc = projectDigestRpc(contract.rpc);
1182
- const operations = projectDigestOperations(contract.operations);
1183
- const events = projectDigestEvents(contract.events);
1184
- const feeds = projectDigestFeeds(contract.feeds);
1185
- return {
1186
- format: contract.format,
1187
- id: contract.id,
1188
- kind: contract.kind,
1189
- ...(contract.capabilities ? { capabilities: contract.capabilities } : {}),
1190
- ...(schemas ? { schemas } : {}),
1191
- ...(state ? { state } : {}),
1192
- ...(uses ? { uses } : {}),
1193
- ...(rpc ? { rpc } : {}),
1194
- ...(operations ? { operations } : {}),
1195
- ...(events ? { events } : {}),
1196
- ...(feeds ? { feeds } : {}),
1197
- ...(errors ? { errors } : {}),
1198
- ...(jobs ? { jobs } : {}),
1199
- ...(eventConsumers ? { eventConsumers } : {}),
1200
- ...(resources ? { resources } : {}),
1201
- };
1202
- }
1203
- /** Compute the v1 contract digest from the normalized digest projection. */
1204
- function digestContractManifest(contract) {
1205
- return digestCanonicalJson(projectContractDigestManifest(normalizeContractManifest(contract)));
1206
- }
1207
- function rpcSubject(name, version) {
1208
- return `rpc.${version}.${name}`;
1209
- }
1210
- function operationSubject(name, version) {
1211
- return `operations.${version}.${name}`;
1212
- }
1213
- function feedSubject(name, version) {
1214
- return `feeds.${version}.${name}`;
1215
- }
1216
- function eventSubject(name, version, params) {
1217
- const suffix = params && params.length > 0
1218
- ? `.${params.map((pointer) => `{${pointer}}`).join(".")}`
1219
- : "";
1220
- return `events.${version}.${name}${suffix}`;
1221
- }
1222
- function emitResources(resources) {
1223
- if (!resources?.kv && !resources?.store) {
1224
- return undefined;
1225
- }
1226
- return {
1227
- ...(resources.kv
1228
- ? {
1229
- kv: Object.fromEntries(Object.entries(resources.kv).map(([alias, resource]) => [
1230
- alias,
1231
- {
1232
- purpose: resource.purpose,
1233
- schema: { ...resource.schema },
1234
- required: resource.required ?? true,
1235
- history: resource.history ?? 1,
1236
- ttlMs: resource.ttlMs ?? 0,
1237
- ...(resource.maxValueBytes
1238
- ? { maxValueBytes: resource.maxValueBytes }
1239
- : {}),
1240
- ...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
1241
- },
1242
- ])),
1243
- }
1244
- : {}),
1245
- ...(resources.store
1246
- ? {
1247
- store: Object.fromEntries(Object.entries(resources.store).map(([alias, resource]) => [
1248
- alias,
1249
- {
1250
- purpose: resource.purpose,
1251
- required: resource.required ?? true,
1252
- ttlMs: resource.ttlMs ?? 0,
1253
- ...(resource.maxObjectBytes !== undefined
1254
- ? { maxObjectBytes: resource.maxObjectBytes }
1255
- : {}),
1256
- ...(resource.maxTotalBytes !== undefined
1257
- ? { maxTotalBytes: resource.maxTotalBytes }
1258
- : {}),
1259
- ...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
1260
- },
1261
- ])),
1262
- }
1263
- : {}),
1264
- };
1265
- }
1266
- function emitJobs(jobs) {
1267
- if (!jobs) {
1268
- return undefined;
1269
- }
1270
- return Object.fromEntries(Object.entries(jobs).map(([queueType, queue]) => [
1271
- queueType,
1272
- {
1273
- payload: { ...queue.payload },
1274
- ...(queue.result ? { result: { ...queue.result } } : {}),
1275
- ...(queue.maxDeliver !== undefined
1276
- ? { maxDeliver: queue.maxDeliver }
1277
- : {}),
1278
- ...(queue.backoffMs ? { backoffMs: [...queue.backoffMs] } : {}),
1279
- ...(queue.ackWaitMs !== undefined
1280
- ? { ackWaitMs: queue.ackWaitMs }
1281
- : {}),
1282
- ...(queue.defaultDeadlineMs !== undefined
1283
- ? { defaultDeadlineMs: queue.defaultDeadlineMs }
1284
- : {}),
1285
- ...(queue.progress !== undefined ? { progress: queue.progress } : {}),
1286
- ...(queue.logs !== undefined ? { logs: queue.logs } : {}),
1287
- ...(queue.dlq !== undefined ? { dlq: queue.dlq } : {}),
1288
- ...(queue.concurrency !== undefined
1289
- ? { concurrency: queue.concurrency }
1290
- : {}),
1291
- ...(queue.docs ? { docs: contractDocs(queue.docs) } : {}),
1292
- },
1293
- ]));
1294
- }
1295
- function emitEventConsumers(eventConsumers) {
1296
- if (!eventConsumers) {
1297
- return undefined;
1298
- }
1299
- return Object.fromEntries(Object.entries(eventConsumers).map(([groupName, group]) => [
1300
- groupName,
1301
- {
1302
- events: sortEventConsumerEvents(group.events),
1303
- replay: group.replay ?? "new",
1304
- ordering: group.ordering ?? "strict",
1305
- concurrency: group.concurrency ?? 1,
1306
- ...(group.ackWaitMs !== undefined
1307
- ? { ackWaitMs: group.ackWaitMs }
1308
- : {}),
1309
- ...(group.maxDeliver !== undefined
1310
- ? { maxDeliver: group.maxDeliver }
1311
- : {}),
1312
- ...(group.backoffMs ? { backoffMs: [...group.backoffMs] } : {}),
1313
- ...(group.docs ? { docs: contractDocs(group.docs) } : {}),
1314
- },
1315
- ]));
1316
- }
1317
- function buildContractJobsMetadata(jobs) {
1318
- if (!jobs) {
1319
- return {};
1320
- }
1321
- return Object.fromEntries(Object.keys(jobs).map((queueType) => [queueType, {
1322
- payload: undefined,
1323
- result: undefined,
1324
- }]));
1325
- }
1326
- function buildContractKvMetadata(resources, schemas) {
1327
- const kv = resources?.kv;
1328
- if (!kv) {
1329
- return {};
1330
- }
1331
- const metadata = {};
1332
- for (const [alias, resource] of Object.entries(kv)) {
1333
- assertSchemaRefExists(schemas, resource.schema, `kv resource '${alias}'`);
1334
- const schema = schemas?.[resource.schema.schema];
1335
- if (!schema) {
1336
- throw new Error(`kv resource '${alias}' references missing schema '${resource.schema.schema}'`);
1337
- }
1338
- metadata[alias] = {
1339
- required: resource.required ?? true,
1340
- value: undefined,
1341
- schema,
1342
- };
1343
- }
1344
- return metadata;
1345
- }
1346
- function buildContractStateMetadata(state, schemas) {
1347
- if (!state) {
1348
- return {};
1349
- }
1350
- return Object.fromEntries(Object.entries(state).map(([storeName, store]) => [storeName, {
1351
- kind: store.kind,
1352
- value: undefined,
1353
- schema: resolveSchemaRef(schemas, store.schema, `state store '${storeName}'`),
1354
- stateVersion: store.stateVersion ?? "v1",
1355
- acceptedVersions: Object.fromEntries(Object.entries(store.acceptedVersions ?? {}).map(([version, schema]) => [
1356
- version,
1357
- resolveSchemaRef(schemas, schema, `state store '${storeName}' accepted version '${version}'`),
1358
- ])),
1359
- }]));
1360
- }
1361
- function emitState(state) {
1362
- if (!state) {
1363
- return undefined;
1364
- }
1365
- return Object.fromEntries(Object.entries(state).map(([storeName, store]) => [
1366
- storeName,
1367
- {
1368
- kind: store.kind,
1369
- schema: { ...store.schema },
1370
- ...(store.stateVersion === undefined
1371
- ? {}
1372
- : { stateVersion: store.stateVersion }),
1373
- ...(store.acceptedVersions === undefined
1374
- ? {}
1375
- : { acceptedVersions: store.acceptedVersions }),
1376
- ...(store.docs ? { docs: contractDocs(store.docs) } : {}),
1377
- },
1378
- ]));
1379
- }
1380
- function emitUsesFlat(uses) {
1381
- if (!uses) {
1382
- return undefined;
1383
- }
1384
- return Object.fromEntries(Object.entries(uses).map(([alias, use]) => [
1385
- alias,
1386
- {
1387
- contract: use.contract,
1388
- ...(use.rpc?.call ? { rpc: { call: sortedUnique(use.rpc.call) } } : {}),
1389
- ...(use.operations?.call
1390
- ? { operations: { call: sortedUnique(use.operations.call) } }
1391
- : {}),
1392
- ...((use.events?.publish || use.events?.subscribe)
1393
- ? {
1394
- events: {
1395
- ...(use.events.publish
1396
- ? { publish: sortedUnique(use.events.publish) }
1397
- : {}),
1398
- ...(use.events.subscribe
1399
- ? { subscribe: sortedUnique(use.events.subscribe) }
1400
- : {}),
1401
- },
1402
- }
1403
- : {}),
1404
- ...(use.feeds?.subscribe
1405
- ? { feeds: { subscribe: sortedUnique(use.feeds.subscribe) } }
1406
- : {}),
1407
- },
1408
- ]));
1409
- }
1410
- function emitUses(uses) {
1411
- if (!uses) {
1412
- return undefined;
1413
- }
1414
- const required = emitUsesFlat(uses.required);
1415
- const optional = omitRequiredUseAliases(emitUsesFlat(uses.optional), required);
1416
- if (!required && !optional) {
1417
- return undefined;
1418
- }
1419
- return {
1420
- ...(required ? { required } : {}),
1421
- ...(optional ? { optional } : {}),
1422
- };
1423
- }
1424
- function emitContract(source) {
1425
- const capabilities = emitCapabilities(source.id, source.capabilities);
1426
- const rpc = source.rpc
1427
- ? Object.fromEntries(Object.entries(source.rpc).map(([name, method]) => {
1428
- const emitted = {
1429
- version: method.version,
1430
- subject: method.subject ?? rpcSubject(name, method.version),
1431
- input: { ...method.input },
1432
- output: { ...method.output },
1433
- };
1434
- if (method.capabilities?.call) {
1435
- emitted.capabilities = {
1436
- call: projectCapabilities(method.capabilities.call, source.id, source.capabilities, `rpc '${name}' call capabilities`) ?? [],
1437
- };
1438
- }
1439
- if (method.transfer) {
1440
- emitted.transfer = { ...method.transfer };
1441
- }
1442
- if (method.errors && method.errors.length > 0) {
1443
- emitted.errors = sortedUnique(method.errors.map((errorName) => source.errors?.[errorName]?.type ?? errorName)).map((type) => ({ type }));
1444
- }
1445
- if (method.internal) {
1446
- emitted.internal = true;
1447
- }
1448
- if (method.docs) {
1449
- emitted.docs = contractDocs(method.docs);
1450
- }
1451
- return [name, emitted];
1452
- }))
1453
- : undefined;
1454
- const operations = source.operations
1455
- ? Object.fromEntries(Object.entries(source.operations).map(([name, operation]) => {
1456
- if (operation.transfer) {
1457
- const store = source.resources?.store?.[operation.transfer.store];
1458
- if (!store) {
1459
- throw new Error(`Operation '${name}' references unknown store resource '${operation.transfer.store}'`);
1460
- }
1461
- const inputSchema = resolveSchemaRef(source.schemas, operation.input, `operation '${name}' input`);
1462
- for (const pointer of [
1463
- operation.transfer.key,
1464
- operation.transfer.contentType,
1465
- operation.transfer.metadata,
1466
- ]) {
1467
- if (!pointer) {
1468
- continue;
1469
- }
1470
- if ((0, schema_pointers_js_1.getSubschemaAtDataPointer)(inputSchema, pointer) === undefined) {
1471
- throw new Error(`Invalid transfer pointer '${pointer}' for operation '${name}' (path not found in input schema)`);
1472
- }
1473
- }
1474
- }
1475
- const emitted = {
1476
- version: operation.version,
1477
- subject: operation.subject ??
1478
- operationSubject(name, operation.version),
1479
- input: { ...operation.input },
1480
- output: { ...operation.output },
1481
- };
1482
- if (operation.progress) {
1483
- emitted.progress = { ...operation.progress };
1484
- }
1485
- if (operation.transfer) {
1486
- emitted.transfer = { ...operation.transfer, direction: "send" };
1487
- }
1488
- if (operation.capabilities?.call || operation.capabilities?.observe ||
1489
- operation.capabilities?.cancel || operation.capabilities?.control) {
1490
- emitted.capabilities = {
1491
- ...(operation.capabilities.call
1492
- ? {
1493
- call: projectCapabilities(operation.capabilities.call, source.id, source.capabilities, `operation '${name}' call capabilities`) ?? [],
1494
- }
1495
- : {}),
1496
- ...(operation.capabilities.observe
1497
- ? {
1498
- observe: projectCapabilities(operation.capabilities.observe, source.id, source.capabilities, `operation '${name}' observe capabilities`) ?? [],
1499
- }
1500
- : {}),
1501
- ...(operation.capabilities.cancel
1502
- ? {
1503
- cancel: projectCapabilities(operation.capabilities.cancel, source.id, source.capabilities, `operation '${name}' cancel capabilities`) ?? [],
1504
- }
1505
- : {}),
1506
- ...(operation.capabilities.control
1507
- ? {
1508
- control: projectCapabilities(operation.capabilities.control, source.id, source.capabilities, `operation '${name}' control capabilities`) ?? [],
1509
- }
1510
- : {}),
1511
- };
1512
- }
1513
- if (operation.signals) {
1514
- emitted.signals = Object.fromEntries(Object.entries(operation.signals).map(([signalName, signal]) => [
1515
- signalName,
1516
- {
1517
- input: { ...signal.input },
1518
- ...(signal.docs ? { docs: contractDocs(signal.docs) } : {}),
1519
- },
1520
- ]));
1521
- }
1522
- if (operation.cancel !== undefined) {
1523
- emitted.cancel = operation.cancel;
1524
- }
1525
- if (operation.docs) {
1526
- emitted.docs = contractDocs(operation.docs);
1527
- }
1528
- return [name, emitted];
1529
- }))
1530
- : undefined;
1531
- const events = source.events
1532
- ? Object.fromEntries(Object.entries(source.events).map(([name, event]) => {
1533
- if (event.params && event.params.length > 0) {
1534
- (0, schema_pointers_js_1.assertDataPointersExistAndAreTokenable)(name, resolveSchemaRef(source.schemas, event.event, `event '${name}'`), event.params);
1535
- }
1536
- const emitted = {
1537
- version: event.version,
1538
- subject: event.subject ??
1539
- eventSubject(name, event.version, event.params),
1540
- event: { ...event.event },
1541
- };
1542
- if (event.params && event.params.length > 0) {
1543
- emitted.params = [...event.params];
1544
- }
1545
- if (event.capabilities?.publish || event.capabilities?.subscribe) {
1546
- emitted.capabilities = {
1547
- ...(event.capabilities.publish
1548
- ? {
1549
- publish: projectCapabilities(event.capabilities.publish, source.id, source.capabilities, `event '${name}' publish capabilities`) ?? [],
1550
- }
1551
- : {}),
1552
- ...(event.capabilities.subscribe
1553
- ? {
1554
- subscribe: projectCapabilities(event.capabilities.subscribe, source.id, source.capabilities, `event '${name}' subscribe capabilities`) ?? [],
1555
- }
1556
- : {}),
1557
- };
1558
- }
1559
- if (event.docs) {
1560
- emitted.docs = contractDocs(event.docs);
1561
- }
1562
- return [name, emitted];
1563
- }))
1564
- : undefined;
1565
- const feeds = source.feeds
1566
- ? Object.fromEntries(Object.entries(source.feeds).map(([name, feed]) => {
1567
- const emitted = {
1568
- version: feed.version,
1569
- subject: feed.subject ?? feedSubject(name, feed.version),
1570
- input: { ...feed.input },
1571
- event: { ...feed.event },
1572
- };
1573
- if (feed.capabilities?.subscribe) {
1574
- emitted.capabilities = {
1575
- subscribe: projectCapabilities(feed.capabilities.subscribe, source.id, source.capabilities, `feed '${name}' subscribe capabilities`) ?? [],
1576
- };
1577
- }
1578
- if (feed.docs) {
1579
- emitted.docs = contractDocs(feed.docs);
1580
- }
1581
- return [name, emitted];
1582
- }))
1583
- : undefined;
1584
- const errors = source.errors
1585
- ? Object.fromEntries(Object.entries(source.errors).map(([name, error]) => {
1586
- const emitted = { type: error.type };
1587
- const schemaRef = resolveErrorSchemaRef(source.schemas, name, error);
1588
- if (schemaRef) {
1589
- emitted.schema = { ...schemaRef };
1590
- }
1591
- return [name, emitted];
1592
- }))
1593
- : undefined;
1594
- const jobs = emitJobs(source.jobs);
1595
- const eventConsumers = emitEventConsumers(source.eventConsumers);
1596
- const state = emitState(source.state);
1597
- const resources = emitResources(source.resources);
1598
- const uses = emitUses(source.uses);
1599
- assertValidEventConsumers(eventConsumers, uses);
1600
- return {
1601
- format: exports.CONTRACT_FORMAT_V1,
1602
- id: source.id,
1603
- displayName: source.displayName,
1604
- description: source.description,
1605
- ...(source.docs ? { docs: contractDocs(source.docs) } : {}),
1606
- kind: source.kind,
1607
- ...(capabilities ? { capabilities } : {}),
1608
- ...(source.schemas ? { schemas: cloneSchemas(source.schemas) } : {}),
1609
- ...(source.exports
1610
- ? { exports: cloneContractExports(source.exports) }
1611
- : {}),
1612
- ...(state ? { state } : {}),
1613
- ...(uses ? { uses } : {}),
1614
- ...(rpc ? { rpc } : {}),
1615
- ...(operations ? { operations } : {}),
1616
- ...(events ? { events } : {}),
1617
- ...(feeds ? { feeds } : {}),
1618
- ...(errors ? { errors } : {}),
1619
- ...(jobs ? { jobs } : {}),
1620
- ...(eventConsumers ? { eventConsumers } : {}),
1621
- ...(resources ? { resources } : {}),
1622
- };
1623
- }
1624
- function buildOwnedApi(source) {
1625
- const localRuntimeErrors = {};
1626
- for (const [name, errorDecl] of Object.entries(source.errors ?? {})) {
1627
- const errorClass = getContractErrorRuntimeClass(errorDecl);
1628
- if (!errorClass) {
1629
- continue;
1630
- }
1631
- const errorSchemaRef = resolveErrorSchemaRef(source.schemas, name, errorDecl);
1632
- localRuntimeErrors[name] = {
1633
- type: errorDecl.type,
1634
- ...(errorSchemaRef
1635
- ? {
1636
- schema: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, errorSchemaRef, `error '${name}' schema`)),
1637
- }
1638
- : {}),
1639
- fromSerializable(data) {
1640
- if (!isSerializableErrorData(data)) {
1641
- throw new Error(`Transport error '${errorDecl.type}' is missing base error fields`);
1642
- }
1643
- return errorClass.fromSerializable(data);
1644
- },
1645
- };
1646
- }
1647
- const rpc = {};
1648
- for (const [name, method] of Object.entries(source.rpc ?? {})) {
1649
- rpc[name] = {
1650
- subject: method.subject ?? rpcSubject(name, method.version),
1651
- input: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, method.input, `rpc '${name}' input`)),
1652
- output: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, method.output, `rpc '${name}' output`)),
1653
- callerCapabilities: projectCapabilities(method.capabilities?.call, source.id, source.capabilities, `rpc '${name}' call capabilities`) ?? [],
1654
- transfer: method.transfer ? { ...method.transfer } : undefined,
1655
- authRequired: method.authRequired ?? true,
1656
- errors: method.errors,
1657
- declaredErrorTypes: method.errors?.map((errorName) => source.errors?.[errorName]?.type ?? errorName),
1658
- runtimeErrors: method.errors?.flatMap((errorName) => {
1659
- const runtimeError = localRuntimeErrors[errorName];
1660
- return runtimeError ? [runtimeError] : [];
1661
- }),
1662
- };
1663
- }
1664
- const operations = Object.fromEntries(Object.entries(source.operations ?? {}).map(([name, operation]) => [
1665
- name,
1666
- {
1667
- subject: operation.subject ?? operationSubject(name, operation.version),
1668
- input: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, operation.input, `operation '${name}' input`)),
1669
- progress: operation.progress
1670
- ? (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, operation.progress, `operation '${name}' progress`))
1671
- : undefined,
1672
- output: operation.output
1673
- ? (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, operation.output, `operation '${name}' output`))
1674
- : undefined,
1675
- transfer: operation.transfer
1676
- ? { ...operation.transfer, direction: "send" }
1677
- : undefined,
1678
- signals: operation.signals
1679
- ? Object.fromEntries(Object.entries(operation.signals).map(([signalName, signal]) => [
1680
- signalName,
1681
- {
1682
- input: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, signal.input, `operation '${name}' signal '${signalName}' input`)),
1683
- },
1684
- ]))
1685
- : undefined,
1686
- callerCapabilities: projectCapabilities(operation.capabilities?.call, source.id, source.capabilities, `operation '${name}' call capabilities`) ?? [],
1687
- observeCapabilities: projectCapabilities(operation.capabilities?.observe, source.id, source.capabilities, `operation '${name}' observe capabilities`) ?? [],
1688
- cancelCapabilities: projectCapabilities(operation.capabilities?.cancel, source.id, source.capabilities, `operation '${name}' cancel capabilities`) ?? [],
1689
- controlCapabilities: projectCapabilities(operation.capabilities?.control, source.id, source.capabilities, `operation '${name}' control capabilities`) ?? [],
1690
- cancel: operation.cancel,
1691
- },
1692
- ]));
1693
- const events = Object.fromEntries(Object.entries(source.events ?? {}).map(([name, event]) => {
1694
- if (event.params && event.params.length > 0) {
1695
- (0, schema_pointers_js_1.assertDataPointersExistAndAreTokenable)(name, resolveSchemaRef(source.schemas, event.event, `event '${name}'`), event.params);
1696
- }
1697
- return [
1698
- name,
1699
- {
1700
- subject: event.subject ??
1701
- eventSubject(name, event.version, event.params),
1702
- params: event.params,
1703
- event: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, event.event, `event '${name}'`)),
1704
- publishCapabilities: projectCapabilities(event.capabilities?.publish, source.id, source.capabilities, `event '${name}' publish capabilities`) ?? [],
1705
- subscribeCapabilities: projectCapabilities(event.capabilities?.subscribe, source.id, source.capabilities, `event '${name}' subscribe capabilities`) ?? [],
1706
- },
1707
- ];
1708
- }));
1709
- const feeds = Object.fromEntries(Object.entries(source.feeds ?? {}).map(([name, feed]) => [
1710
- name,
1711
- {
1712
- subject: feed.subject ?? feedSubject(name, feed.version),
1713
- input: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, feed.input, `feed '${name}' input`)),
1714
- event: (0, runtime_js_1.schema)(resolveSchemaRef(source.schemas, feed.event, `feed '${name}' event`)),
1715
- subscribeCapabilities: projectCapabilities(feed.capabilities?.subscribe, source.id, source.capabilities, `feed '${name}' subscribe capabilities`) ?? [],
1716
- },
1717
- ]));
1718
- return { rpc, operations, events, feeds, subjects: {} };
1719
- }
1720
- function mergeRecord(kind, out, next) {
1721
- for (const [key, value] of Object.entries(next)) {
1722
- if (Object.hasOwn(out, key)) {
1723
- throw new Error(`Duplicate ${kind} key '${key}' while deriving contract API`);
1724
- }
1725
- out[key] = value;
1726
- }
1727
- }
1728
- function assertSelectedKeysExist(contractId, kind, keys, api) {
1729
- if (!keys) {
1730
- return;
1731
- }
1732
- for (const key of keys) {
1733
- if (!Object.hasOwn(api, key)) {
1734
- throw new Error(`Contract '${contractId}' does not expose ${kind} key '${key}'`);
1735
- }
1736
- }
1737
- }
1738
- function assertValidUseSpec(contractId, spec, api) {
1739
- assertSelectedKeysExist(contractId, "rpc", spec.rpc?.call, api.rpc);
1740
- assertSelectedKeysExist(contractId, "operations", spec.operations?.call, api.operations);
1741
- assertSelectedKeysExist(contractId, "events", spec.events?.publish, api.events);
1742
- assertSelectedKeysExist(contractId, "events", spec.events?.subscribe, api.events);
1743
- assertSelectedKeysExist(contractId, "feeds", spec.feeds?.subscribe, api.feeds ?? {});
1744
- }
1745
- function contractUseByAlias(uses, alias) {
1746
- return uses?.required?.[alias] ?? uses?.optional?.[alias];
1747
- }
1748
- function assertValidEventConsumers(eventConsumers, uses) {
1749
- if (!eventConsumers) {
1750
- return;
1751
- }
1752
- for (const [groupName, group] of Object.entries(eventConsumers)) {
1753
- if (group.events.length === 0) {
1754
- throw new Error(`event consumer group '${groupName}' must declare events`);
1755
- }
1756
- if ((group.ordering ?? "strict") === "strict" && group.concurrency !== 1) {
1757
- throw new Error(`event consumer group '${groupName}' with strict ordering requires concurrency 1`);
1758
- }
1759
- for (const eventRef of group.events) {
1760
- const use = contractUseByAlias(uses, eventRef.use);
1761
- if (!use) {
1762
- throw new Error(`event consumer group '${groupName}' references unknown use '${eventRef.use}'`);
1763
- }
1764
- if (!use.events?.subscribe?.includes(eventRef.event)) {
1765
- throw new Error(`event consumer group '${groupName}' references event '${eventRef.event}' that use '${eventRef.use}' does not subscribe to`);
1766
- }
1767
- }
1768
- }
1769
- }
1770
- function attachContractModuleMetadata(value, contractModule) {
1771
- Object.defineProperty(value, CONTRACT_MODULE_METADATA, {
1772
- value: contractModule,
1773
- enumerable: false,
1774
- });
1775
- return value;
1776
- }
1777
- function attachContractErrorRuntimeMetadata(value, errorClass) {
1778
- Object.defineProperty(value, CONTRACT_ERROR_RUNTIME_METADATA, {
1779
- value: errorClass,
1780
- enumerable: false,
1781
- });
1782
- return value;
1783
- }
1784
- function getContractErrorRuntimeClass(errorDecl) {
1785
- const value = Object.getOwnPropertyDescriptor(errorDecl, CONTRACT_ERROR_RUNTIME_METADATA)?.value;
1786
- if (isErrorClass(value)) {
1787
- return value;
1788
- }
1789
- return undefined;
1790
- }
1791
- function resolveErrorSchemaRef(schemas, errorName, errorDecl) {
1792
- if (errorDecl.schema) {
1793
- return errorDecl.schema;
1794
- }
1795
- const runtimeSchema = getErrorRuntimeSchema(errorDecl);
1796
- if (!runtimeSchema) {
1797
- return undefined;
1798
- }
1799
- const schemaName = findMatchingSchemaName(schemas, runtimeSchema);
1800
- if (schemaName) {
1801
- return { schema: schemaName };
1802
- }
1803
- throw new Error(`error '${errorName}' schema must be declared in contract.schemas`);
1804
- }
1805
- /**
1806
- * Define a transportable Trellis error class from a payload-object schema.
1807
- *
1808
- * The returned value is a real runtime error class that carries the wire schema
1809
- * and reconstruction logic needed by `defineServiceContract(...)`.
1810
- */
1811
- function defineError(options) {
1812
- var _a;
1813
- assertNoReservedDefinedErrorFieldNames(options.fields);
1814
- const errorSchema = createDefinedErrorSchema(options.type, options.fields);
1815
- const fieldNames = definedErrorPayloadFieldNames(options.fields);
1816
- class DefinedErrorImpl extends TrellisError_js_1.TrellisError {
1817
- constructor(payload) {
1818
- const customPayload = pickDefinedErrorPayload(fieldNames, payload);
1819
- const message = typeof options.message === "function"
1820
- ? options.message(customPayload)
1821
- : options.message;
1822
- super(message, definedErrorBaseOptions(payload));
1823
- Object.defineProperty(this, "name", {
1824
- enumerable: true,
1825
- configurable: true,
1826
- writable: true,
1827
- value: options.type
1828
- });
1829
- Object.defineProperty(this, _a, {
1830
- enumerable: true,
1831
- configurable: true,
1832
- writable: true,
1833
- value: void 0
1834
- });
1835
- this[DEFINED_ERROR_PAYLOAD] = customPayload;
1836
- Object.assign(this, customPayload);
1837
- }
1838
- static fromSerializable(data) {
1839
- const customPayload = pickDefinedErrorPayload(fieldNames, data);
1840
- const ErrorCtor = DefinedErrorImpl;
1841
- const error = new ErrorCtor({
1842
- ...customPayload,
1843
- id: data.id,
1844
- context: data.context,
1845
- traceId: data.traceId,
1846
- });
1847
- error[DEFINED_ERROR_PAYLOAD] = customPayload;
1848
- return Object.assign(error, customPayload);
1849
- }
1850
- toSerializable() {
1851
- return {
1852
- ...this.baseSerializable(),
1853
- type: this.name,
1854
- ...this[DEFINED_ERROR_PAYLOAD],
1855
- };
1856
- }
1857
- }
1858
- _a = DEFINED_ERROR_PAYLOAD;
1859
- Object.defineProperty(DefinedErrorImpl, "type", {
1860
- enumerable: true,
1861
- configurable: true,
1862
- writable: true,
1863
- value: options.type
1864
- });
1865
- Object.defineProperty(DefinedErrorImpl, "schema", {
1866
- enumerable: true,
1867
- configurable: true,
1868
- writable: true,
1869
- value: errorSchema
1870
- });
1871
- // @ts-expect-error TypeScript cannot model the dynamically assigned payload
1872
- // fields on the generated class instance constructor return type.
1873
- return DefinedErrorImpl;
1874
- }
1875
- function createUseHelper(getContractModule) {
1876
- return ((spec) => {
1877
- const contractModule = getContractModule();
1878
- assertValidUseSpec(contractModule.CONTRACT_ID, spec, contractModule.API.owned);
1879
- const dependencyUse = {
1880
- contract: contractModule.CONTRACT_ID,
1881
- ...(spec.rpc?.call ? { rpc: { call: [...spec.rpc.call] } } : {}),
1882
- ...(spec.operations?.call
1883
- ? { operations: { call: [...spec.operations.call] } }
1884
- : {}),
1885
- ...((spec.events?.publish || spec.events?.subscribe)
1886
- ? {
1887
- events: {
1888
- ...(spec.events.publish
1889
- ? { publish: [...spec.events.publish] }
1890
- : {}),
1891
- ...(spec.events.subscribe
1892
- ? { subscribe: [...spec.events.subscribe] }
1893
- : {}),
1894
- },
1895
- }
1896
- : {}),
1897
- ...(spec.feeds?.subscribe
1898
- ? { feeds: { subscribe: [...spec.feeds.subscribe] } }
1899
- : {}),
1900
- };
1901
- return attachContractModuleMetadata(dependencyUse, contractModule);
1902
- });
1903
- }
1904
- function getContractModuleFromUse(alias, useValue) {
1905
- const contractModule = Object.getOwnPropertyDescriptor(useValue, CONTRACT_MODULE_METADATA)?.value;
1906
- if (!contractModule) {
1907
- throw new Error(`Contract use '${alias}' must be created with contractModule.use(...) from @qlever-llc/trellis/contracts`);
1908
- }
1909
- return contractModule;
1910
- }
1911
- function normalizeUseEntries(uses) {
1912
- if (!uses) {
1913
- return {
1914
- manifestUses: undefined,
1915
- usedApi: { rpc: {}, operations: {}, events: {}, feeds: {}, subjects: {} },
1916
- };
1917
- }
1918
- const manifestUses = {};
1919
- const usedApi = {
1920
- rpc: {},
1921
- operations: {},
1922
- events: {},
1923
- feeds: {},
1924
- subjects: {},
1925
- };
1926
- for (const [alias, useValue] of Object.entries(uses)) {
1927
- const contractModule = getContractModuleFromUse(alias, useValue);
1928
- const rpcCall = useValue.rpc?.call;
1929
- const operationsCall = useValue.operations?.call;
1930
- const eventsPublish = useValue.events?.publish;
1931
- const eventsSubscribe = useValue.events?.subscribe;
1932
- const feedsSubscribe = useValue.feeds?.subscribe;
1933
- if (useValue.contract !== contractModule.CONTRACT_ID) {
1934
- throw new Error(`Contract use '${alias}' references '${useValue.contract}' but module id is '${contractModule.CONTRACT_ID}'`);
1935
- }
1936
- assertValidUseSpec(contractModule.CONTRACT_ID, {
1937
- ...(rpcCall ? { rpc: { call: rpcCall } } : {}),
1938
- ...(operationsCall ? { operations: { call: operationsCall } } : {}),
1939
- ...((eventsPublish || eventsSubscribe)
1940
- ? {
1941
- events: {
1942
- ...(eventsPublish ? { publish: eventsPublish } : {}),
1943
- ...(eventsSubscribe ? { subscribe: eventsSubscribe } : {}),
1944
- },
1945
- }
1946
- : {}),
1947
- ...(feedsSubscribe ? { feeds: { subscribe: feedsSubscribe } } : {}),
1948
- }, contractModule.API.owned);
1949
- manifestUses[alias] = {
1950
- contract: contractModule.CONTRACT_ID,
1951
- ...(rpcCall ? { rpc: { call: [...rpcCall] } } : {}),
1952
- ...(operationsCall ? { operations: { call: [...operationsCall] } } : {}),
1953
- ...((eventsPublish || eventsSubscribe)
1954
- ? {
1955
- events: {
1956
- ...(eventsPublish ? { publish: [...eventsPublish] } : {}),
1957
- ...(eventsSubscribe ? { subscribe: [...eventsSubscribe] } : {}),
1958
- },
1959
- }
1960
- : {}),
1961
- ...(feedsSubscribe ? { feeds: { subscribe: [...feedsSubscribe] } } : {}),
1962
- };
1963
- const rpcKeys = selectedKeys(rpcCall);
1964
- if (rpcKeys.length > 0) {
1965
- mergeRecord("rpc", usedApi.rpc, Object.fromEntries(rpcKeys.map((key) => [key, contractModule.API.owned.rpc[key]])));
1966
- }
1967
- const operationKeys = selectedKeys(operationsCall);
1968
- if (operationKeys.length > 0) {
1969
- mergeRecord("operations", usedApi.operations, Object.fromEntries(operationKeys.map((key) => [key, contractModule.API.owned.operations[key]])));
1970
- }
1971
- const eventKeys = new Set([
1972
- ...selectedKeys(eventsPublish),
1973
- ...selectedKeys(eventsSubscribe),
1974
- ]);
1975
- if (eventKeys.size > 0) {
1976
- mergeRecord("events", usedApi.events, Object.fromEntries([...eventKeys].map((key) => [key, contractModule.API.owned.events[key]])));
1977
- }
1978
- const feedKeys = selectedKeys(feedsSubscribe);
1979
- if (feedKeys.length > 0) {
1980
- mergeRecord("feeds", usedApi.feeds ?? {}, Object.fromEntries(feedKeys.map((key) => [key, contractModule.API.owned.feeds?.[key]])));
1981
- }
1982
- }
1983
- return { manifestUses, usedApi };
1984
- }
1985
- function normalizeUses(uses) {
1986
- if (!uses) {
1987
- return {
1988
- manifestUses: undefined,
1989
- usedApi: emptyApi(),
1990
- };
1991
- }
1992
- const required = normalizeUseEntries(uses.required);
1993
- const optional = normalizeUseEntries(omitRequiredUseAliases(uses.optional, uses.required));
1994
- const usedApi = emptyApi();
1995
- mergeUseIntoApi(usedApi, required.usedApi);
1996
- mergeUseIntoApi(usedApi, optional.usedApi);
1997
- return {
1998
- manifestUses: {
1999
- ...(required.manifestUses ? { required: required.manifestUses } : {}),
2000
- ...(optional.manifestUses ? { optional: optional.manifestUses } : {}),
2001
- },
2002
- usedApi,
2003
- };
2004
- }
2005
- function emptyApi() {
2006
- return { rpc: {}, operations: {}, events: {}, feeds: {}, subjects: {} };
2007
- }
2008
- function addUniqueStrings(target, values) {
2009
- for (const value of values) {
2010
- if (!target.includes(value)) {
2011
- target.push(value);
2012
- }
2013
- }
2014
- }
2015
- function mergeUseIntoManifest(manifestUses, alias, use) {
2016
- const existing = manifestUses[alias];
2017
- if (!existing) {
2018
- manifestUses[alias] = use;
2019
- return;
2020
- }
2021
- if (existing.contract !== use.contract) {
2022
- throw new Error(`Contract use '${alias}' references both '${existing.contract}' and '${use.contract}'`);
2023
- }
2024
- const rpcCall = [...(existing.rpc?.call ?? [])];
2025
- addUniqueStrings(rpcCall, use.rpc?.call ?? []);
2026
- const operationsCall = [...(existing.operations?.call ?? [])];
2027
- addUniqueStrings(operationsCall, use.operations?.call ?? []);
2028
- const eventsPublish = [...(existing.events?.publish ?? [])];
2029
- addUniqueStrings(eventsPublish, use.events?.publish ?? []);
2030
- const eventsSubscribe = [...(existing.events?.subscribe ?? [])];
2031
- addUniqueStrings(eventsSubscribe, use.events?.subscribe ?? []);
2032
- const feedsSubscribe = [...(existing.feeds?.subscribe ?? [])];
2033
- addUniqueStrings(feedsSubscribe, use.feeds?.subscribe ?? []);
2034
- manifestUses[alias] = {
2035
- contract: existing.contract,
2036
- ...(rpcCall.length > 0 ? { rpc: { call: rpcCall } } : {}),
2037
- ...(operationsCall.length > 0
2038
- ? { operations: { call: operationsCall } }
2039
- : {}),
2040
- ...((eventsPublish.length > 0 || eventsSubscribe.length > 0)
2041
- ? {
2042
- events: {
2043
- ...(eventsPublish.length > 0 ? { publish: eventsPublish } : {}),
2044
- ...(eventsSubscribe.length > 0 ? { subscribe: eventsSubscribe } : {}),
2045
- },
2046
- }
2047
- : {}),
2048
- ...(feedsSubscribe.length > 0
2049
- ? { feeds: { subscribe: feedsSubscribe } }
2050
- : {}),
2051
- };
2052
- }
2053
- function mergeApiAllowDuplicateSubject(kind, out, next) {
2054
- for (const [key, value] of Object.entries(next)) {
2055
- const existing = out[key];
2056
- if (existing !== undefined) {
2057
- const existingSubject = typeof existing === "object" && existing !== null
2058
- ? existing.subject
2059
- : undefined;
2060
- const nextSubject = typeof value === "object" && value !== null
2061
- ? value.subject
2062
- : undefined;
2063
- if (typeof existingSubject === "string" && existingSubject === nextSubject) {
2064
- continue;
2065
- }
2066
- throw new Error(`Duplicate ${kind} key '${key}' while deriving contract API`);
2067
- }
2068
- out[key] = value;
2069
- }
2070
- }
2071
- function mergeUseIntoApi(target, api) {
2072
- mergeApiAllowDuplicateSubject("rpc", target.rpc, api.rpc);
2073
- mergeApiAllowDuplicateSubject("operations", target.operations, api.operations);
2074
- mergeApiAllowDuplicateSubject("events", target.events, api.events);
2075
- mergeApiAllowDuplicateSubject("feeds", target.feeds ?? {}, api.feeds ?? {});
2076
- mergeApiAllowDuplicateSubject("subjects", target.subjects, api.subjects);
2077
- }
2078
- function baselineUse(contract, use, api) {
2079
- return { manifestUse: { contract, ...use }, api };
2080
- }
2081
- function deriveImplicitTrellisUses(source) {
2082
- const uses = {};
2083
- if (source.kind === "app" || source.kind === "agent" || source.kind === "device") {
2084
- uses.auth = baselineUse(TRELLIS_AUTH_CONTRACT_ID, { rpc: { call: [...BASELINE_AUTH_RPC_CALL] } }, BASELINE_AUTH_API);
2085
- }
2086
- if (source.state) {
2087
- uses.state = baselineUse(TRELLIS_STATE_CONTRACT_ID, { rpc: { call: [...BASELINE_STATE_RPC_CALL] } }, BASELINE_STATE_API);
2088
- }
2089
- if ((source.kind === "service" || source.kind === "device") &&
2090
- source.id !== TRELLIS_HEALTH_CONTRACT_ID) {
2091
- uses.health = baselineUse(TRELLIS_HEALTH_CONTRACT_ID, { events: { publish: [...BASELINE_HEALTH_EVENTS_PUBLISH] } }, BASELINE_HEALTH_API);
2092
- }
2093
- return uses;
2094
- }
2095
- function normalizeContractUses(source) {
2096
- const explicit = normalizeUses(source.uses);
2097
- const usedApi = emptyApi();
2098
- mergeUseIntoApi(usedApi, explicit.usedApi);
2099
- const required = {
2100
- ...(explicit.manifestUses?.required ?? {}),
2101
- };
2102
- const optional = explicit.manifestUses?.optional
2103
- ? { ...explicit.manifestUses.optional }
2104
- : undefined;
2105
- for (const [alias, use] of Object.entries(deriveImplicitTrellisUses(source))) {
2106
- mergeUseIntoManifest(required, alias, use.manifestUse);
2107
- mergeUseIntoApi(usedApi, use.api);
2108
- }
2109
- return {
2110
- manifestUses: Object.keys(required).length > 0 ||
2111
- (optional && Object.keys(optional).length > 0)
2112
- ? {
2113
- ...(Object.keys(required).length > 0 ? { required } : {}),
2114
- ...(optional && Object.keys(optional).length > 0 ? { optional } : {}),
2115
- }
2116
- : undefined,
2117
- usedApi,
2118
- };
2119
- }
2120
- function selectedKeys(keys) {
2121
- return keys ?? [];
2122
- }
2123
- function mergeApiSection(kind, usedEntries, ownedEntries) {
2124
- const merged = {};
2125
- mergeRecord(kind, merged, usedEntries);
2126
- mergeRecord(kind, merged, ownedEntries);
2127
- return merged;
2128
- }
2129
- function mergeDerivedApis(ownedApi, usedApi) {
2130
- return {
2131
- rpc: mergeApiSection("rpc", usedApi.rpc, ownedApi.rpc),
2132
- operations: mergeApiSection("operations", usedApi.operations, ownedApi.operations),
2133
- events: mergeApiSection("events", usedApi.events, ownedApi.events),
2134
- feeds: mergeApiSection("feeds", usedApi.feeds ?? {}, ownedApi.feeds ?? {}),
2135
- subjects: mergeApiSection("subjects", usedApi.subjects, ownedApi.subjects),
2136
- };
2137
- }
2138
- function defineContract(registry, build) {
2139
- assertRegistryDoesNotDeclareExports(registry);
2140
- assertRegistryDoesNotDeclareCapabilities(registry);
2141
- const errorClasses = getErrorClassRegistry(registry.errors);
2142
- const normalizedErrors = normalizeErrorRegistry(registry.errors);
2143
- const body = build(createContractRefBuilder({
2144
- ...(registry.schemas ? { schemas: registry.schemas } : {}),
2145
- ...(errorClasses ? { errors: errorClasses } : {}),
2146
- }));
2147
- const materializedSchemas = materializeErrorSchemas(registry.schemas, normalizedErrors);
2148
- const source = {
2149
- ...body,
2150
- ...(materializedSchemas ? { schemas: materializedSchemas } : {}),
2151
- ...(normalizedErrors ? { errors: normalizedErrors } : {}),
2152
- };
2153
- assertExportedSchemasExist(source.schemas, source.exports);
2154
- const { manifestUses, usedApi } = normalizeContractUses(source);
2155
- const emittedSource = {
2156
- id: source.id,
2157
- displayName: source.displayName,
2158
- description: source.description,
2159
- ...(source.docs ? { docs: source.docs } : {}),
2160
- kind: source.kind,
2161
- ...(source.capabilities ? { capabilities: source.capabilities } : {}),
2162
- ...(source.schemas ? { schemas: source.schemas } : {}),
2163
- ...(source.exports ? { exports: source.exports } : {}),
2164
- ...(source.state ? { state: source.state } : {}),
2165
- ...(manifestUses ? { uses: manifestUses } : {}),
2166
- ...(source.rpc ? { rpc: source.rpc } : {}),
2167
- ...(source.operations ? { operations: source.operations } : {}),
2168
- ...(source.events ? { events: source.events } : {}),
2169
- ...(source.feeds ? { feeds: source.feeds } : {}),
2170
- ...(source.errors ? { errors: source.errors } : {}),
2171
- ...(source.jobs ? { jobs: source.jobs } : {}),
2172
- ...(source.eventConsumers ? { eventConsumers: source.eventConsumers } : {}),
2173
- ...(source.resources ? { resources: source.resources } : {}),
2174
- };
2175
- const ownedApi = buildOwnedApi(emittedSource);
2176
- const trellisApi = mergeDerivedApis(ownedApi, usedApi);
2177
- const CONTRACT = emitContract(emittedSource);
2178
- const CONTRACT_DIGEST = digestContractManifest(CONTRACT);
2179
- let contract;
2180
- contract = {
2181
- CONTRACT_ID: source.id,
2182
- CONTRACT,
2183
- CONTRACT_DIGEST,
2184
- API: {
2185
- owned: ownedApi,
2186
- used: usedApi,
2187
- trellis: trellisApi,
2188
- },
2189
- use: createUseHelper(() => contract),
2190
- [exports.CONTRACT_JOBS_METADATA]: buildContractJobsMetadata(source.jobs),
2191
- [exports.CONTRACT_KV_METADATA]: buildContractKvMetadata(source.resources, source.schemas),
2192
- [exports.CONTRACT_STATE_METADATA]: buildContractStateMetadata(source.state, source.schemas),
2193
- };
2194
- return contract;
2195
- }
2196
- function defineServiceContract(registry, build) {
2197
- return defineContract(registry, (ref) => ({
2198
- ...build(ref),
2199
- kind: "service",
2200
- }));
2201
- }
2202
- function defineClientContract(kind, registry, build) {
2203
- return defineContract(registry, (ref) => ({ ...build(ref), kind }));
2204
- }
2205
- function defineAppContract(...args) {
2206
- const [registryOrBuild, maybeBuild] = args;
2207
- if (typeof registryOrBuild === "function") {
2208
- return defineClientContract("app", {}, () => registryOrBuild());
2209
- }
2210
- return defineClientContract("app", registryOrBuild, maybeBuild);
2211
- }
2212
- function defineAgentContract(...args) {
2213
- const [registryOrBuild, maybeBuild] = args;
2214
- if (typeof registryOrBuild === "function") {
2215
- return defineClientContract("agent", {}, () => registryOrBuild());
2216
- }
2217
- return defineClientContract("agent", registryOrBuild, maybeBuild);
2218
- }
2219
- function defineDeviceContract(...args) {
2220
- const [registryOrBuild, maybeBuild] = args;
2221
- if (typeof registryOrBuild === "function") {
2222
- return defineClientContract("device", {}, () => registryOrBuild());
2223
- }
2224
- return defineClientContract("device", registryOrBuild, maybeBuild);
2225
- }