@restatedev/restate-sdk 0.8.0 → 0.9.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 (375) hide show
  1. package/dist/{clients → src/clients}/workflow_client.d.ts +2 -2
  2. package/dist/src/clients/workflow_client.d.ts.map +1 -0
  3. package/dist/{clients → src/clients}/workflow_client.js +2 -2
  4. package/dist/src/clients/workflow_client.js.map +1 -0
  5. package/dist/{connection → src/connection}/buffered_connection.d.ts +1 -0
  6. package/dist/src/connection/buffered_connection.d.ts.map +1 -0
  7. package/dist/src/connection/buffered_connection.js.map +1 -0
  8. package/dist/src/connection/connection.d.ts.map +1 -0
  9. package/dist/src/connection/connection.js.map +1 -0
  10. package/dist/{connection → src/connection}/http_connection.d.ts +1 -1
  11. package/dist/src/connection/http_connection.d.ts.map +1 -0
  12. package/dist/{connection → src/connection}/http_connection.js +1 -1
  13. package/dist/src/connection/http_connection.js.map +1 -0
  14. package/dist/{connection → src/connection}/lambda_connection.d.ts +1 -0
  15. package/dist/src/connection/lambda_connection.d.ts.map +1 -0
  16. package/dist/{connection → src/connection}/lambda_connection.js +5 -4
  17. package/dist/src/connection/lambda_connection.js.map +1 -0
  18. package/dist/{context.d.ts → src/context.d.ts} +146 -224
  19. package/dist/src/context.d.ts.map +1 -0
  20. package/dist/{context.js → src/context.js} +6 -41
  21. package/dist/src/context.js.map +1 -0
  22. package/dist/src/context_impl.d.ts +62 -0
  23. package/dist/src/context_impl.d.ts.map +1 -0
  24. package/dist/{context_impl.js → src/context_impl.js} +201 -182
  25. package/dist/src/context_impl.js.map +1 -0
  26. package/dist/src/endpoint/endpoint_impl.d.ts +28 -0
  27. package/dist/src/endpoint/endpoint_impl.d.ts.map +1 -0
  28. package/dist/src/endpoint/endpoint_impl.js +164 -0
  29. package/dist/src/endpoint/endpoint_impl.js.map +1 -0
  30. package/dist/{endpoint → src/endpoint}/http2_handler.d.ts +1 -1
  31. package/dist/src/endpoint/http2_handler.d.ts.map +1 -0
  32. package/dist/src/endpoint/http2_handler.js +153 -0
  33. package/dist/src/endpoint/http2_handler.js.map +1 -0
  34. package/dist/{endpoint → src/endpoint}/lambda_handler.d.ts +3 -3
  35. package/dist/src/endpoint/lambda_handler.d.ts.map +1 -0
  36. package/dist/src/endpoint/lambda_handler.js +154 -0
  37. package/dist/src/endpoint/lambda_handler.js.map +1 -0
  38. package/dist/src/endpoint/request_signing/basex.d.ts +10 -0
  39. package/dist/src/endpoint/request_signing/basex.d.ts.map +1 -0
  40. package/dist/src/endpoint/request_signing/basex.js +138 -0
  41. package/dist/src/endpoint/request_signing/basex.js.map +1 -0
  42. package/dist/src/endpoint/request_signing/ed25519.d.ts +17 -0
  43. package/dist/src/endpoint/request_signing/ed25519.d.ts.map +1 -0
  44. package/dist/src/endpoint/request_signing/ed25519.js +78 -0
  45. package/dist/src/endpoint/request_signing/ed25519.js.map +1 -0
  46. package/dist/src/endpoint/request_signing/v1.d.ts +9 -0
  47. package/dist/src/endpoint/request_signing/v1.d.ts.map +1 -0
  48. package/dist/src/endpoint/request_signing/v1.js +148 -0
  49. package/dist/src/endpoint/request_signing/v1.js.map +1 -0
  50. package/dist/src/endpoint/request_signing/validate.d.ts +18 -0
  51. package/dist/src/endpoint/request_signing/validate.d.ts.map +1 -0
  52. package/dist/src/endpoint/request_signing/validate.js +45 -0
  53. package/dist/src/endpoint/request_signing/validate.js.map +1 -0
  54. package/dist/src/endpoint.d.ts +102 -0
  55. package/dist/src/endpoint.d.ts.map +1 -0
  56. package/dist/{endpoint.js → src/endpoint.js} +1 -1
  57. package/dist/src/endpoint.js.map +1 -0
  58. package/dist/src/generated/proto/javascript_pb.d.ts +26 -0
  59. package/dist/src/generated/proto/javascript_pb.d.ts.map +1 -0
  60. package/dist/src/generated/proto/javascript_pb.js +52 -0
  61. package/dist/src/generated/proto/javascript_pb.js.map +1 -0
  62. package/dist/src/generated/proto/protocol_pb.d.ts +865 -0
  63. package/dist/src/generated/proto/protocol_pb.d.ts.map +1 -0
  64. package/dist/src/generated/proto/protocol_pb.js +1112 -0
  65. package/dist/src/generated/proto/protocol_pb.js.map +1 -0
  66. package/dist/src/generated/version.d.ts +2 -0
  67. package/dist/src/generated/version.d.ts.map +1 -0
  68. package/dist/src/generated/version.js +5 -0
  69. package/dist/src/generated/version.js.map +1 -0
  70. package/dist/{invocation.d.ts → src/invocation.d.ts} +14 -18
  71. package/dist/src/invocation.d.ts.map +1 -0
  72. package/dist/{invocation.js → src/invocation.js} +25 -24
  73. package/dist/src/invocation.js.map +1 -0
  74. package/dist/{io → src/io}/decoder.d.ts +3 -2
  75. package/dist/src/io/decoder.d.ts.map +1 -0
  76. package/dist/{io → src/io}/decoder.js +12 -10
  77. package/dist/src/io/decoder.js.map +1 -0
  78. package/dist/{io → src/io}/encoder.d.ts +1 -1
  79. package/dist/src/io/encoder.d.ts.map +1 -0
  80. package/dist/{io → src/io}/encoder.js +11 -21
  81. package/dist/src/io/encoder.js.map +1 -0
  82. package/dist/{journal.d.ts → src/journal.d.ts} +7 -7
  83. package/dist/src/journal.d.ts.map +1 -0
  84. package/dist/{journal.js → src/journal.js} +64 -46
  85. package/dist/src/journal.js.map +1 -0
  86. package/dist/{local_state_store.d.ts → src/local_state_store.d.ts} +2 -2
  87. package/dist/src/local_state_store.d.ts.map +1 -0
  88. package/dist/{local_state_store.js → src/local_state_store.js} +19 -17
  89. package/dist/src/local_state_store.js.map +1 -0
  90. package/dist/{logger.d.ts → src/logger.d.ts} +9 -1
  91. package/dist/src/logger.d.ts.map +1 -0
  92. package/dist/src/logger.js +158 -0
  93. package/dist/src/logger.js.map +1 -0
  94. package/dist/src/promise_combinator_tracker.d.ts.map +1 -0
  95. package/dist/src/promise_combinator_tracker.js.map +1 -0
  96. package/dist/src/public_api.d.ts +7 -0
  97. package/dist/src/public_api.d.ts.map +1 -0
  98. package/dist/{public_api.js → src/public_api.js} +4 -14
  99. package/dist/src/public_api.js.map +1 -0
  100. package/dist/{state_machine.d.ts → src/state_machine.d.ts} +7 -4
  101. package/dist/src/state_machine.d.ts.map +1 -0
  102. package/dist/{state_machine.js → src/state_machine.js} +32 -34
  103. package/dist/src/state_machine.js.map +1 -0
  104. package/dist/src/types/components.d.ts +65 -0
  105. package/dist/src/types/components.d.ts.map +1 -0
  106. package/dist/src/types/components.js +163 -0
  107. package/dist/src/types/components.js.map +1 -0
  108. package/dist/src/types/discovery.d.ts +40 -0
  109. package/dist/src/types/discovery.d.ts.map +1 -0
  110. package/dist/src/types/discovery.js +29 -0
  111. package/dist/src/types/discovery.js.map +1 -0
  112. package/dist/src/types/errors.d.ts +53 -0
  113. package/dist/src/types/errors.d.ts.map +1 -0
  114. package/dist/src/types/errors.js +129 -0
  115. package/dist/src/types/errors.js.map +1 -0
  116. package/dist/src/types/protocol.d.ts +33 -0
  117. package/dist/src/types/protocol.d.ts.map +1 -0
  118. package/dist/{types → src/types}/protocol.js +52 -52
  119. package/dist/src/types/protocol.js.map +1 -0
  120. package/dist/src/types/rpc.d.ts +50 -0
  121. package/dist/src/types/rpc.d.ts.map +1 -0
  122. package/dist/src/types/rpc.js +38 -0
  123. package/dist/src/types/rpc.js.map +1 -0
  124. package/dist/{types → src/types}/types.d.ts +0 -9
  125. package/dist/src/types/types.d.ts.map +1 -0
  126. package/dist/{types → src/types}/types.js +4 -21
  127. package/dist/src/types/types.js.map +1 -0
  128. package/dist/src/user_agent.d.ts +2 -0
  129. package/dist/src/user_agent.d.ts.map +1 -0
  130. package/dist/src/user_agent.js +16 -0
  131. package/dist/src/user_agent.js.map +1 -0
  132. package/dist/src/utils/message_logger.d.ts +7 -0
  133. package/dist/src/utils/message_logger.d.ts.map +1 -0
  134. package/dist/{utils → src/utils}/message_logger.js +17 -26
  135. package/dist/src/utils/message_logger.js.map +1 -0
  136. package/dist/src/utils/promises.d.ts.map +1 -0
  137. package/dist/src/utils/promises.js.map +1 -0
  138. package/dist/{utils → src/utils}/rand.d.ts +1 -0
  139. package/dist/src/utils/rand.d.ts.map +1 -0
  140. package/dist/{utils → src/utils}/rand.js +7 -6
  141. package/dist/src/utils/rand.js.map +1 -0
  142. package/dist/src/utils/serde.d.ts +3 -0
  143. package/dist/src/utils/serde.d.ts.map +1 -0
  144. package/dist/src/utils/serde.js +24 -0
  145. package/dist/src/utils/serde.js.map +1 -0
  146. package/dist/{utils → src/utils}/utils.d.ts +0 -1
  147. package/dist/src/utils/utils.d.ts.map +1 -0
  148. package/dist/{utils → src/utils}/utils.js +36 -43
  149. package/dist/src/utils/utils.js.map +1 -0
  150. package/dist/{workflows → src/workflows}/workflow.d.ts +6 -6
  151. package/dist/src/workflows/workflow.d.ts.map +1 -0
  152. package/dist/{workflows → src/workflows}/workflow.js +11 -7
  153. package/dist/src/workflows/workflow.js.map +1 -0
  154. package/dist/src/workflows/workflow_state_service.d.ts +35 -0
  155. package/dist/src/workflows/workflow_state_service.d.ts.map +1 -0
  156. package/dist/{workflows → src/workflows}/workflow_state_service.js +11 -11
  157. package/dist/src/workflows/workflow_state_service.js.map +1 -0
  158. package/dist/{workflows → src/workflows}/workflow_wrapper_service.d.ts +2 -2
  159. package/dist/src/workflows/workflow_wrapper_service.d.ts.map +1 -0
  160. package/dist/{workflows → src/workflows}/workflow_wrapper_service.js +66 -45
  161. package/dist/src/workflows/workflow_wrapper_service.js.map +1 -0
  162. package/dist/tsconfig.tsbuildinfo +1 -0
  163. package/package.json +13 -16
  164. package/LICENSE +0 -21
  165. package/README.md +0 -154
  166. package/dist/clients/workflow_client.d.ts.map +0 -1
  167. package/dist/clients/workflow_client.js.map +0 -1
  168. package/dist/connection/buffered_connection.d.ts.map +0 -1
  169. package/dist/connection/buffered_connection.js.map +0 -1
  170. package/dist/connection/connection.d.ts.map +0 -1
  171. package/dist/connection/connection.js.map +0 -1
  172. package/dist/connection/embedded_connection.d.ts +0 -20
  173. package/dist/connection/embedded_connection.d.ts.map +0 -1
  174. package/dist/connection/embedded_connection.js +0 -59
  175. package/dist/connection/embedded_connection.js.map +0 -1
  176. package/dist/connection/http_connection.d.ts.map +0 -1
  177. package/dist/connection/http_connection.js.map +0 -1
  178. package/dist/connection/lambda_connection.d.ts.map +0 -1
  179. package/dist/connection/lambda_connection.js.map +0 -1
  180. package/dist/context.d.ts.map +0 -1
  181. package/dist/context.js.map +0 -1
  182. package/dist/context_impl.d.ts +0 -65
  183. package/dist/context_impl.d.ts.map +0 -1
  184. package/dist/context_impl.js.map +0 -1
  185. package/dist/embedded/api.d.ts +0 -27
  186. package/dist/embedded/api.d.ts.map +0 -1
  187. package/dist/embedded/api.js +0 -35
  188. package/dist/embedded/api.js.map +0 -1
  189. package/dist/embedded/handler.d.ts +0 -4
  190. package/dist/embedded/handler.d.ts.map +0 -1
  191. package/dist/embedded/handler.js +0 -26
  192. package/dist/embedded/handler.js.map +0 -1
  193. package/dist/embedded/http2_remote.d.ts +0 -11
  194. package/dist/embedded/http2_remote.d.ts.map +0 -1
  195. package/dist/embedded/http2_remote.js +0 -91
  196. package/dist/embedded/http2_remote.js.map +0 -1
  197. package/dist/embedded/invocation.d.ts +0 -5
  198. package/dist/embedded/invocation.d.ts.map +0 -1
  199. package/dist/embedded/invocation.js +0 -94
  200. package/dist/embedded/invocation.js.map +0 -1
  201. package/dist/endpoint/endpoint_impl.d.ts +0 -35
  202. package/dist/endpoint/endpoint_impl.d.ts.map +0 -1
  203. package/dist/endpoint/endpoint_impl.js +0 -405
  204. package/dist/endpoint/endpoint_impl.js.map +0 -1
  205. package/dist/endpoint/http2_handler.d.ts.map +0 -1
  206. package/dist/endpoint/http2_handler.js +0 -119
  207. package/dist/endpoint/http2_handler.js.map +0 -1
  208. package/dist/endpoint/lambda_handler.d.ts.map +0 -1
  209. package/dist/endpoint/lambda_handler.js +0 -144
  210. package/dist/endpoint/lambda_handler.js.map +0 -1
  211. package/dist/endpoint.d.ts +0 -161
  212. package/dist/endpoint.d.ts.map +0 -1
  213. package/dist/endpoint.js.map +0 -1
  214. package/dist/generated/dev/restate/events.d.ts +0 -96
  215. package/dist/generated/dev/restate/events.d.ts.map +0 -1
  216. package/dist/generated/dev/restate/events.js +0 -371
  217. package/dist/generated/dev/restate/events.js.map +0 -1
  218. package/dist/generated/dev/restate/ext.d.ts +0 -91
  219. package/dist/generated/dev/restate/ext.d.ts.map +0 -1
  220. package/dist/generated/dev/restate/ext.js +0 -215
  221. package/dist/generated/dev/restate/ext.js.map +0 -1
  222. package/dist/generated/google/protobuf/descriptor.d.ts +0 -1204
  223. package/dist/generated/google/protobuf/descriptor.d.ts.map +0 -1
  224. package/dist/generated/google/protobuf/descriptor.js +0 -6676
  225. package/dist/generated/google/protobuf/descriptor.js.map +0 -1
  226. package/dist/generated/google/protobuf/empty.d.ts +0 -86
  227. package/dist/generated/google/protobuf/empty.d.ts.map +0 -1
  228. package/dist/generated/google/protobuf/empty.js +0 -107
  229. package/dist/generated/google/protobuf/empty.js.map +0 -1
  230. package/dist/generated/google/protobuf/struct.d.ts +0 -175
  231. package/dist/generated/google/protobuf/struct.d.ts.map +0 -1
  232. package/dist/generated/google/protobuf/struct.js +0 -754
  233. package/dist/generated/google/protobuf/struct.js.map +0 -1
  234. package/dist/generated/proto/discovery.d.ts +0 -105
  235. package/dist/generated/proto/discovery.d.ts.map +0 -1
  236. package/dist/generated/proto/discovery.js +0 -364
  237. package/dist/generated/proto/discovery.js.map +0 -1
  238. package/dist/generated/proto/dynrpc.d.ts +0 -150
  239. package/dist/generated/proto/dynrpc.d.ts.map +0 -1
  240. package/dist/generated/proto/dynrpc.js +0 -668
  241. package/dist/generated/proto/dynrpc.js.map +0 -1
  242. package/dist/generated/proto/javascript.d.ts +0 -110
  243. package/dist/generated/proto/javascript.d.ts.map +0 -1
  244. package/dist/generated/proto/javascript.js +0 -416
  245. package/dist/generated/proto/javascript.js.map +0 -1
  246. package/dist/generated/proto/protocol.d.ts +0 -450
  247. package/dist/generated/proto/protocol.d.ts.map +0 -1
  248. package/dist/generated/proto/protocol.js +0 -2641
  249. package/dist/generated/proto/protocol.js.map +0 -1
  250. package/dist/generated/proto/services.d.ts +0 -307
  251. package/dist/generated/proto/services.d.ts.map +0 -1
  252. package/dist/generated/proto/services.js +0 -1535
  253. package/dist/generated/proto/services.js.map +0 -1
  254. package/dist/generated/proto/test.d.ts +0 -116
  255. package/dist/generated/proto/test.d.ts.map +0 -1
  256. package/dist/generated/proto/test.js +0 -321
  257. package/dist/generated/proto/test.js.map +0 -1
  258. package/dist/invocation.d.ts.map +0 -1
  259. package/dist/invocation.js.map +0 -1
  260. package/dist/io/decoder.d.ts.map +0 -1
  261. package/dist/io/decoder.js.map +0 -1
  262. package/dist/io/encoder.d.ts.map +0 -1
  263. package/dist/io/encoder.js.map +0 -1
  264. package/dist/journal.d.ts.map +0 -1
  265. package/dist/journal.js.map +0 -1
  266. package/dist/local_state_store.d.ts.map +0 -1
  267. package/dist/local_state_store.js.map +0 -1
  268. package/dist/logger.d.ts.map +0 -1
  269. package/dist/logger.js +0 -90
  270. package/dist/logger.js.map +0 -1
  271. package/dist/promise_combinator_tracker.d.ts.map +0 -1
  272. package/dist/promise_combinator_tracker.js.map +0 -1
  273. package/dist/public_api.d.ts +0 -10
  274. package/dist/public_api.d.ts.map +0 -1
  275. package/dist/public_api.js.map +0 -1
  276. package/dist/state_machine.d.ts.map +0 -1
  277. package/dist/state_machine.js.map +0 -1
  278. package/dist/types/errors.d.ts +0 -188
  279. package/dist/types/errors.d.ts.map +0 -1
  280. package/dist/types/errors.js +0 -273
  281. package/dist/types/errors.js.map +0 -1
  282. package/dist/types/grpc.d.ts +0 -90
  283. package/dist/types/grpc.d.ts.map +0 -1
  284. package/dist/types/grpc.js +0 -81
  285. package/dist/types/grpc.js.map +0 -1
  286. package/dist/types/protocol.d.ts +0 -30
  287. package/dist/types/protocol.d.ts.map +0 -1
  288. package/dist/types/protocol.js.map +0 -1
  289. package/dist/types/router.d.ts +0 -33
  290. package/dist/types/router.d.ts.map +0 -1
  291. package/dist/types/router.js +0 -36
  292. package/dist/types/router.js.map +0 -1
  293. package/dist/types/types.d.ts.map +0 -1
  294. package/dist/types/types.js.map +0 -1
  295. package/dist/utils/assumptions.d.ts +0 -8
  296. package/dist/utils/assumptions.d.ts.map +0 -1
  297. package/dist/utils/assumptions.js +0 -101
  298. package/dist/utils/assumptions.js.map +0 -1
  299. package/dist/utils/message_logger.d.ts +0 -28
  300. package/dist/utils/message_logger.d.ts.map +0 -1
  301. package/dist/utils/message_logger.js.map +0 -1
  302. package/dist/utils/promises.d.ts.map +0 -1
  303. package/dist/utils/promises.js.map +0 -1
  304. package/dist/utils/public_utils.d.ts +0 -58
  305. package/dist/utils/public_utils.d.ts.map +0 -1
  306. package/dist/utils/public_utils.js +0 -49
  307. package/dist/utils/public_utils.js.map +0 -1
  308. package/dist/utils/rand.d.ts.map +0 -1
  309. package/dist/utils/rand.js.map +0 -1
  310. package/dist/utils/utils.d.ts.map +0 -1
  311. package/dist/utils/utils.js.map +0 -1
  312. package/dist/workflows/workflow.d.ts.map +0 -1
  313. package/dist/workflows/workflow.js.map +0 -1
  314. package/dist/workflows/workflow_state_service.d.ts +0 -35
  315. package/dist/workflows/workflow_state_service.d.ts.map +0 -1
  316. package/dist/workflows/workflow_state_service.js.map +0 -1
  317. package/dist/workflows/workflow_wrapper_service.d.ts.map +0 -1
  318. package/dist/workflows/workflow_wrapper_service.js.map +0 -1
  319. package/src/clients/workflow_client.ts +0 -290
  320. package/src/connection/buffered_connection.ts +0 -47
  321. package/src/connection/connection.ts +0 -34
  322. package/src/connection/embedded_connection.ts +0 -62
  323. package/src/connection/http_connection.ts +0 -228
  324. package/src/connection/lambda_connection.ts +0 -69
  325. package/src/context.ts +0 -633
  326. package/src/context_impl.ts +0 -721
  327. package/src/embedded/api.ts +0 -57
  328. package/src/embedded/handler.ts +0 -36
  329. package/src/embedded/http2_remote.ts +0 -103
  330. package/src/embedded/invocation.ts +0 -126
  331. package/src/endpoint/endpoint_impl.ts +0 -623
  332. package/src/endpoint/http2_handler.ts +0 -151
  333. package/src/endpoint/lambda_handler.ts +0 -178
  334. package/src/endpoint.ts +0 -187
  335. package/src/generated/dev/restate/events.ts +0 -430
  336. package/src/generated/dev/restate/ext.ts +0 -238
  337. package/src/generated/google/protobuf/descriptor.ts +0 -7889
  338. package/src/generated/google/protobuf/empty.ts +0 -150
  339. package/src/generated/google/protobuf/struct.ts +0 -878
  340. package/src/generated/proto/discovery.ts +0 -423
  341. package/src/generated/proto/dynrpc.ts +0 -768
  342. package/src/generated/proto/javascript.ts +0 -488
  343. package/src/generated/proto/protocol.ts +0 -3091
  344. package/src/generated/proto/services.ts +0 -1834
  345. package/src/generated/proto/test.ts +0 -387
  346. package/src/invocation.ts +0 -212
  347. package/src/io/decoder.ts +0 -171
  348. package/src/io/encoder.ts +0 -72
  349. package/src/journal.ts +0 -537
  350. package/src/local_state_store.ts +0 -94
  351. package/src/logger.ts +0 -121
  352. package/src/promise_combinator_tracker.ts +0 -191
  353. package/src/public_api.ts +0 -53
  354. package/src/state_machine.ts +0 -635
  355. package/src/types/errors.ts +0 -297
  356. package/src/types/grpc.ts +0 -97
  357. package/src/types/protocol.ts +0 -201
  358. package/src/types/router.ts +0 -118
  359. package/src/types/types.ts +0 -160
  360. package/src/utils/assumptions.ts +0 -131
  361. package/src/utils/message_logger.ts +0 -112
  362. package/src/utils/promises.ts +0 -118
  363. package/src/utils/public_utils.ts +0 -91
  364. package/src/utils/rand.ts +0 -142
  365. package/src/utils/utils.ts +0 -178
  366. package/src/workflows/workflow.ts +0 -178
  367. package/src/workflows/workflow_state_service.ts +0 -299
  368. package/src/workflows/workflow_wrapper_service.ts +0 -314
  369. /package/dist/{connection → src/connection}/buffered_connection.js +0 -0
  370. /package/dist/{connection → src/connection}/connection.d.ts +0 -0
  371. /package/dist/{connection → src/connection}/connection.js +0 -0
  372. /package/dist/{promise_combinator_tracker.d.ts → src/promise_combinator_tracker.d.ts} +0 -0
  373. /package/dist/{promise_combinator_tracker.js → src/promise_combinator_tracker.js} +0 -0
  374. /package/dist/{utils → src/utils}/promises.d.ts +0 -0
  375. /package/dist/{utils → src/utils}/promises.js +0 -0
