reactor-effect-client 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (514) hide show
  1. package/NOTICE +7 -2
  2. package/README.md +103 -141
  3. package/dist/Coordinator.d.ts +382 -0
  4. package/dist/Coordinator.d.ts.map +1 -0
  5. package/dist/Coordinator.js +732 -0
  6. package/dist/Coordinator.js.map +1 -0
  7. package/dist/H3.d.ts +159 -0
  8. package/dist/H3.d.ts.map +1 -0
  9. package/dist/H3.js +21 -0
  10. package/dist/H3.js.map +1 -0
  11. package/dist/H3Source.d.ts +93 -0
  12. package/dist/H3Source.d.ts.map +1 -0
  13. package/dist/H3Source.js +401 -0
  14. package/dist/H3Source.js.map +1 -0
  15. package/dist/LocalSource.d.ts +68 -0
  16. package/dist/LocalSource.d.ts.map +1 -0
  17. package/dist/LocalSource.js +354 -0
  18. package/dist/LocalSource.js.map +1 -0
  19. package/dist/Media.d.ts +106 -0
  20. package/dist/Media.d.ts.map +1 -0
  21. package/dist/Media.js +16 -0
  22. package/dist/Media.js.map +1 -0
  23. package/dist/Peer.d.ts +134 -0
  24. package/dist/Peer.d.ts.map +1 -0
  25. package/dist/Peer.js +57 -0
  26. package/dist/Peer.js.map +1 -0
  27. package/dist/Playout.d.ts +724 -0
  28. package/dist/Playout.d.ts.map +1 -0
  29. package/dist/Playout.js +28 -0
  30. package/dist/Playout.js.map +1 -0
  31. package/dist/Reactor.d.ts +135 -0
  32. package/dist/Reactor.d.ts.map +1 -0
  33. package/dist/Reactor.js +158 -0
  34. package/dist/Reactor.js.map +1 -0
  35. package/dist/ReactorError.d.ts +331 -0
  36. package/dist/ReactorError.d.ts.map +1 -0
  37. package/dist/ReactorError.js +316 -0
  38. package/dist/ReactorError.js.map +1 -0
  39. package/dist/ReactorTest.d.ts +383 -0
  40. package/dist/ReactorTest.d.ts.map +1 -0
  41. package/dist/ReactorTest.js +317 -0
  42. package/dist/ReactorTest.js.map +1 -0
  43. package/dist/Session.d.ts +314 -0
  44. package/dist/Session.d.ts.map +1 -0
  45. package/dist/Session.js +51 -0
  46. package/dist/Session.js.map +1 -0
  47. package/dist/index.d.ts +12 -22
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +12 -11
  50. package/dist/index.js.map +1 -1
  51. package/dist/internal/correlator.d.ts +46 -0
  52. package/dist/internal/correlator.d.ts.map +1 -0
  53. package/dist/internal/correlator.js +150 -0
  54. package/dist/internal/correlator.js.map +1 -0
  55. package/dist/internal/deadline.d.ts +24 -0
  56. package/dist/internal/deadline.d.ts.map +1 -0
  57. package/dist/internal/deadline.js +44 -0
  58. package/dist/internal/deadline.js.map +1 -0
  59. package/dist/{h3/_internal/contracts.d.ts → internal/h3/commands.d.ts} +39 -33
  60. package/dist/internal/h3/commands.d.ts.map +1 -0
  61. package/dist/internal/h3/commands.js +128 -0
  62. package/dist/internal/h3/commands.js.map +1 -0
  63. package/dist/{h3 → internal/h3}/messages.d.ts +16 -11
  64. package/dist/internal/h3/messages.d.ts.map +1 -0
  65. package/dist/{h3 → internal/h3}/messages.js +19 -31
  66. package/dist/internal/h3/messages.js.map +1 -0
  67. package/dist/internal/h3/operations.d.ts +145 -0
  68. package/dist/internal/h3/operations.d.ts.map +1 -0
  69. package/dist/internal/h3/operations.js +284 -0
  70. package/dist/internal/h3/operations.js.map +1 -0
  71. package/dist/{h3 → internal/h3}/profile.d.ts +63 -65
  72. package/dist/internal/h3/profile.d.ts.map +1 -0
  73. package/dist/{h3 → internal/h3}/profile.js +39 -39
  74. package/dist/internal/h3/profile.js.map +1 -0
  75. package/dist/internal/h3/provider.d.ts +14 -0
  76. package/dist/internal/h3/provider.d.ts.map +1 -0
  77. package/dist/internal/h3/provider.js +672 -0
  78. package/dist/internal/h3/provider.js.map +1 -0
  79. package/dist/internal/h3/references.d.ts +68 -0
  80. package/dist/internal/h3/references.d.ts.map +1 -0
  81. package/dist/internal/h3/references.js +339 -0
  82. package/dist/internal/h3/references.js.map +1 -0
  83. package/dist/internal/h3/request.d.ts +56 -0
  84. package/dist/internal/h3/request.d.ts.map +1 -0
  85. package/dist/internal/h3/request.js +70 -0
  86. package/dist/internal/h3/request.js.map +1 -0
  87. package/dist/internal/h3/state.d.ts +120 -0
  88. package/dist/internal/h3/state.d.ts.map +1 -0
  89. package/dist/internal/h3/state.js +270 -0
  90. package/dist/internal/h3/state.js.map +1 -0
  91. package/dist/{Submission.d.ts → internal/h3/submission.d.ts} +1 -3
  92. package/dist/internal/h3/submission.d.ts.map +1 -0
  93. package/dist/{Submission.js → internal/h3/submission.js} +1 -9
  94. package/dist/internal/h3/submission.js.map +1 -0
  95. package/dist/internal/hub.d.ts +32 -0
  96. package/dist/internal/hub.d.ts.map +1 -0
  97. package/dist/internal/hub.js +92 -0
  98. package/dist/internal/hub.js.map +1 -0
  99. package/dist/internal/playout/errors.d.ts +51 -0
  100. package/dist/internal/playout/errors.d.ts.map +1 -0
  101. package/dist/internal/playout/errors.js +40 -0
  102. package/dist/internal/playout/errors.js.map +1 -0
  103. package/dist/internal/playout/policy.d.ts +559 -0
  104. package/dist/internal/playout/policy.d.ts.map +1 -0
  105. package/dist/internal/playout/policy.js +2338 -0
  106. package/dist/internal/playout/policy.js.map +1 -0
  107. package/dist/internal/playout/runtime.d.ts +28 -0
  108. package/dist/internal/playout/runtime.d.ts.map +1 -0
  109. package/dist/internal/playout/runtime.js +766 -0
  110. package/dist/internal/playout/runtime.js.map +1 -0
  111. package/dist/internal/playout/tag.d.ts +14 -0
  112. package/dist/internal/playout/tag.d.ts.map +1 -0
  113. package/dist/internal/playout/tag.js +43 -0
  114. package/dist/internal/playout/tag.js.map +1 -0
  115. package/dist/internal/proto/reactor_wire/v1/common_pb.d.ts +55 -0
  116. package/dist/internal/proto/reactor_wire/v1/common_pb.d.ts.map +1 -0
  117. package/dist/internal/proto/reactor_wire/v1/common_pb.js +42 -0
  118. package/dist/internal/proto/reactor_wire/v1/common_pb.js.map +1 -0
  119. package/dist/internal/proto/reactor_wire/v1/control_pb.d.ts +160 -0
  120. package/dist/internal/proto/reactor_wire/v1/control_pb.d.ts.map +1 -0
  121. package/dist/internal/proto/reactor_wire/v1/control_pb.js +21 -0
  122. package/dist/internal/proto/reactor_wire/v1/control_pb.js.map +1 -0
  123. package/dist/internal/proto/reactor_wire/v1/data_pb.d.ts +89 -0
  124. package/dist/internal/proto/reactor_wire/v1/data_pb.d.ts.map +1 -0
  125. package/dist/internal/proto/reactor_wire/v1/data_pb.js +20 -0
  126. package/dist/internal/proto/reactor_wire/v1/data_pb.js.map +1 -0
  127. package/dist/internal/proto/reactor_wire/v1/model_pb.d.ts +85 -0
  128. package/dist/internal/proto/reactor_wire/v1/model_pb.d.ts.map +1 -0
  129. package/dist/internal/proto/reactor_wire/v1/model_pb.js +24 -0
  130. package/dist/internal/proto/reactor_wire/v1/model_pb.js.map +1 -0
  131. package/dist/internal/proto/reactor_wire/v1/platform_pb.d.ts +190 -0
  132. package/dist/internal/proto/reactor_wire/v1/platform_pb.d.ts.map +1 -0
  133. package/dist/internal/proto/reactor_wire/v1/platform_pb.js +54 -0
  134. package/dist/internal/proto/reactor_wire/v1/platform_pb.js.map +1 -0
  135. package/dist/internal/proto/reactor_wire/v1/track_pb.d.ts +88 -0
  136. package/dist/internal/proto/reactor_wire/v1/track_pb.d.ts.map +1 -0
  137. package/dist/internal/proto/reactor_wire/v1/track_pb.js +33 -0
  138. package/dist/internal/proto/reactor_wire/v1/track_pb.js.map +1 -0
  139. package/dist/internal/queue.d.ts +4 -0
  140. package/dist/internal/queue.d.ts.map +1 -0
  141. package/dist/{_internal → internal}/queue.js +0 -9
  142. package/dist/internal/queue.js.map +1 -0
  143. package/dist/internal/reactorTest/coordinator.d.ts +5 -0
  144. package/dist/internal/reactorTest/coordinator.d.ts.map +1 -0
  145. package/dist/internal/reactorTest/coordinator.js +178 -0
  146. package/dist/internal/reactorTest/coordinator.js.map +1 -0
  147. package/dist/internal/reactorTest/faults.d.ts +172 -0
  148. package/dist/internal/reactorTest/faults.d.ts.map +1 -0
  149. package/dist/internal/reactorTest/faults.js +23 -0
  150. package/dist/internal/reactorTest/faults.js.map +1 -0
  151. package/dist/internal/reactorTest/h3.d.ts +431 -0
  152. package/dist/internal/reactorTest/h3.d.ts.map +1 -0
  153. package/dist/internal/reactorTest/h3.js +625 -0
  154. package/dist/internal/reactorTest/h3.js.map +1 -0
  155. package/dist/internal/reactorTest/media.d.ts +22 -0
  156. package/dist/internal/reactorTest/media.d.ts.map +1 -0
  157. package/dist/internal/reactorTest/media.js +34 -0
  158. package/dist/internal/reactorTest/media.js.map +1 -0
  159. package/dist/internal/reactorTest/peer.d.ts +318 -0
  160. package/dist/internal/reactorTest/peer.d.ts.map +1 -0
  161. package/dist/internal/reactorTest/peer.js +206 -0
  162. package/dist/internal/reactorTest/peer.js.map +1 -0
  163. package/dist/internal/reactorTest/playout.d.ts +34 -0
  164. package/dist/internal/reactorTest/playout.d.ts.map +1 -0
  165. package/dist/internal/reactorTest/playout.js +340 -0
  166. package/dist/internal/reactorTest/playout.js.map +1 -0
  167. package/dist/internal/reactorTest/references.d.ts +25 -0
  168. package/dist/internal/reactorTest/references.d.ts.map +1 -0
  169. package/dist/{testing/Png.js → internal/reactorTest/references.js} +50 -12
  170. package/dist/internal/reactorTest/references.js.map +1 -0
  171. package/dist/internal/reactorTest/sessions.d.ts +364 -0
  172. package/dist/internal/reactorTest/sessions.d.ts.map +1 -0
  173. package/dist/internal/reactorTest/sessions.js +592 -0
  174. package/dist/internal/reactorTest/sessions.js.map +1 -0
  175. package/dist/internal/reactorTest/timing.d.ts +13 -0
  176. package/dist/internal/reactorTest/timing.d.ts.map +1 -0
  177. package/dist/internal/reactorTest/timing.js +20 -0
  178. package/dist/internal/reactorTest/timing.js.map +1 -0
  179. package/dist/internal/recording.d.ts +52 -0
  180. package/dist/internal/recording.d.ts.map +1 -0
  181. package/dist/internal/recording.js +141 -0
  182. package/dist/internal/recording.js.map +1 -0
  183. package/dist/internal/session/connect.d.ts +34 -0
  184. package/dist/internal/session/connect.d.ts.map +1 -0
  185. package/dist/internal/session/connect.js +502 -0
  186. package/dist/internal/session/connect.js.map +1 -0
  187. package/dist/internal/session/generation.d.ts +35 -0
  188. package/dist/internal/session/generation.d.ts.map +1 -0
  189. package/dist/internal/session/generation.js +185 -0
  190. package/dist/internal/session/generation.js.map +1 -0
  191. package/dist/internal/session/ice.d.ts +23 -0
  192. package/dist/internal/session/ice.d.ts.map +1 -0
  193. package/dist/internal/session/ice.js +57 -0
  194. package/dist/internal/session/ice.js.map +1 -0
  195. package/dist/internal/session/inbound.d.ts +50 -0
  196. package/dist/internal/session/inbound.d.ts.map +1 -0
  197. package/dist/internal/session/inbound.js +202 -0
  198. package/dist/internal/session/inbound.js.map +1 -0
  199. package/dist/internal/session/model.d.ts +163 -0
  200. package/dist/internal/session/model.d.ts.map +1 -0
  201. package/dist/internal/session/model.js +78 -0
  202. package/dist/internal/session/model.js.map +1 -0
  203. package/dist/internal/session/requests.d.ts +71 -0
  204. package/dist/internal/session/requests.d.ts.map +1 -0
  205. package/dist/internal/session/requests.js +240 -0
  206. package/dist/internal/session/requests.js.map +1 -0
  207. package/dist/internal/session/tracks.d.ts +21 -0
  208. package/dist/internal/session/tracks.d.ts.map +1 -0
  209. package/dist/internal/session/tracks.js +166 -0
  210. package/dist/internal/session/tracks.js.map +1 -0
  211. package/dist/internal/session/upload.d.ts +21 -0
  212. package/dist/internal/session/upload.d.ts.map +1 -0
  213. package/dist/internal/session/upload.js +68 -0
  214. package/dist/internal/session/upload.js.map +1 -0
  215. package/dist/internal/session.d.ts +66 -0
  216. package/dist/internal/session.d.ts.map +1 -0
  217. package/dist/internal/session.js +280 -0
  218. package/dist/internal/session.js.map +1 -0
  219. package/dist/{stats.d.ts → internal/stats.d.ts} +30 -16
  220. package/dist/internal/stats.d.ts.map +1 -0
  221. package/dist/internal/stats.js +201 -0
  222. package/dist/internal/stats.js.map +1 -0
  223. package/dist/internal/token.d.ts +22 -0
  224. package/dist/internal/token.d.ts.map +1 -0
  225. package/dist/internal/token.js +65 -0
  226. package/dist/internal/token.js.map +1 -0
  227. package/dist/internal/wire.d.ts +37 -0
  228. package/dist/internal/wire.d.ts.map +1 -0
  229. package/dist/internal/wire.js +49 -0
  230. package/dist/internal/wire.js.map +1 -0
  231. package/notices/bufbuild-protobuf-LICENSE +201 -0
  232. package/package.json +17 -38
  233. package/dist/FetchHttp.d.ts +0 -9
  234. package/dist/FetchHttp.d.ts.map +0 -1
  235. package/dist/FetchHttp.js +0 -63
  236. package/dist/FetchHttp.js.map +0 -1
  237. package/dist/PeerFactory.d.ts +0 -26
  238. package/dist/PeerFactory.d.ts.map +0 -1
  239. package/dist/PeerFactory.js +0 -4
  240. package/dist/PeerFactory.js.map +0 -1
  241. package/dist/PeerTypes.d.ts +0 -64
  242. package/dist/PeerTypes.d.ts.map +0 -1
  243. package/dist/PeerTypes.js +0 -2
  244. package/dist/PeerTypes.js.map +0 -1
  245. package/dist/Sequence.d.ts +0 -85
  246. package/dist/Sequence.d.ts.map +0 -1
  247. package/dist/Sequence.js +0 -210
  248. package/dist/Sequence.js.map +0 -1
  249. package/dist/SessionTypes.d.ts +0 -312
  250. package/dist/SessionTypes.d.ts.map +0 -1
  251. package/dist/SessionTypes.js +0 -19
  252. package/dist/SessionTypes.js.map +0 -1
  253. package/dist/Submission.d.ts.map +0 -1
  254. package/dist/Submission.js.map +0 -1
  255. package/dist/_internal/queue.d.ts +0 -6
  256. package/dist/_internal/queue.d.ts.map +0 -1
  257. package/dist/_internal/queue.js.map +0 -1
  258. package/dist/bytes.d.ts +0 -6
  259. package/dist/bytes.d.ts.map +0 -1
  260. package/dist/bytes.js +0 -32
  261. package/dist/bytes.js.map +0 -1
  262. package/dist/contract.d.ts +0 -149
  263. package/dist/contract.d.ts.map +0 -1
  264. package/dist/contract.js +0 -119
  265. package/dist/contract.js.map +0 -1
  266. package/dist/coordinator/_internal/client.d.ts +0 -215
  267. package/dist/coordinator/_internal/client.d.ts.map +0 -1
  268. package/dist/coordinator/_internal/client.js +0 -563
  269. package/dist/coordinator/_internal/client.js.map +0 -1
  270. package/dist/coordinator/_internal/recording.d.ts +0 -31
  271. package/dist/coordinator/_internal/recording.d.ts.map +0 -1
  272. package/dist/coordinator/_internal/recording.js +0 -123
  273. package/dist/coordinator/_internal/recording.js.map +0 -1
  274. package/dist/coordinator/_internal/response.d.ts +0 -15
  275. package/dist/coordinator/_internal/response.d.ts.map +0 -1
  276. package/dist/coordinator/_internal/response.js +0 -55
  277. package/dist/coordinator/_internal/response.js.map +0 -1
  278. package/dist/coordinator/_internal/schemas.d.ts +0 -73
  279. package/dist/coordinator/_internal/schemas.d.ts.map +0 -1
  280. package/dist/coordinator/_internal/schemas.js +0 -200
  281. package/dist/coordinator/_internal/schemas.js.map +0 -1
  282. package/dist/coordinator/index.d.ts +0 -40
  283. package/dist/coordinator/index.d.ts.map +0 -1
  284. package/dist/coordinator/index.js +0 -21
  285. package/dist/coordinator/index.js.map +0 -1
  286. package/dist/correlation.d.ts +0 -47
  287. package/dist/correlation.d.ts.map +0 -1
  288. package/dist/correlation.js +0 -131
  289. package/dist/correlation.js.map +0 -1
  290. package/dist/duration.d.ts +0 -27
  291. package/dist/duration.d.ts.map +0 -1
  292. package/dist/duration.js +0 -47
  293. package/dist/duration.js.map +0 -1
  294. package/dist/errors.d.ts +0 -1303
  295. package/dist/errors.d.ts.map +0 -1
  296. package/dist/errors.js +0 -745
  297. package/dist/errors.js.map +0 -1
  298. package/dist/h3/_internal/client.d.ts +0 -9
  299. package/dist/h3/_internal/client.d.ts.map +0 -1
  300. package/dist/h3/_internal/client.js +0 -652
  301. package/dist/h3/_internal/client.js.map +0 -1
  302. package/dist/h3/_internal/contracts.d.ts.map +0 -1
  303. package/dist/h3/_internal/contracts.js +0 -123
  304. package/dist/h3/_internal/contracts.js.map +0 -1
  305. package/dist/h3/_internal/deployment.d.ts +0 -8
  306. package/dist/h3/_internal/deployment.d.ts.map +0 -1
  307. package/dist/h3/_internal/deployment.js +0 -149
  308. package/dist/h3/_internal/deployment.js.map +0 -1
  309. package/dist/h3/_internal/evidence.d.ts +0 -17
  310. package/dist/h3/_internal/evidence.d.ts.map +0 -1
  311. package/dist/h3/_internal/evidence.js +0 -48
  312. package/dist/h3/_internal/evidence.js.map +0 -1
  313. package/dist/h3/_internal/operations.d.ts +0 -58
  314. package/dist/h3/_internal/operations.d.ts.map +0 -1
  315. package/dist/h3/_internal/operations.js +0 -268
  316. package/dist/h3/_internal/operations.js.map +0 -1
  317. package/dist/h3/_internal/references.d.ts +0 -24
  318. package/dist/h3/_internal/references.d.ts.map +0 -1
  319. package/dist/h3/_internal/references.js +0 -309
  320. package/dist/h3/_internal/references.js.map +0 -1
  321. package/dist/h3/_internal/request.d.ts +0 -21
  322. package/dist/h3/_internal/request.d.ts.map +0 -1
  323. package/dist/h3/_internal/request.js +0 -97
  324. package/dist/h3/_internal/request.js.map +0 -1
  325. package/dist/h3/_internal/retained.d.ts +0 -22
  326. package/dist/h3/_internal/retained.d.ts.map +0 -1
  327. package/dist/h3/_internal/retained.js +0 -89
  328. package/dist/h3/_internal/retained.js.map +0 -1
  329. package/dist/h3/_internal/state.d.ts +0 -44
  330. package/dist/h3/_internal/state.d.ts.map +0 -1
  331. package/dist/h3/_internal/state.js +0 -283
  332. package/dist/h3/_internal/state.js.map +0 -1
  333. package/dist/h3/index.d.ts +0 -10
  334. package/dist/h3/index.d.ts.map +0 -1
  335. package/dist/h3/index.js +0 -7
  336. package/dist/h3/index.js.map +0 -1
  337. package/dist/h3/messages.d.ts.map +0 -1
  338. package/dist/h3/messages.js.map +0 -1
  339. package/dist/h3/profile.d.ts.map +0 -1
  340. package/dist/h3/profile.js.map +0 -1
  341. package/dist/h3/types.d.ts +0 -291
  342. package/dist/h3/types.d.ts.map +0 -1
  343. package/dist/h3/types.js +0 -2
  344. package/dist/h3/types.js.map +0 -1
  345. package/dist/host.d.ts +0 -26
  346. package/dist/host.d.ts.map +0 -1
  347. package/dist/host.js +0 -20
  348. package/dist/host.js.map +0 -1
  349. package/dist/json.d.ts +0 -25
  350. package/dist/json.d.ts.map +0 -1
  351. package/dist/json.js +0 -143
  352. package/dist/json.js.map +0 -1
  353. package/dist/media-stream.d.ts +0 -10
  354. package/dist/media-stream.d.ts.map +0 -1
  355. package/dist/media-stream.js +0 -18
  356. package/dist/media-stream.js.map +0 -1
  357. package/dist/observation.d.ts +0 -38
  358. package/dist/observation.d.ts.map +0 -1
  359. package/dist/observation.js +0 -113
  360. package/dist/observation.js.map +0 -1
  361. package/dist/orchestration/elapsed.d.ts +0 -9
  362. package/dist/orchestration/elapsed.d.ts.map +0 -1
  363. package/dist/orchestration/elapsed.js +0 -8
  364. package/dist/orchestration/elapsed.js.map +0 -1
  365. package/dist/orchestration/h3-source.d.ts +0 -58
  366. package/dist/orchestration/h3-source.d.ts.map +0 -1
  367. package/dist/orchestration/h3-source.js +0 -362
  368. package/dist/orchestration/h3-source.js.map +0 -1
  369. package/dist/orchestration/index.d.ts +0 -17
  370. package/dist/orchestration/index.d.ts.map +0 -1
  371. package/dist/orchestration/index.js +0 -12
  372. package/dist/orchestration/index.js.map +0 -1
  373. package/dist/orchestration/media-buffer.d.ts +0 -32
  374. package/dist/orchestration/media-buffer.d.ts.map +0 -1
  375. package/dist/orchestration/media-buffer.js +0 -94
  376. package/dist/orchestration/media-buffer.js.map +0 -1
  377. package/dist/orchestration/open-h3.d.ts +0 -101
  378. package/dist/orchestration/open-h3.d.ts.map +0 -1
  379. package/dist/orchestration/open-h3.js +0 -127
  380. package/dist/orchestration/open-h3.js.map +0 -1
  381. package/dist/orchestration/queries.d.ts +0 -10
  382. package/dist/orchestration/queries.d.ts.map +0 -1
  383. package/dist/orchestration/queries.js +0 -43
  384. package/dist/orchestration/queries.js.map +0 -1
  385. package/dist/orchestration/references.d.ts +0 -18
  386. package/dist/orchestration/references.d.ts.map +0 -1
  387. package/dist/orchestration/references.js +0 -79
  388. package/dist/orchestration/references.js.map +0 -1
  389. package/dist/orchestration/renewal-state.d.ts +0 -84
  390. package/dist/orchestration/renewal-state.d.ts.map +0 -1
  391. package/dist/orchestration/renewal-state.js +0 -95
  392. package/dist/orchestration/renewal-state.js.map +0 -1
  393. package/dist/orchestration/renewal.d.ts +0 -103
  394. package/dist/orchestration/renewal.d.ts.map +0 -1
  395. package/dist/orchestration/renewal.js +0 -1088
  396. package/dist/orchestration/renewal.js.map +0 -1
  397. package/dist/orchestration/request.d.ts +0 -65
  398. package/dist/orchestration/request.d.ts.map +0 -1
  399. package/dist/orchestration/request.js +0 -134
  400. package/dist/orchestration/request.js.map +0 -1
  401. package/dist/orchestration/retention.d.ts +0 -100
  402. package/dist/orchestration/retention.d.ts.map +0 -1
  403. package/dist/orchestration/retention.js +0 -134
  404. package/dist/orchestration/retention.js.map +0 -1
  405. package/dist/orchestration/routing.d.ts +0 -21
  406. package/dist/orchestration/routing.d.ts.map +0 -1
  407. package/dist/orchestration/routing.js +0 -93
  408. package/dist/orchestration/routing.js.map +0 -1
  409. package/dist/orchestration/scheduler-key.d.ts +0 -14
  410. package/dist/orchestration/scheduler-key.d.ts.map +0 -1
  411. package/dist/orchestration/scheduler-key.js +0 -62
  412. package/dist/orchestration/scheduler-key.js.map +0 -1
  413. package/dist/orchestration/scheduler-policy.d.ts +0 -222
  414. package/dist/orchestration/scheduler-policy.d.ts.map +0 -1
  415. package/dist/orchestration/scheduler-policy.js +0 -582
  416. package/dist/orchestration/scheduler-policy.js.map +0 -1
  417. package/dist/orchestration/scheduler.d.ts +0 -383
  418. package/dist/orchestration/scheduler.d.ts.map +0 -1
  419. package/dist/orchestration/scheduler.js +0 -2597
  420. package/dist/orchestration/scheduler.js.map +0 -1
  421. package/dist/orchestration/source-slot.d.ts +0 -124
  422. package/dist/orchestration/source-slot.d.ts.map +0 -1
  423. package/dist/orchestration/source-slot.js +0 -348
  424. package/dist/orchestration/source-slot.js.map +0 -1
  425. package/dist/orchestration/types.d.ts +0 -1462
  426. package/dist/orchestration/types.d.ts.map +0 -1
  427. package/dist/orchestration/types.js +0 -135
  428. package/dist/orchestration/types.js.map +0 -1
  429. package/dist/protobuf.d.ts +0 -63
  430. package/dist/protobuf.d.ts.map +0 -1
  431. package/dist/protobuf.js +0 -252
  432. package/dist/protobuf.js.map +0 -1
  433. package/dist/session/_internal/acquire.d.ts +0 -21
  434. package/dist/session/_internal/acquire.d.ts.map +0 -1
  435. package/dist/session/_internal/acquire.js +0 -168
  436. package/dist/session/_internal/acquire.js.map +0 -1
  437. package/dist/session/_internal/cleanup.d.ts +0 -19
  438. package/dist/session/_internal/cleanup.d.ts.map +0 -1
  439. package/dist/session/_internal/cleanup.js +0 -102
  440. package/dist/session/_internal/cleanup.js.map +0 -1
  441. package/dist/session/_internal/lifecycle.d.ts +0 -67
  442. package/dist/session/_internal/lifecycle.d.ts.map +0 -1
  443. package/dist/session/_internal/lifecycle.js +0 -142
  444. package/dist/session/_internal/lifecycle.js.map +0 -1
  445. package/dist/session/_internal/remote.d.ts +0 -28
  446. package/dist/session/_internal/remote.d.ts.map +0 -1
  447. package/dist/session/_internal/remote.js +0 -71
  448. package/dist/session/_internal/remote.js.map +0 -1
  449. package/dist/session/_internal/uploads.d.ts +0 -7
  450. package/dist/session/_internal/uploads.d.ts.map +0 -1
  451. package/dist/session/_internal/uploads.js +0 -31
  452. package/dist/session/_internal/uploads.js.map +0 -1
  453. package/dist/session/commands.d.ts +0 -2
  454. package/dist/session/commands.d.ts.map +0 -1
  455. package/dist/session/commands.js +0 -2
  456. package/dist/session/commands.js.map +0 -1
  457. package/dist/session/files.d.ts +0 -21
  458. package/dist/session/files.d.ts.map +0 -1
  459. package/dist/session/files.js +0 -49
  460. package/dist/session/files.js.map +0 -1
  461. package/dist/session/index.d.ts +0 -84
  462. package/dist/session/index.d.ts.map +0 -1
  463. package/dist/session/index.js +0 -16
  464. package/dist/session/index.js.map +0 -1
  465. package/dist/session/media.d.ts +0 -114
  466. package/dist/session/media.d.ts.map +0 -1
  467. package/dist/session/media.js +0 -2
  468. package/dist/session/media.js.map +0 -1
  469. package/dist/session/recorder.d.ts +0 -24
  470. package/dist/session/recorder.d.ts.map +0 -1
  471. package/dist/session/recorder.js +0 -19
  472. package/dist/session/recorder.js.map +0 -1
  473. package/dist/session.d.ts +0 -105
  474. package/dist/session.d.ts.map +0 -1
  475. package/dist/session.js +0 -976
  476. package/dist/session.js.map +0 -1
  477. package/dist/simulation/_internal/source.d.ts +0 -12
  478. package/dist/simulation/_internal/source.d.ts.map +0 -1
  479. package/dist/simulation/_internal/source.js +0 -513
  480. package/dist/simulation/_internal/source.js.map +0 -1
  481. package/dist/simulation/index.d.ts +0 -13
  482. package/dist/simulation/index.d.ts.map +0 -1
  483. package/dist/simulation/index.js +0 -12
  484. package/dist/simulation/index.js.map +0 -1
  485. package/dist/simulation/types.d.ts +0 -39
  486. package/dist/simulation/types.d.ts.map +0 -1
  487. package/dist/simulation/types.js +0 -2
  488. package/dist/simulation/types.js.map +0 -1
  489. package/dist/stats.d.ts.map +0 -1
  490. package/dist/stats.js +0 -205
  491. package/dist/stats.js.map +0 -1
  492. package/dist/testing/Faults.d.ts +0 -4
  493. package/dist/testing/Faults.d.ts.map +0 -1
  494. package/dist/testing/Faults.js +0 -7
  495. package/dist/testing/Faults.js.map +0 -1
  496. package/dist/testing/Png.d.ts +0 -3
  497. package/dist/testing/Png.d.ts.map +0 -1
  498. package/dist/testing/Png.js.map +0 -1
  499. package/dist/testing/Wav.d.ts +0 -14
  500. package/dist/testing/Wav.d.ts.map +0 -1
  501. package/dist/testing/Wav.js +0 -37
  502. package/dist/testing/Wav.js.map +0 -1
  503. package/dist/testing/index.d.ts +0 -5
  504. package/dist/testing/index.d.ts.map +0 -1
  505. package/dist/testing/index.js +0 -4
  506. package/dist/testing/index.js.map +0 -1
  507. package/dist/wire.d.ts +0 -7
  508. package/dist/wire.d.ts.map +0 -1
  509. package/dist/wire.generated.d.ts +0 -305
  510. package/dist/wire.generated.d.ts.map +0 -1
  511. package/dist/wire.generated.js +0 -1257
  512. package/dist/wire.generated.js.map +0 -1
  513. package/dist/wire.js +0 -5
  514. package/dist/wire.js.map +0 -1