@@ -1,7 +1,27 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { RetrySettings } from "./utils/public_utils";
4
- import { Client, SendClient } from "./types/router";
3
+ import { Client, SendClient, ServiceDefinition, VirtualObjectDefinition } from "./types/rpc";
4
+ /**
5
+ * Represents the original request as sent to this handler.
6
+ *
7
+ * A request object includes the request headers, and the raw unparsed
8
+ * request body.
9
+ */
10
+ export interface Request {
11
+ /**
12
+ * The unique id that identifies the current function invocation. This id is guaranteed to be
13
+ * unique across invocations, but constant across reties and suspensions.
14
+ */
15
+ readonly id: Buffer;
16
+ /**
17
+ * Request headers
18
+ */
19
+ readonly headers: ReadonlyMap<string, string>;
20
+ /**
21
+ * Raw unparsed request body
22
+ */
23
+ readonly body: Uint8Array;
24
+ }
5
25
  /**
6
26
  * Key value store operations. Only keyed services have an attached key-value store.
7
27
  */
@@ -15,7 +35,6 @@ export interface KeyValueStore {
15
35
  * @returns a Promise that is resolved with the value of the state key
16
36
  *
17
37
  * @example
18
- * const ctx = restate.useContext(this);
19
38
  * const state = await ctx.get<string>("STATE");
20
39
  */
21
40
  get<T>(name: string): Promise<T | null>;
@@ -29,7 +48,6 @@ export interface KeyValueStore {
29
48
  * @param value value to set
30
49
  *
31
50
  * @example
32
- * const ctx = restate.useContext(this);
33
51
  * ctx.set("STATE", "Hello");
34
52
  */
35
53
  set<T>(name: string, value: T): void;
@@ -38,7 +56,6 @@ export interface KeyValueStore {
38
56
  * @param name key of the state to delete
39
57
  *
40
58
  * @example
41
- * const ctx = restate.useContext(this);
42
59
  * ctx.clear("STATE");
43
60
  */
44
61
  clear(name: string): void;
@@ -46,40 +63,76 @@ export interface KeyValueStore {
46
63
  * Clear/delete all the state entries in the Restate runtime.
47
64
  *
48
65
  * @example
49
- * const ctx = restate.useContext(this);
50
66
  * ctx.clearAll();
51
67
  */
52
68
  clearAll(): void;
53
69
  }
70
+ export interface SendOptions {
71
+ /**
72
+ * Makes a type-safe one-way RPC to the specified target service, after a delay specified by the
73
+ * milliseconds' argument.
74
+ * This method is like setting up a fault-tolerant cron job that enqueues the message in a
75
+ * message queue.
76
+ * The handler calling this function does not have to stay active for the delay time.
77
+ *
78
+ * Both the delay timer and the message are durably stored in Restate and guaranteed to be reliably
79
+ * delivered. The delivery happens no earlier than specified through the delay, but may happen
80
+ * later, if the target service is down, or backpressuring the system.
81
+ *
82
+ * The delay message is journaled for durable execution and will thus not be duplicated when the
83
+ * handler is re-invoked for retries or after suspending.
84
+ *
85
+ * This call will return immediately; the message sending happens asynchronously in the background.
86
+ * Despite that, the message is guaranteed to be sent, because the completion of the invocation that
87
+ * triggers the send (calls this function) happens logically after the sending. That means that any
88
+ * failure where the message does not reach Restate also cannot complete this invocation, and will
89
+ * hence recover this handler and (through the durable execution) recover the message to be sent.
90
+ *
91
+ * @example
92
+ * *Service Side:*
93
+ * ```ts
94
+ * const service = restate.service({
95
+ * ...
96
+ * });
97
+ *
98
+ * ```
99
+ * **Client side:**
100
+ * ```ts
101
+ * ctx.send(service, {delay: 60_000}).anotherAction(1337);
102
+ * ```
103
+ */
104
+ delay?: number;
105
+ }
106
+ export interface ContextDate {
107
+ /** Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
108
+ * This is equivalent to Date.now()
109
+ */
110
+ now(): Promise<number>;
111
+ /** Returns the JSON represention of the current date.
112
+ * This is equivalent to new Date().toJSON()
113
+ **/
114
+ toJSON(): Promise<string>;
115
+ }
116
+ export type RunAction<T> = (() => Promise<T>) | (() => T);
54
117
  /**
55
118
  * The context that gives access to all Restate-backed operations, for example
56
119
  * - sending reliable messages / RPC through Restate
57
- * - side effects
120
+ * - execute non-deterministic closures and memoize their result
58
121
  * - sleeps and delayed calls
59
122
  * - awakeables
60
123
  * - ...
61
124
  *
62
- * Keyed services can also access their key-value store using the {@link KeyedContext}.
125
+ * Virtual objects can also access their key-value store using the {@link ObjectContext}.
63
126
  *
64
- * In gRPC-based API, to access this context, use {@link useContext}.
65
127
  */
66
128
  export interface Context {
67
- /**
68
- * The unique id that identifies the current function invocation. This id is guaranteed to be
69
- * unique across invocations, but constant across reties and suspensions.
70
- */
71
- id: Buffer;
72
- /**
73
- * Name of the service.
74
- */
75
- serviceName: string;
76
129
  /**
77
130
  * Deterministic random methods; these are inherently predictable (seeded on the invocation ID, which is not secret)
78
131
  * and so should not be used for any cryptographic purposes. They are useful for identifiers, idempotency keys,
79
132
  * and for uniform sampling from a set of options. If a cryptographically secure value is needed, please generate that
80
133
  * externally and capture the result with a side effect.
81
134
  *
82
- * Calls to these methods from inside side effects are disallowed and will fail - side effects must be idempotent, and
135
+ * Calls to these methods from inside `ctx.run` are disallowed and will fail - side effects must be idempotent, and
83
136
  * these calls are not.
84
137
  */
85
138
  rand: Rand;
@@ -89,47 +142,54 @@ export interface Context {
89
142
  */
90
143
  console: Console;
91
144
  /**
92
- * Execute a side effect and store the result in Restate. The side effect will thus not
93
- * be re-executed during a later replay, but take the durable result from Restate.
145
+ * Deterministic date.
146
+ */
147
+ date: ContextDate;
148
+ /**
149
+ * Run an operation and store the result in Restate. The operation will thus not
150
+ * be re-run during a later replay, but take the durable result from Restate.
94
151
  *
95
- * Side effects let you capture potentially non-deterministic computation and interaction
152
+ * This let you capture potentially non-deterministic computation and interaction
96
153
  * with external systems in a safe way.
97
154
  *
98
- * Failure semantics of side effects are:
99
- * - If a side effect executed and persisted before, the result (value or Error) will be
155
+ * Failure semantics are:
156
+ * - If an operation has run and persisted before, the result (value or Error) will be
100
157
  * taken from the Restate journal.
101
- * - There is a small window where a side effect may be re-executed twice, if a failure
102
- * occurred between execution and persisting the result.
103
- * - No second side effect will be executed while a previous side effect's result is not
104
- * yet durable. That way, side effects that build on top of each other can assume
105
- * deterministic results from previous effects, and at most one side effect will be
158
+ * - There is a small window where an action may be re-run, if a failure
159
+ * occurred between a successful run and persisting the result.
160
+ * - No second action will be run while a previous run's result is not
161
+ * yet durable. That way, effects that build on top of each other can assume
162
+ * deterministic results from previous runs, and at most one run will be
106
163
  * re-executed on replay (the latest, if the failure happened in the small windows
107
164
  * described above).
108
165
  *
109
- * This function takes an optional retry policy, that determines what happens if the
110
- * side effect throws an error. The default retry policy retries infinitely, with exponential
111
- * backoff and uses suspending sleep for the wait times between retries.
112
- *
113
166
  * @example
114
- * const ctx = restate.useContext(this);
115
- * const result = await ctx.sideEffect(async () => someExternalAction() )
167
+ * const result = await ctx.run(someExternalAction)
116
168
  *
117
169
  * @example
118
170
  * const paymentAction = async () => {
119
171
  * const result = await paymentClient.call(txId, methodIdentifier, amount);
120
- * if (result.error) {
121
- * throw result.error;
172
+ * if (!result.ok) {
173
+ * throw result.cause;
122
174
  * } else {
123
175
  * return result.payment_accepted;
124
176
  * }
125
177
  * }
126
178
  * const paymentAccepted: boolean =
127
- * await ctx.sideEffect(paymentAction, { maxRetries: 10});
179
+ * await ctx.run("paymentAction", paymentAction);
128
180
  *
129
- * @param fn The function to run as a side effect.
130
- * @param retryPolicy The optional policy describing how retries happen.
181
+ * @param action The function to run.
182
+ * @param nameOrOptions the operation's name or a run configuration
131
183
  */
132
- sideEffect<T>(fn: () => Promise<T>, retryPolicy?: RetrySettings): Promise<T>;
184
+ run<T>(action: RunAction<T>): Promise<T>;
185
+ /**
186
+ * Run an operation and store the result in Restate. The operation will thus not
187
+ * be re-run during a later replay, but take the durable result from Restate.
188
+ *
189
+ * @param name the action's name
190
+ * @param action the action to run.
191
+ */
192
+ run<T>(name: string, action: RunAction<T>): Promise<T>;
133
193
  /**
134
194
  * Register an awakeable and pause the processing until the awakeable ID (and optional payload) have been returned to the service
135
195
  * (via ctx.completeAwakeable(...)). The SDK deserializes the payload with `JSON.parse(result.toString()) as T`.
@@ -138,7 +198,6 @@ export interface Context {
138
198
  * - promise: the Promise that needs to be awaited and that is resolved with the payload that was supplied by the service which completed the awakeable
139
199
  *
140
200
  * @example
141
- * const ctx = restate.useContext(this);
142
201
  * const awakeable = ctx.awakeable<string>();
143
202
  *
144
203
  * // send the awakeable ID to some external service that will wake this one back up
@@ -155,7 +214,7 @@ export interface Context {
155
214
  promise: CombineablePromise<T>;
156
215
  };
157
216
  /**
158
- * Resolve an awakeable of another service.
217
+ * Resolve an awakeable.
159
218
  * @param id the string ID of the awakeable.
160
219
  * This is supplied by the service that needs to be woken up.
161
220
  * @param payload the payload to pass to the service that is woken up.
@@ -163,19 +222,17 @@ export interface Context {
163
222
  * and deserializes it in the receiving service with `JSON.parse(result.toString()) as T`.
164
223
  *
165
224
  * @example
166
- * const ctx = restate.useContext(this);
167
225
  * // The sleeping service should have sent the awakeableIdentifier string to this service.
168
226
  * ctx.resolveAwakeable(awakeableIdentifier, "hello");
169
227
  */
170
228
  resolveAwakeable<T>(id: string, payload?: T): void;
171
229
  /**
172
- * Reject an awakeable of another service. When rejecting, the service waiting on this awakeable will be woken up with a terminal error with the provided reason.
230
+ * Reject an awakeable. When rejecting, the service waiting on this awakeable will be woken up with a terminal error with the provided reason.
173
231
  * @param id the string ID of the awakeable.
174
232
  * This is supplied by the service that needs to be woken up.
175
233
  * @param reason the reason of the rejection.
176
234
  *
177
235
  * @example
178
- * const ctx = restate.useContext(this);
179
236
  * // The sleeping service should have sent the awakeableIdentifier string to this service.
180
237
  * ctx.rejectAwakeable(awakeableIdentifier, "super bad error");
181
238
  */
@@ -186,7 +243,6 @@ export interface Context {
186
243
  * This is a lower-bound.
187
244
  *
188
245
  * @example
189
- * const ctx = restate.useContext(this);
190
246
  * await ctx.sleep(1000);
191
247
  */
192
248
  sleep(millis: number): CombineablePromise<void>;
@@ -206,29 +262,38 @@ export interface Context {
206
262
  * @example
207
263
  * *Service Side:*
208
264
  * ```ts
209
- * const router = restate.router({
210
- * someAction: async(ctx: restate.RpcContext, req: string) => { ... },
211
- * anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
265
+ * const service = restate.service(
266
+ * name: "myservice",
267
+ * handlers: {
268
+ * someAction: async(ctx: restate.RpcContext, req: string) => { ... },
269
+ * anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
212
270
  * });
213
271
  *
214
272
  * // option 1: export only the type signature of the router
215
- * export type myApiType = typeof router;
273
+ * export type MyApi = typeof service;
216
274
  *
217
- * // option 2: export the API definition with type and name (path)
218
- * export const myApi: restate.ServiceApi<typeof router> = { path : "myservice" };
275
+ * // option 2: export the API definition with type and name (name)
276
+ * const MyService: MyApi = { name: "myservice" };
219
277
  *
220
- * restate.createServer().bindRouter("myservice", router).listen(9080);
278
+ * restate.createServer().bind(service).listen(9080);
221
279
  * ```
222
280
  * **Client side:**
223
281
  * ```ts
224
282
  * // option 1: use only types and supply service name separately
225
- * const result1 = await ctx.rpc<myApiType>({path: "myservice"}).someAction("hello!");
283
+ * const result1 = await ctx.serviceClient<MyApi>({name: "myservice"}).someAction("hello!");
226
284
  *
227
285
  * // option 2: use full API spec
228
- * const result2 = await ctx.rpc(myApi).anotherAction(1337);
286
+ * const result2 = await ctx.serviceClient(MyService).anotherAction(1337);
229
287
  * ```
230
288
  */
231
- rpc<M>(opts: ServiceApi<M>): Client<M>;
289
+ serviceClient<P extends string, M>(opts: ServiceDefinition<P, M>): Client<M>;
290
+ /**
291
+ * Same as {@link serviceClient} but for virtual objects.
292
+ *
293
+ * @param opts
294
+ * @param key the virtual object key
295
+ */
296
+ objectClient<P extends string, M>(opts: VirtualObjectDefinition<P, M>, key: string): Client<M>;
232
297
  /**
233
298
  * Makes a type-safe one-way RPC to the specified target service. This method effectively behaves
234
299
  * like enqueuing the message in a message queue.
@@ -246,94 +311,59 @@ export interface Context {
246
311
  * @example
247
312
  * *Service Side:*
248
313
  * ```ts
249
- * const router = restate.router({
250
- * someAction: async(ctx: restate.RpcContext, req: string) => { ... },
251
- * anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
314
+ * const service = restate.service(
315
+ * name: "myservice",
316
+ * handlers: {
317
+ * someAction: async(ctx: restate.RpcContext, req: string) => { ... },
318
+ * anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
252
319
  * });
253
320
  *
254
321
  * // option 1: export only the type signature of the router
255
- * export type myApiType = typeof router;
322
+ * export type MyApi = typeof service;
256
323
  *
257
- * // option 2: export the API definition with type and name (path)
258
- * export const myApi: restate.ServiceApi<typeof router> = { path : "myservice" };
324
+ * // option 2: export the API definition with type and name (name)
325
+ * const MyService: MyApi = { name: "myservice" };
259
326
  *
260
- * restate.createServer().bindRouter("myservice", router).listen(9080);
327
+ * restate.createServer().bind(service).listen(9080);
261
328
  * ```
262
329
  * **Client side:**
263
330
  * ```ts
264
331
  * // option 1: use only types and supply service name separately
265
- * ctx.send<myApiType>({path: "myservice"}).someAction("hello!");
332
+ * ctx.serviceSendClient<MyApi>({name: "myservice"}).someAction("hello!");
266
333
  *
267
334
  * // option 2: use full API spec
268
- * ctx.send(myApi).anotherAction(1337);
335
+ * ctx.serviceSendClient(MyService).anotherAction(1337);
269
336
  * ```
270
337
  */
271
- send<M>(opts: ServiceApi<M>): SendClient<M>;
338
+ serviceSendClient<P extends string, M>(service: ServiceDefinition<P, M>, opts?: SendOptions): SendClient<M>;
272
339
  /**
273
- * Makes a type-safe one-way RPC to the specified target service, after a delay specified by the
274
- * milliseconds' argument.
275
- * This method is like stetting up a fault-tolerant cron job that enqueues the message in a
276
- * message queue.
277
- * The handler calling this function does not have to stay active for the delay time.
340
+ * Same as {@link serviceSendClient} but for virtual objects.
278
341
  *
279
- * Both the delay timer and the message are durably stored in Restate and guaranteed to be reliably
280
- * delivered. The delivery happens no earlier than specified through the delay, but may happen
281
- * later, if the target service is down, or backpressuring the system.
282
- *
283
- * The delay message is journaled for durable execution and will thus not be duplicated when the
284
- * handler is re-invoked for retries or after suspending.
285
- *
286
- * This call will return immediately; the message sending happens asynchronously in the background.
287
- * Despite that, the message is guaranteed to be sent, because the completion of the invocation that
288
- * triggers the send (calls this function) happens logically after the sending. That means that any
289
- * failure where the message does not reach Restate also cannot complete this invocation, and will
290
- * hence recover this handler and (through the durable execution) recover the message to be sent.
291
- *
292
- * @example
293
- * *Service Side:*
294
- * ```ts
295
- * const router = restate.router({
296
- * someAction: async(ctx: restate.RpcContext, req: string) => { ... },
297
- * anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
298
- * });
299
- *
300
- * // option 1: export only the type signature of the router
301
- * export type myApiType = typeof router;
302
- *
303
- * // option 2: export the API definition with type and name (path)
304
- * export const myApi: restate.ServiceApi<typeof router> = { path : "myservice" };
305
- *
306
- * restate.createServer().bindRouter("myservice", router).listen(9080);
307
- * ```
308
- * **Client side:**
309
- * ```ts
310
- * // option 1: use only types and supply service name separately
311
- * ctx.sendDelayed<myApiType>({path: "myservice"}, 60_000).someAction("hello!");
312
- *
313
- * // option 2: use full API spec
314
- * ctx.sendDelayed(myApi, 60_000).anotherAction(1337);
315
- * ```
342
+ * @param obj
343
+ * @param key the virtual object key
344
+ * @param opts Send options
316
345
  */
317
- sendDelayed<M>(opts: ServiceApi<M>, delay: number): SendClient<M>;
346
+ objectSendClient<P extends string, M>(obj: VirtualObjectDefinition<P, M>, key: string, opts?: SendOptions): SendClient<M>;
318
347
  /**
319
- * Get the {@link RestateGrpcChannel} to invoke gRPC based services.
348
+ * Returns the raw request that triggered that handler.
349
+ * Use that object to inspect the original request headers
320
350
  */
321
- grpcChannel(): RestateGrpcChannel;
351
+ request(): Request;
322
352
  }
323
353
  /**
324
354
  * The context that gives access to all Restate-backed operations, for example
325
355
  * - sending reliable messages / RPC through Restate
326
356
  * - access/update state
327
- * - side effects
357
+ * - execute non-deterministic closures and memoize their result
328
358
  * - sleeps and delayed calls
329
359
  * - awakeables
330
360
  * - ...
331
361
  *
332
- * This context can be used only within keyed services/routers.
362
+ * This context can be used only within virtual objects.
333
363
  *
334
- * In gRPC-based API, to access this context, use {@link useKeyedContext}.
335
364
  */
336
- export interface KeyedContext extends Context, KeyValueStore {
365
+ export interface ObjectContext extends Context, KeyValueStore {
366
+ key: string;
337
367
  }
338
368
  export interface Rand {
339
369
  /**
@@ -351,7 +381,6 @@ export interface Rand {
351
381
  * A promise that can be combined using Promise combinators in RestateContext.
352
382
  */
353
383
  export type CombineablePromise<T> = Promise<T> & {
354
- __restate_context: Context;
355
384
  /**
356
385
  * Creates a promise that awaits for the current promise up to the specified timeout duration.
357
386
  * If the timeout is fired, this Promise will be rejected with a {@link TimeoutError}.
@@ -404,111 +433,4 @@ export declare const CombineablePromise: {
404
433
  */
405
434
  allSettled<T_3 extends [] | readonly CombineablePromise<unknown>[]>(values: T_3): Promise<{ -readonly [P_1 in keyof T_3]: PromiseSettledResult<Awaited<T_3[P_1]>>; }>;
406
435
  };
407
- /**
408
- * Interface to interact with **gRPC** based services. You can use this interface to instantiate a gRPC generated client.
409
- */
410
- export interface RestateGrpcChannel {
411
- /**
412
- * Unidirectional call to other Restate services ( = in background / async / not waiting on response).
413
- * To do this, wrap the call via the proto-ts client with oneWayCall, as shown in the example.
414
- *
415
- * NOTE: this returns a Promise because we override the gRPC clients provided by proto-ts.
416
- * So we are required to return a Promise.
417
- *
418
- * @param call Invoke another service by using the generated proto-ts client.
419
- * @example
420
- * const ctx = restate.useContext(this);
421
- * const client = new GreeterClientImpl(ctx);
422
- * await ctx.oneWayCall(() =>
423
- * client.greet(Request.create({ name: "Peter" }))
424
- * )
425
- */
426
- oneWayCall(call: () => Promise<any>): Promise<void>;
427
- /**
428
- * Delayed unidirectional call to other Restate services ( = in background / async / not waiting on response).
429
- * To do this, wrap the call via the proto-ts client with delayedCall, as shown in the example.
430
- * Add the delay in millis as the second parameter.
431
- *
432
- * NOTE: this returns a Promise because we override the gRPC clients provided by proto-ts.
433
- * So we are required to return a Promise.
434
- *
435
- * @param call Invoke another service by using the generated proto-ts client.
436
- * @param delayMillis millisecond delay duration to delay the execution of the call
437
- * @example
438
- * const ctx = restate.useContext(this);
439
- * const client = new GreeterClientImpl(ctx);
440
- * await ctx.delayedCall(() =>
441
- * client.greet(Request.create({ name: "Peter" })),
442
- * 5000
443
- * )
444
- */
445
- delayedCall(call: () => Promise<any>, delayMillis?: number): Promise<void>;
446
- /**
447
- * Call another Restate service and await the response.
448
- *
449
- * This function is not recommended to be called directly. Instead, use the generated gRPC client
450
- * that was generated based on the Protobuf service definitions (which internally use this method):
451
- *
452
- * @example
453
- * ```
454
- * const ctx = restate.useContext(this);
455
- * const client = new GreeterClientImpl(ctx);
456
- * client.greet(Request.create({ name: "Peter" }))
457
- * ```
458
- *
459
- * @param service name of the service to call
460
- * @param method name of the method to call
461
- * @param data payload as Uint8Array
462
- * @returns a Promise that is resolved with the response of the called service
463
- */
464
- request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
465
- }
466
- /**
467
- * @deprecated use {@link KeyedContext}.
468
- */
469
- export type RestateContext = KeyedContext;
470
- /**
471
- * Returns the {@link Context} which is the entrypoint for all interaction with Restate.
472
- * Use this from within a method to retrieve the {@link Context}.
473
- * The context is bounded to a single invocation.
474
- *
475
- * @example
476
- * const ctx = restate.useContext(this);
477
- *
478
- */
479
- export declare function useContext<T>(instance: T): Context;
480
- /**
481
- * Returns the {@link KeyedContext} which is the entrypoint for all interaction with Restate.
482
- * Use this from within a method of a keyed service to retrieve the {@link KeyedContext}.
483
- * The context is bounded to a single invocation.
484
- *
485
- * @example
486
- * const ctx = restate.useKeyedContext(this);
487
- *
488
- */
489
- export declare function useKeyedContext<T>(instance: T): KeyedContext;
490
- /**
491
- * ServiceApi captures the type and parameters to make RPC calls and send messages to
492
- * a set of RPC handlers in a router.
493
- *
494
- * @example
495
- * **Service Side:**
496
- * ```ts
497
- * const router = restate.router({
498
- * someAction: async(ctx: restate.RpcContext, req: string) => { ... },
499
- * anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
500
- * });
501
- *
502
- * export const myApi: restate.ServiceApi<typeof router> = { path : "myservice" };
503
- *
504
- * restate.createServer().bindRouter("myservice", router).listen(9080);
505
- * ```
506
- * **Client side:**
507
- * ```ts
508
- * ctx.rpc(myApi).someAction("hello!");
509
- * ```
510
- */
511
- export type ServiceApi<_M = unknown> = {
512
- path: string;
513
- };
514
436
  //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"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"}
@@ -10,7 +10,8 @@
10
10
  * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.useKeyedContext = exports.useContext = exports.CombineablePromise = void 0;
13
+ exports.CombineablePromise = void 0;
14
+ const context_impl_1 = require("./context_impl");
14
15
  exports.CombineablePromise = {
15
16
  /**
16
17
  * Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -25,7 +26,7 @@ exports.CombineablePromise = {
25
26
  if (values.length == 0) {
26
27
  return Promise.all(values);
27
28
  }
28
- return values[0].__restate_context.createCombinator(Promise.all.bind(Promise), values);
29
+ return context_impl_1.ContextImpl.createCombinator(Promise.all.bind(Promise), values);
29
30
  },
30
31
  /**
31
32
  * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -40,7 +41,7 @@ exports.CombineablePromise = {
40
41
  if (values.length == 0) {
41
42
  return Promise.race(values);
42
43
  }
43
- return values[0].__restate_context.createCombinator(Promise.race.bind(Promise), values);
44
+ return context_impl_1.ContextImpl.createCombinator(Promise.race.bind(Promise), values);
44
45
  },
45
46
  /**
46
47
  * Creates a promise that fulfills when any of the input's promises fulfills, with this first fulfillment value.
@@ -56,7 +57,7 @@ exports.CombineablePromise = {
56
57
  if (values.length == 0) {
57
58
  return Promise.any(values);
58
59
  }
59
- return values[0].__restate_context.createCombinator(Promise.any.bind(Promise), values);
60
+ return context_impl_1.ContextImpl.createCombinator(Promise.any.bind(Promise), values);
60
61
  },
61
62
  /**
62
63
  * Creates a promise that fulfills when all the input's promises settle (including when an empty iterable is passed),
@@ -71,43 +72,7 @@ exports.CombineablePromise = {
71
72
  if (values.length == 0) {
72
73
  return Promise.allSettled(values);
73
74
  }
74
- return values[0].__restate_context.createCombinator(Promise.allSettled.bind(Promise), values);
75
+ return context_impl_1.ContextImpl.createCombinator(Promise.allSettled.bind(Promise), values);
75
76
  },
76
77
  };
77
- /**
78
- * Returns the {@link Context} which is the entrypoint for all interaction with Restate.
79
- * Use this from within a method to retrieve the {@link Context}.
80
- * The context is bounded to a single invocation.
81
- *
82
- * @example
83
- * const ctx = restate.useContext(this);
84
- *
85
- */
86
- function useContext(instance) {
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- const wrapper = instance;
89
- if (wrapper.$$restate === undefined || wrapper.$$restate === null) {
90
- throw new Error(`not running within a Restate call.`);
91
- }
92
- return wrapper.$$restate;
93
- }
94
- exports.useContext = useContext;
95
- /**
96
- * Returns the {@link KeyedContext} which is the entrypoint for all interaction with Restate.
97
- * Use this from within a method of a keyed service to retrieve the {@link KeyedContext}.
98
- * The context is bounded to a single invocation.
99
- *
100
- * @example
101
- * const ctx = restate.useKeyedContext(this);
102
- *
103
- */
104
- function useKeyedContext(instance) {
105
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
- const wrapper = instance;
107
- if (wrapper.$$restate === undefined || wrapper.$$restate === null) {
108
- throw new Error(`not running within a Restate call.`);
109
- }
110
- return wrapper.$$restate;
111
- }
112
- exports.useKeyedContext = useKeyedContext;
113
78
  //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAQH,iDAA6C;AA2ahC,QAAA,kBAAkB,GAAG;IAChC;;;;;;;;OAQG;IACH,GAAG,CACD,MAAS;QAET,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EACzB,MAAM,CAGN,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CACF,MAAS;QAET,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAC1B,MAAM,CACwB,CAAC;IACnC,CAAC;IAED;;;;;;;;;OASG;IACH,GAAG,CACD,MAAS;QAET,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EACzB,MAAM,CACwB,CAAC;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,UAAU,CACR,MAAS;QAIT,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SACnC;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAChC,MAAM,CAGN,CAAC;IACL,CAAC;CACF,CAAC"}