@@ -0,0 +1,724 @@
1
+ /**
2
+ * Plays a schedule of clips to air across Reactor sessions. Applications submit
3
+ * keyed items into priority lanes; one plan decides what to build, in what
4
+ * order, what to withdraw, and when a renewing session takes over; each
5
+ * session only executes its window of that plan. What actually aired is
6
+ * reported as as-run evidence, kept apart from what was asked for.
7
+ *
8
+ * A pure policy makes every decision. The service applies them one command at
9
+ * a time on each session, wakes on a submission, a session's evidence or the
10
+ * policy's next deadline, and never polls. Sessions are supplied by an `open`
11
+ * effect, such as `H3Source.open`, so the same plan runs on paid H3, a local
12
+ * renderer (`LocalSource`) or the simulated Reactor in `ReactorTest`.
13
+ */
14
+ import * as Context from "effect/Context";
15
+ import type * as Duration from "effect/Duration";
16
+ import type * as Effect from "effect/Effect";
17
+ import * as Layer from "effect/Layer";
18
+ import type * as Redacted from "effect/Redacted";
19
+ import type * as Scope from "effect/Scope";
20
+ import type * as Stream from "effect/Stream";
21
+ import type { Request } from "./H3.js";
22
+ import type { InvalidFiller, InvalidItem, ItemKey, PlayoutClosed, SubmitError } from "./internal/playout/errors.js";
23
+ import type { AudioFrame, MediaPressure, VideoFrame } from "./Media.js";
24
+ import type { CommandFailure, ReactorError, ReactorFailure } from "./ReactorError.js";
25
+ import type { CloseReport } from "./Session.js";
26
+ export { InvalidFiller, InvalidItem, ItemKey, KeyMismatch, LaneBusy, PlayoutClosed, WouldMissDeadline, } from "./internal/playout/errors.js";
27
+ export type { SubmitError } from "./internal/playout/errors.js";
28
+ export interface LaneSpec {
29
+ /** Lanes are listed from the highest priority to the lowest. */
30
+ readonly name: string;
31
+ /**
32
+ * What a new item does to its lane's waiting items: wait behind them (the
33
+ * default); replace them, make-before-break, so they stay as cover until it
34
+ * is Ready and then settle `Dropped` as `replaced`; or be refused with
35
+ * `LaneBusy` while the lane has an item waiting or playing.
36
+ */
37
+ readonly conflict?: "queue" | "replace" | "skip" | undefined;
38
+ /**
39
+ * A Ready item of this lane stops a playing clip of a strictly lower lane, or
40
+ * filler, instead of waiting for its end, unless that clip ends within a
41
+ * second. A clip is stopped at most once, and a stopped clip cannot resume.
42
+ */
43
+ readonly cut?: boolean | undefined;
44
+ }
45
+ /** When an item may air. Only `Follow` keeps its lane's order. */
46
+ export type Start =
47
+ /** The next boundary its lane reaches, in order: the default. */
48
+ {
49
+ readonly _tag: "Follow";
50
+ }
51
+ /** The next boundary, ahead of everything waiting in every lane. */
52
+ | {
53
+ readonly _tag: "Asap";
54
+ }
55
+ /** Built ahead and held until `release(key)`, then as `Asap`. */
56
+ | {
57
+ readonly _tag: "Manual";
58
+ } | {
59
+ readonly _tag: "At";
60
+ /** Epoch milliseconds: a wall-clock instant, so a clock correction moves it. */
61
+ readonly time: number;
62
+ /** What to do when the boundary after `time` comes late. */
63
+ readonly late: {
64
+ readonly _tag: "nextBoundary";
65
+ } | {
66
+ readonly _tag: "skipIfLaterThan";
67
+ readonly by: Duration.Input;
68
+ } | {
69
+ readonly _tag: "drop";
70
+ };
71
+ };
72
+ /** A secondary event on a clip, fired while it plays: from its observed start, or back from its end. */
73
+ export interface Cue {
74
+ readonly name: string;
75
+ readonly at: {
76
+ readonly from: "start" | "end";
77
+ readonly offset: Duration.Input;
78
+ };
79
+ }
80
+ /** Measured from submission on the monotonic clock. */
81
+ export interface Window {
82
+ readonly notBefore?: Duration.Input | undefined;
83
+ readonly startBy?: Duration.Input | undefined;
84
+ /** A firm item is dropped at `startBy`; a soft one may still air, recorded as late. */
85
+ readonly firm: boolean;
86
+ }
87
+ interface ClipSpec {
88
+ readonly key: ItemKey;
89
+ /** `request.seconds` is the requested length; 5 seconds when absent. */
90
+ readonly request: Request;
91
+ readonly cues?: ReadonlyArray<Cue> | undefined;
92
+ /**
93
+ * Build it continuing from the clip that airs just before it, when that clip
94
+ * is on the same session and the provider still offers it. A continued build
95
+ * takes longer: if it would be Ready only after that clip ends, it continues
96
+ * instead from the clip that will be playing by then, and airs right behind
97
+ * that one. The provider falls back to an independent clip without saying
98
+ * so, so as-run never claims continuity.
99
+ */
100
+ readonly continuity?: "previous" | undefined;
101
+ }
102
+ export interface ItemSpec extends ClipSpec {
103
+ readonly lane: string;
104
+ readonly window?: Window | undefined;
105
+ readonly start?: Start | undefined;
106
+ }
107
+ export type GroupPart = ClipSpec;
108
+ export interface GroupSpec {
109
+ readonly key: ItemKey;
110
+ readonly lane: string;
111
+ /** Built in order and aired back to back; a higher lane may still go between parts. */
112
+ readonly parts: readonly [GroupPart, ...ReadonlyArray<GroupPart>];
113
+ /** It applies to the first part. */
114
+ readonly window?: Window | undefined;
115
+ }
116
+ /**
117
+ * A clip that airs immediately before or after an anchor. Give exactly one of the two.
118
+ * `after` an item already playing airs at the next boundary; `before` one refuses.
119
+ */
120
+ export interface InsertSpec extends ClipSpec {
121
+ readonly before?: ItemKey | undefined;
122
+ readonly after?: ItemKey | undefined;
123
+ readonly window?: Window | undefined;
124
+ }
125
+ /** The clip that takes a queued item's place, under a key of its own. */
126
+ export type ReplacementSpec = ClipSpec;
127
+ /** One edit of a batch applied together. */
128
+ export type Edit = {
129
+ readonly _tag: "Submit";
130
+ readonly item: ItemSpec;
131
+ } | {
132
+ readonly _tag: "SubmitGroup";
133
+ readonly group: GroupSpec;
134
+ } | {
135
+ readonly _tag: "Insert";
136
+ readonly insert: InsertSpec;
137
+ } | {
138
+ readonly _tag: "Replace";
139
+ readonly key: ItemKey;
140
+ readonly next: ReplacementSpec;
141
+ } | {
142
+ readonly _tag: "Withdraw";
143
+ readonly key: ItemKey;
144
+ };
145
+ export type WithdrawOutcome = "withdrawn" | "already-started" | "not-found";
146
+ /** Why an item failed for good. */
147
+ export type FailureReason =
148
+ /**
149
+ * The provider failed its clip. `message` is the library's; the provider's
150
+ * own words stay in `provider`, out of messages, logs and spans.
151
+ */
152
+ {
153
+ readonly _tag: "Clip";
154
+ readonly message: string;
155
+ readonly provider: Redacted.Redacted<string>;
156
+ }
157
+ /**
158
+ * A command for it failed in a way a retry would not mend. An enqueue its
159
+ * session refused unsent, not ready for it, is sent there again once what the
160
+ * session reports has changed, as after a reconnect; refused again while the
161
+ * session reports itself ready, it fails here.
162
+ */
163
+ | {
164
+ readonly _tag: "Command";
165
+ readonly cause: CommandFailure;
166
+ }
167
+ /** Its session was lost while it played, or before it was built on two sessions in a row. */
168
+ | {
169
+ readonly _tag: "Lost";
170
+ readonly sessionId: string;
171
+ }
172
+ /** Content moderation ended its session over it; it is never built again. */
173
+ | {
174
+ readonly _tag: "Moderated";
175
+ readonly categories: ReadonlyArray<string>;
176
+ }
177
+ /** The playout closed before it aired. */
178
+ | {
179
+ readonly _tag: "Closed";
180
+ };
181
+ /**
182
+ * What became of an item. `Unknown` is "sent, acknowledgement never seen";
183
+ * `Unobserved` is "acknowledged, start never seen". Neither is ever replayed
184
+ * or given an invented time.
185
+ */
186
+ export type AsRunStatus = {
187
+ readonly _tag: "Accepted";
188
+ /** Accepted again: its clip was lost with this session before it aired, and it is rebuilt. */
189
+ readonly carried?: {
190
+ readonly sessionId: string;
191
+ } | undefined;
192
+ } | {
193
+ readonly _tag: "Building";
194
+ readonly sessionId: string;
195
+ } | {
196
+ readonly _tag: "Ready";
197
+ readonly sessionId: string;
198
+ } | {
199
+ readonly _tag: "Started";
200
+ /** Epoch milliseconds of the local observation. */
201
+ readonly at: number;
202
+ readonly sessionId: string;
203
+ readonly seconds: number;
204
+ /** How late a soft window let it start. */
205
+ readonly lateByMillis?: number | undefined;
206
+ } | {
207
+ readonly _tag: "Ended";
208
+ readonly at: number;
209
+ readonly termination: "finished" | "stopped";
210
+ readonly airedSeconds: number;
211
+ } | {
212
+ readonly _tag: "Dropped";
213
+ readonly reason: "late" | "withdrawn" | "replaced";
214
+ } | {
215
+ readonly _tag: "Failed";
216
+ readonly reason: FailureReason;
217
+ } | {
218
+ readonly _tag: "Unobserved";
219
+ } | {
220
+ readonly _tag: "Unknown";
221
+ /** Nothing can settle it any more: its session retired or the playout closed. */
222
+ readonly terminal?: true | undefined;
223
+ };
224
+ export interface AsRunEvent {
225
+ readonly key: ItemKey;
226
+ /** Epoch milliseconds when this evidence was observed. */
227
+ readonly at: number;
228
+ readonly status: AsRunStatus;
229
+ }
230
+ /**
231
+ * What became of an item for good: nothing changes it afterwards. `Unknown`
232
+ * is settled only once it is terminal.
233
+ */
234
+ export type Settled = Extract<AsRunStatus, {
235
+ readonly _tag: "Ended" | "Dropped" | "Failed" | "Unobserved";
236
+ }> | {
237
+ readonly _tag: "Unknown";
238
+ readonly terminal: true;
239
+ };
240
+ /** How an item settled without a start the playout saw. */
241
+ export type NotStarted = Exclude<Settled, {
242
+ readonly _tag: "Ended";
243
+ }>;
244
+ export interface ItemHandle {
245
+ readonly key: ItemKey;
246
+ /** The item's start, or how it settled without one. */
247
+ readonly started: Effect.Effect<Extract<AsRunStatus, {
248
+ readonly _tag: "Started";
249
+ }> | NotStarted>;
250
+ /** How the item settled. */
251
+ readonly outcome: Effect.Effect<Settled>;
252
+ }
253
+ export interface GroupHandle {
254
+ readonly key: ItemKey;
255
+ readonly parts: readonly [ItemHandle, ...ReadonlyArray<ItemHandle>];
256
+ }
257
+ export type EditResult = {
258
+ readonly _tag: "Added";
259
+ readonly handle: ItemHandle;
260
+ } | {
261
+ readonly _tag: "AddedGroup";
262
+ readonly handle: GroupHandle;
263
+ } | {
264
+ readonly _tag: "Withdrawal";
265
+ readonly outcome: Effect.Effect<WithdrawOutcome>;
266
+ };
267
+ export interface EditHandle {
268
+ readonly results: ReadonlyArray<EditResult>;
269
+ /**
270
+ * The batch took effect together: every clip it adds is Ready or settled,
271
+ * and what it withdraws or replaces went at once.
272
+ */
273
+ readonly committed: Effect.Effect<void, PlayoutClosed>;
274
+ }
275
+ export interface CueEvent {
276
+ readonly key: ItemKey;
277
+ readonly name: string;
278
+ /** Epoch milliseconds when it fired. */
279
+ readonly at: number;
280
+ }
281
+ /** A session's part in the playout. */
282
+ export type SessionEvent = {
283
+ readonly _tag: "Opened";
284
+ readonly sessionId: string;
285
+ /** What remains of its granted length; absent for a session no cap ends. */
286
+ readonly lifetimeSeconds?: number | undefined;
287
+ } | {
288
+ readonly _tag: "SetupFailed";
289
+ readonly reason: string;
290
+ readonly consecutive: number;
291
+ }
292
+ /** The replacement took the air at a boundary. */
293
+ | {
294
+ readonly _tag: "Switched";
295
+ readonly from: string;
296
+ readonly to: string;
297
+ /** The retiring session never started a clip, or its last one left the air and the grace elapsed. */
298
+ readonly decision: "no-observed-start" | "grace-elapsed";
299
+ }
300
+ /** A session was lost or expired before a planned switch; its unaired clips are rebuilt. */
301
+ | {
302
+ readonly _tag: "Replaced";
303
+ readonly from: string;
304
+ readonly reason: string;
305
+ readonly carried: number;
306
+ }
307
+ /** The session's connection dropped, and is being reconnected. */
308
+ | {
309
+ readonly _tag: "Reconnecting";
310
+ readonly sessionId: string;
311
+ }
312
+ /** The session is connected again, this long after the drop was seen. */
313
+ | {
314
+ readonly _tag: "Reconnected";
315
+ readonly sessionId: string;
316
+ readonly afterMillis: number;
317
+ }
318
+ /**
319
+ * Content moderation flagged an input. On `terminate` Reactor ends the
320
+ * session; the item whose enqueue was sent there last is held to blame, as
321
+ * the verdict names no clip, and fails instead of being rebuilt.
322
+ */
323
+ | {
324
+ readonly _tag: "Moderated";
325
+ readonly sessionId: string;
326
+ readonly action: string;
327
+ readonly categories: ReadonlyArray<string>;
328
+ readonly key?: ItemKey | undefined;
329
+ };
330
+ export type Event = {
331
+ readonly _tag: "AsRun";
332
+ readonly event: AsRunEvent;
333
+ } | {
334
+ readonly _tag: "Cue";
335
+ readonly event: CueEvent;
336
+ } | {
337
+ readonly _tag: "Session";
338
+ readonly event: SessionEvent;
339
+ }
340
+ /**
341
+ * A filler clip started or ended, at epoch milliseconds; one that fails on
342
+ * air ends then. `seconds` is its length as the provider built it, when known.
343
+ */
344
+ | {
345
+ readonly _tag: "Filler";
346
+ readonly index: number;
347
+ readonly phase: "Started" | "Ended";
348
+ readonly at: number;
349
+ readonly seconds: number | undefined;
350
+ }
351
+ /**
352
+ * A reader of the session's `track` fell behind its bound and missed frames;
353
+ * it reads on from the next one. `pressure` is the session's media pressure
354
+ * just after, its `readerOverflows` counting this one.
355
+ */
356
+ | {
357
+ readonly _tag: "ReaderOverflow";
358
+ readonly sessionId: string;
359
+ readonly track: "video" | "audio";
360
+ readonly at: number;
361
+ readonly pressure: MediaPressure;
362
+ }
363
+ /** Nothing was left to play while the plan still wanted air. */
364
+ | {
365
+ readonly _tag: "Starved";
366
+ readonly at: number;
367
+ };
368
+ export interface State {
369
+ readonly accepting: boolean;
370
+ /**
371
+ * Seconds of air secured: the playing clip's rest and the Ready clips that
372
+ * will air after it, on the session on air and then on its replacement. A
373
+ * held clip, or one anchored later, counts once it may air.
374
+ */
375
+ readonly runwaySeconds: number;
376
+ /**
377
+ * The clip on air: whose it is, when its start was seen in epoch
378
+ * milliseconds, and its length as the provider built it. The length is
379
+ * unknown for a clip that started before the playout attached, until it ends.
380
+ */
381
+ readonly playing: {
382
+ readonly key: ItemKey | "filler" | "other";
383
+ readonly startedAt: number;
384
+ readonly seconds: number | undefined;
385
+ } | null;
386
+ readonly lanes: ReadonlyArray<{
387
+ readonly name: string;
388
+ readonly keys: ReadonlyArray<ItemKey>;
389
+ }>;
390
+ readonly sessions: ReadonlyArray<{
391
+ readonly sessionId: string;
392
+ readonly role: "on-air" | "replacement" | "retiring";
393
+ readonly ready: ReadonlyArray<ItemKey | "filler" | "other">;
394
+ }>;
395
+ readonly starved: number;
396
+ /**
397
+ * Learned from this playout's own clips: build seconds per requested second
398
+ * over every build, filler's included (median and p95, once three were
399
+ * measured), apart for clips built continuing from another, which take
400
+ * longer; and an item's actual over requested length.
401
+ */
402
+ readonly estimates: {
403
+ readonly build: {
404
+ readonly median: number;
405
+ readonly p95: number;
406
+ } | undefined;
407
+ readonly continuedBuild: {
408
+ readonly median: number;
409
+ readonly p95: number;
410
+ } | undefined;
411
+ readonly length: number;
412
+ };
413
+ }
414
+ /** Identifies what a clip was enqueued for, read back from the provider's clip metadata. */
415
+ export type ClipTag = {
416
+ readonly _tag: "Item";
417
+ readonly key: ItemKey;
418
+ } | {
419
+ readonly _tag: "Filler";
420
+ readonly index: number;
421
+ };
422
+ export interface SourceClip {
423
+ readonly clipId: string;
424
+ /** Undefined for a clip this playout did not enqueue. */
425
+ readonly tag: ClipTag | undefined;
426
+ /** The provider's length for the clip, which may differ from the request. */
427
+ readonly seconds: number;
428
+ }
429
+ /**
430
+ * The clip playing, or armed to play. A provider may name one it never
431
+ * reported starting, such as H3 for a clip playing before the source attached:
432
+ * its tag and length are then unknown until it ends.
433
+ */
434
+ export interface PlayingClip extends Omit<SourceClip, "seconds"> {
435
+ readonly seconds: number | undefined;
436
+ }
437
+ /** One session's queues, as its provider last reported them. */
438
+ export interface SourceState {
439
+ /** The provider accepts commands. */
440
+ readonly available: boolean;
441
+ /** Waiting to build, the build in flight first, in the provider's order. */
442
+ readonly building: ReadonlyArray<SourceClip>;
443
+ /** Built and waiting to play, in playout order. */
444
+ readonly ready: ReadonlyArray<SourceClip>;
445
+ readonly playing: PlayingClip | undefined;
446
+ /** Clips a new build can continue from. */
447
+ readonly continuable: ReadonlyArray<string>;
448
+ }
449
+ export type SourceEvent = {
450
+ readonly _tag: "State";
451
+ readonly state: SourceState;
452
+ } | {
453
+ readonly _tag: "Started";
454
+ readonly clip: SourceClip;
455
+ } | {
456
+ readonly _tag: "Ended";
457
+ readonly clip: SourceClip;
458
+ readonly termination: "finished" | "stopped";
459
+ /** From the provider's own count when it gives one. */
460
+ readonly airedSeconds?: number | undefined;
461
+ }
462
+ /** The provider failed a clip: `message` in the source's words, `provider` in its own. */
463
+ | {
464
+ readonly _tag: "Failed";
465
+ readonly clip: SourceClip;
466
+ readonly message: string;
467
+ readonly provider: Redacted.Redacted<string>;
468
+ }
469
+ /** The provider's content moderation flagged an input; `terminate` ends the session. */
470
+ | {
471
+ readonly _tag: "Moderated";
472
+ readonly action: string;
473
+ readonly categories: ReadonlyArray<string>;
474
+ }
475
+ /**
476
+ * The connection dropped and is being reconnected; a reconnect that fails, or outlasts the
477
+ * source's wait, fails `events`.
478
+ */
479
+ | {
480
+ readonly _tag: "Reconnecting";
481
+ }
482
+ /** The connection is back, this long after the drop was seen. */
483
+ | {
484
+ readonly _tag: "Reconnected";
485
+ readonly afterMillis: number;
486
+ }
487
+ /** A reader of `video` or `audio` fell behind its bound, missed frames and reads on. */
488
+ | {
489
+ readonly _tag: "ReaderOverflow";
490
+ readonly track: "video" | "audio";
491
+ readonly pressure: MediaPressure;
492
+ };
493
+ /**
494
+ * One session as the playout drives it: its evidence, its commands and its
495
+ * media. What the playout relies on:
496
+ *
497
+ * - `sessionId` is unique among the sources open at once; the playout refuses
498
+ * a second under the same id.
499
+ * - A clip id names one clip of its session. Another session's clip may have
500
+ * the same id.
501
+ * - `events` starts with a `State`. `Started`, `Ended` and `Failed` come before
502
+ * the `State` that reflects them, and once `enqueue` has returned no `State`
503
+ * leaves the clip out until its `Ended` or `Failed`.
504
+ * - `events` fails only when the session is lost for good; the source
505
+ * recovers a dropped connection itself, and reports it.
506
+ * - Each command ends, done or failed, in bounded time. The playout sends a
507
+ * session its commands one at a time, so one that never ends holds up the
508
+ * rest of that session's, though no other session's.
509
+ * - A method that throws when called is reported as a defect, as one whose
510
+ * effect dies is, and whether its command applied is taken as unknown. An
511
+ * `enqueue` is never sent again, and unless a read of the session's queues
512
+ * shows its clip within `unknownTimeout`, a replacement takes over. A
513
+ * `remove` is asked again once the session's queues change, and a `move` a
514
+ * second later. After such a `setAutoplay` the session's autoplay is
515
+ * unknown, and the value the playout wants goes again: a second later if it
516
+ * is the one that died, and at once if not. Until its autoplay is as wanted,
517
+ * a session is sent nothing else but, as it retires, the removal of its
518
+ * filler once its replacement has an item Ready. A `stop` or `play` ends its
519
+ * cut, and the cutter airs at the next boundary.
520
+ */
521
+ export interface Source {
522
+ readonly sessionId: string;
523
+ /**
524
+ * What remains of the session's granted length when the source is returned,
525
+ * counted by the playout from then; `Infinity` for none.
526
+ */
527
+ readonly lifetime: Duration.Duration;
528
+ readonly events: Stream.Stream<SourceEvent, ReactorError>;
529
+ readonly enqueue: (request: Request, tag: ClipTag, continueFrom?: string) => Effect.Effect<string, CommandFailure>;
530
+ readonly remove: (clipId: string) => Effect.Effect<void, CommandFailure>;
531
+ readonly move: (clipId: string, position: number) => Effect.Effect<void, CommandFailure>;
532
+ readonly setAutoplay: (enabled: boolean) => Effect.Effect<void, CommandFailure>;
533
+ /**
534
+ * Stops `clipId` if it still plays, and completes once the provider reports
535
+ * it ended. A provider's stop may name no clip, so one that ended first, or
536
+ * another clip playing by then, is left alone. The playout turns autoplay
537
+ * off first, so nothing starts in its place.
538
+ */
539
+ readonly stop: (clipId: string) => Effect.Effect<void, CommandFailure>;
540
+ /** Plays `clipId`, a Ready clip, while nothing plays. */
541
+ readonly play: (clipId: string) => Effect.Effect<void, CommandFailure>;
542
+ readonly video: Stream.Stream<VideoFrame, ReactorError>;
543
+ readonly audio: Stream.Stream<AudioFrame, ReactorError>;
544
+ /** Idempotent; closing an owned session terminates it. */
545
+ readonly close: Effect.Effect<CloseReport>;
546
+ }
547
+ export interface FillContext {
548
+ /**
549
+ * Numbers filler clips from zero as each is first asked for. One the provider refused is asked
550
+ * for again as it was, under its own index, on whichever session's lane is free.
551
+ */
552
+ readonly index: number;
553
+ readonly runwaySeconds: number;
554
+ /**
555
+ * A requested length within `filler.lengths`: before an `At` anchor, one of
556
+ * equal clips that tile the uncovered gap, none asking for less than its
557
+ * share; ahead of an item whose build it covers (`filler.protect`), as long
558
+ * as that takes; otherwise the shortest, which keeps boundaries, and so
559
+ * reactions, frequent.
560
+ */
561
+ readonly seconds: number;
562
+ }
563
+ export interface Options<R = never> {
564
+ /** Opens one session. Called for the first and for each replacement. */
565
+ readonly open: Effect.Effect<Source, ReactorFailure, R | Scope.Scope>;
566
+ readonly lanes: ReadonlyArray<LaneSpec>;
567
+ /** The bottom lane, never owed: generated clips that keep the air covered. */
568
+ readonly filler?: {
569
+ /** Air secured ahead: refill below `floor`, up to `target`. */
570
+ readonly runway: {
571
+ readonly floor: Duration.Input;
572
+ readonly target: Duration.Input;
573
+ };
574
+ /**
575
+ * Called once per clip, as it is first asked for; keep it pure. A request
576
+ * outside H3's documented limits fails the playout with `InvalidFiller`.
577
+ */
578
+ readonly clip: (context: FillContext) => Request;
579
+ /** Lengths a filler clip may take; H3's request range by default. */
580
+ readonly lengths?: {
581
+ readonly min: number;
582
+ readonly max: number;
583
+ } | undefined;
584
+ /**
585
+ * What goes first when an item's build would outlast the air secured.
586
+ * With `"air"`, the default, once three builds were measured, an item
587
+ * whose p95 build, at the continued rate if it continues a clip,
588
+ * exceeds `State.runwaySeconds` waits for one filler clip that builds
589
+ * sooner than it does: long enough, within `lengths`, to cover the rest
590
+ * and a second more, and airing no longer than the item builds unless
591
+ * `lengths.min` is longer. The floor, which filler refills without
592
+ * holding any item, covers the next such item's build and a second
593
+ * more. An item with a time to meet goes as soon as it may: one with an
594
+ * `At` start or a `startBy`, and, since its time is now, one with an
595
+ * `Asap` start, a released `Manual` one, or one on a lane that cuts.
596
+ * `"order"` builds each item as soon as it may: it airs sooner, but the
597
+ * air may go dark while it builds.
598
+ */
599
+ readonly protect?: "air" | "order" | undefined;
600
+ } | undefined;
601
+ /**
602
+ * Builds in flight at once on the session that takes new work; one by
603
+ * default. A moderation verdict that names no item fails the latest enqueue
604
+ * on its session: with more than one in flight that may be an innocent
605
+ * item, while the flagged one is carried to the next session.
606
+ */
607
+ readonly maxBuildsInFlight?: number | undefined;
608
+ /** Settled keys kept for idempotency, oldest dropped first; 4,096 by default. */
609
+ readonly maxHistory?: number | undefined;
610
+ /**
611
+ * An enqueue whose outcome stays unknown this long marks its session
612
+ * indeterminate, so a replacement takes over; 60 seconds by default. Until
613
+ * then it holds no build slot: what follows builds behind it, and it is
614
+ * never sent again.
615
+ */
616
+ readonly unknownTimeout?: Duration.Input | undefined;
617
+ /**
618
+ * Sessions content moderation may end before the playout fails, rather than
619
+ * open more paid sessions for content that keeps being flagged; 2 by default.
620
+ */
621
+ readonly maxModerations?: number | undefined;
622
+ readonly renewal?: {
623
+ /**
624
+ * Opens the replacement this long before a session's lifetime ends, and
625
+ * no earlier: what cannot air before the cap waits for it. 30 seconds by default.
626
+ */
627
+ readonly lead?: Duration.Input | undefined;
628
+ /**
629
+ * How long opening a session may take, the wait for a GPU included;
630
+ * 3 minutes by default. Waiting for a GPU is not billed.
631
+ */
632
+ readonly openTimeout?: Duration.Input | undefined;
633
+ /**
634
+ * How long after the retiring session's last clip ends, or fails on air,
635
+ * the switch waits; 250 ms by default.
636
+ */
637
+ readonly grace?: Duration.Input | undefined;
638
+ /**
639
+ * Consecutive failed setups that end the playout: opens that failed,
640
+ * and sessions lost before any clip sent to them started. A run ends
641
+ * when a session airs its first clip; more clips on the session already
642
+ * on air don't end it. 3 by default. Each open is retried a second
643
+ * longer after each failure, but at most this many seconds later, and
644
+ * never sooner than a refusal's `Retry-After`. An open that failed with
645
+ * an `AcquisitionFailure` whose `cleanup.allocation` is `"none"`, such
646
+ * as a refusal with a 4xx status, billed nothing: refused while a
647
+ * session holds the air, it counts neither then nor later, so it is
648
+ * asked again however often it fails. Running out while a session holds
649
+ * the air doesn't end the playout: opening pauses until that session's
650
+ * cap ends it or it is lost, and then one more open is tried, once the
651
+ * last failure's wait is over.
652
+ */
653
+ readonly maxSetupFailures?: number | undefined;
654
+ } | undefined;
655
+ }
656
+ /**
657
+ * Close reports of the sessions this playout retired, failed opens that
658
+ * allocated included: every one that may still bill (`Session.mayStillBill`)
659
+ * and the latest others.
660
+ */
661
+ export interface Cleanup {
662
+ readonly sessions: number;
663
+ readonly retained: ReadonlyArray<CloseReport>;
664
+ }
665
+ declare const Playout_base: Context.ServiceClass<Playout, "reactor-effect-client/Playout", {
666
+ readonly submit: (item: ItemSpec) => Effect.Effect<ItemHandle, SubmitError>;
667
+ readonly submitGroup: (group: GroupSpec) => Effect.Effect<GroupHandle, SubmitError>;
668
+ readonly insert: (spec: InsertSpec) => Effect.Effect<ItemHandle, SubmitError>;
669
+ /**
670
+ * Builds `next` for the item's place, lane and group position. Once `next`
671
+ * is Ready the item goes as `replaced`; if the item starts first, `next`
672
+ * is dropped as `withdrawn`.
673
+ */
674
+ readonly replace: (key: ItemKey, next: ReplacementSpec) => Effect.Effect<ItemHandle, SubmitError>;
675
+ /**
676
+ * Several edits as one make-before-break change: all are checked before any
677
+ * takes effect, and what the batch withdraws or replaces stays as cover
678
+ * until everything it adds is Ready or settled.
679
+ */
680
+ readonly edit: (edits: ReadonlyArray<Edit>) => Effect.Effect<EditHandle, SubmitError>;
681
+ /** Releases a held `Manual` item to air at the next boundary. */
682
+ readonly release: (key: ItemKey) => Effect.Effect<void, InvalidItem>;
683
+ /**
684
+ * A group key withdraws its unstarted parts, and answers `withdrawn` if any
685
+ * part was, else `already-started` if any started; a part key withdraws that
686
+ * part and those after it, and answers for that part. Once the playout has
687
+ * stopped, it answers from what became of the item or the parts. It answers
688
+ * `not-found` for a key it doesn't hold, and for an item that settled
689
+ * without starting, such as one that failed: its handle says how.
690
+ */
691
+ readonly withdraw: (key: ItemKey) => Effect.Effect<WithdrawOutcome>;
692
+ /** Admits nothing more and completes once the chosen work has aired or settled. */
693
+ readonly drain: (options?: {
694
+ readonly finish?: "playing" | "accepted";
695
+ }) => Effect.Effect<void, PlayoutClosed>;
696
+ readonly state: Effect.Effect<State>;
697
+ /** Every event from subscription on, in order. */
698
+ readonly events: Stream.Stream<Event>;
699
+ readonly asRun: Stream.Stream<AsRunEvent>;
700
+ /**
701
+ * The on-air session's picture, continuing across renewals, and ending
702
+ * when the playout stops. It fails with the on-air source's media failure;
703
+ * reading it again starts from the session then on air.
704
+ */
705
+ readonly video: Stream.Stream<VideoFrame, ReactorError>;
706
+ /** The on-air session's sound, as `video` is its picture. */
707
+ readonly audio: Stream.Stream<AudioFrame, ReactorError>;
708
+ /**
709
+ * Why the playout stopped: a session could not be opened or kept, a filler
710
+ * request was outside H3's limits (`InvalidFiller`), or its scope closed
711
+ * (`Closed`). A defect that stopped it, such as a throwing `filler.clip`,
712
+ * stays a defect: this dies with it.
713
+ */
714
+ readonly failure: Effect.Effect<ReactorFailure | InvalidFiller>;
715
+ readonly cleanup: Effect.Effect<Cleanup>;
716
+ }>;
717
+ export declare class Playout extends Playout_base {
718
+ }
719
+ /** A playout in the caller's scope; closing the scope retires every session. */
720
+ export declare const make: <R>(options: Options<R>) => Effect.Effect<Playout["Service"], never, R | Scope.Scope>;
721
+ export declare const layer: <R>(options: Options<R>) => Layer.Layer<Playout, never, R>;
722
+ /** The lineup: one lane of the application's items ahead of filler. */
723
+ export declare const lineup: (filler: NonNullable<Options["filler"]>) => Pick<Options, "lanes" | "filler">;
724
+ //# sourceMappingURL=Playout.d.ts.map