@restatedev/restate-sdk-cloudflare-workers 1.15.0-rc.0 → 1.15.0-rc.2

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 (90) hide show
  1. package/dist/common_api.d.cts +1 -1
  2. package/dist/common_api.d.cts.map +1 -1
  3. package/dist/common_api.d.ts +1 -1
  4. package/dist/common_api.d.ts.map +1 -1
  5. package/dist/common_api.js +1 -1
  6. package/dist/common_api.js.map +1 -1
  7. package/dist/context_impl.cjs +1 -0
  8. package/dist/context_impl.d.ts.map +1 -0
  9. package/dist/context_impl.js +2 -1
  10. package/dist/context_impl.js.map +1 -1
  11. package/dist/endpoint/components.d.ts.map +1 -0
  12. package/dist/endpoint/discovery.d.ts +184 -0
  13. package/dist/endpoint/discovery.d.ts.map +1 -0
  14. package/dist/endpoint/discovery.js +7 -0
  15. package/dist/endpoint/discovery.js.map +1 -0
  16. package/dist/endpoint/endpoint.d.ts.map +1 -0
  17. package/dist/endpoint/handlers/core_logging.d.ts +10 -0
  18. package/dist/endpoint/handlers/core_logging.d.ts.map +1 -0
  19. package/dist/endpoint/handlers/discovery.d.ts +5 -0
  20. package/dist/endpoint/handlers/discovery.d.ts.map +1 -0
  21. package/dist/endpoint/handlers/fetch.d.ts +5 -0
  22. package/dist/endpoint/handlers/fetch.d.ts.map +1 -0
  23. package/dist/endpoint/handlers/generic.cjs +4 -1
  24. package/dist/endpoint/handlers/generic.d.ts +5 -0
  25. package/dist/endpoint/handlers/generic.d.ts.map +1 -0
  26. package/dist/endpoint/handlers/generic.js +5 -2
  27. package/dist/endpoint/handlers/generic.js.map +1 -1
  28. package/dist/endpoint/handlers/lambda.d.ts +10 -0
  29. package/dist/endpoint/handlers/lambda.d.ts.map +1 -0
  30. package/dist/endpoint/handlers/preview.d.ts +5 -0
  31. package/dist/endpoint/handlers/preview.d.ts.map +1 -0
  32. package/dist/endpoint/handlers/types.d.ts.map +1 -0
  33. package/dist/endpoint/handlers/types.js +2 -0
  34. package/dist/endpoint/handlers/types.js.map +1 -0
  35. package/dist/endpoint/handlers/utils.d.ts +23 -0
  36. package/dist/endpoint/handlers/utils.d.ts.map +1 -0
  37. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts +1 -0
  38. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.js +16 -0
  39. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm +0 -0
  40. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm.d.ts +1 -0
  41. package/dist/endpoint/node_endpoint.d.ts +28 -0
  42. package/dist/endpoint/node_endpoint.d.ts.map +1 -0
  43. package/dist/endpoint/types.js +2 -0
  44. package/dist/endpoint/types.js.map +1 -0
  45. package/dist/endpoint/withOptions.d.ts +4 -0
  46. package/dist/endpoint/withOptions.d.ts.map +1 -0
  47. package/dist/endpoint.js +12 -0
  48. package/dist/endpoint.js.map +1 -0
  49. package/dist/error_sanitization.d.ts +13 -0
  50. package/dist/error_sanitization.d.ts.map +1 -0
  51. package/dist/fetch.cjs +1 -0
  52. package/dist/fetch.d.cts +2 -2
  53. package/dist/fetch.d.ts +2 -2
  54. package/dist/hooks.js +2 -0
  55. package/dist/hooks.js.map +1 -0
  56. package/dist/index.cjs +1 -0
  57. package/dist/index.d.cts +2 -2
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +2 -2
  61. package/dist/index.js.map +1 -0
  62. package/dist/io.d.ts.map +1 -0
  63. package/dist/lambda.cjs +1 -0
  64. package/dist/lambda.d.cts +2 -2
  65. package/dist/lambda.d.ts +2 -2
  66. package/dist/lambda.js +2 -2
  67. package/dist/logging/console_logger_transport.d.ts +5 -0
  68. package/dist/logging/console_logger_transport.d.ts.map +1 -0
  69. package/dist/logging/logger.d.ts.map +1 -0
  70. package/dist/node.cjs +1 -0
  71. package/dist/node.d.cts +2 -2
  72. package/dist/node.d.ts +2 -2
  73. package/dist/node.js +2 -2
  74. package/dist/package.cjs +1 -1
  75. package/dist/package.js +1 -1
  76. package/dist/package.js.map +1 -1
  77. package/dist/types/errors.cjs +26 -0
  78. package/dist/types/errors.d.cts +18 -1
  79. package/dist/types/errors.d.cts.map +1 -1
  80. package/dist/types/errors.d.ts +18 -1
  81. package/dist/types/errors.d.ts.map +1 -1
  82. package/dist/types/errors.js +26 -1
  83. package/dist/types/errors.js.map +1 -1
  84. package/dist/user_agent.d.ts +2 -0
  85. package/dist/user_agent.d.ts.map +1 -0
  86. package/dist/utils/external_progress_channel.d.ts +19 -0
  87. package/dist/utils/external_progress_channel.d.ts.map +1 -0
  88. package/dist/utils/rand.d.ts +13 -0
  89. package/dist/utils/rand.d.ts.map +1 -0
  90. package/package.json +3 -3
package/dist/lambda.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
1
+ import { CancelledError, PauseError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
2
2
  import { Hooks, HooksProvider, Interceptor } from "./hooks.js";
3
3
  import { Client, ClientCallOptions, ClientSendOptions, InferArg, ObjectHandlerOpts, ObjectOptions, ObjectOpts, Opts, RemoveVoidArgument, RetryPolicy, SendClient, SendOpts, ServiceHandlerOpts, ServiceOptions, ServiceOpts, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
4
4
  import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, SignalReference, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.js";
@@ -31,5 +31,5 @@ declare function endpoint(): LambdaEndpoint;
31
31
  */
32
32
  declare function createEndpointHandler(options: EndpointOptions): (event: any, ctx: any) => Promise<any>;
33
33
  //#endregion
34
- export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, JournalValueCodec, KeyValueStore, type LambdaEndpoint, LogMetadata, LogSource, LoggerContext, LoggerTransport, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, SignalReference, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, service, workflow };
34
+ export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, JournalValueCodec, KeyValueStore, type LambdaEndpoint, LogMetadata, LogSource, LoggerContext, LoggerTransport, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, PauseError, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, SignalReference, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, service, workflow };
35
35
  //# sourceMappingURL=lambda.d.ts.map
package/dist/lambda.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CancelledError, RestateError, RetryableError, TerminalError, TimeoutError } from "./types/errors.js";
1
+ import { CancelledError, PauseError, RestateError, RetryableError, TerminalError, TimeoutError } from "./types/errors.js";
2
2
  import { isRestatePromise } from "./promises.js";
3
3
  import { InvocationIdParser, RestatePromise } from "./context.js";
4
4
  import { Opts, SendOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
@@ -33,5 +33,5 @@ function createEndpointHandler(options) {
33
33
  }
34
34
 
35
35
  //#endregion
36
- export { CancelledError, CombineablePromise, InvocationIdParser, Opts, RestateError, RestatePromise, RetryableError, SendOpts, TerminalError, TimeoutError, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_exports as internal, isRestatePromise, object, rpc, serde, service, workflow };
36
+ export { CancelledError, CombineablePromise, InvocationIdParser, Opts, PauseError, RestateError, RestatePromise, RetryableError, SendOpts, TerminalError, TimeoutError, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_exports as internal, isRestatePromise, object, rpc, serde, service, workflow };
37
37
  //# sourceMappingURL=lambda.js.map
@@ -0,0 +1,5 @@
1
+ import type { LoggerTransport } from "./logger_transport.js";
2
+ import { RestateLogLevel } from "./logger_transport.js";
3
+ export declare const defaultLoggerTransport: LoggerTransport;
4
+ export declare const DEFAULT_CONSOLE_LOGGER_LOG_LEVEL: RestateLogLevel;
5
+ //# sourceMappingURL=console_logger_transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console_logger_transport.d.ts","sourceRoot":"","sources":["../../src/logging/console_logger_transport.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,eAAO,MAAM,sBAAsB,EAAE,eA0BpC,CAAC;AAKF,eAAO,MAAM,gCAAgC,iBAAwB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,SAAS,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;IACrC,WAAW,CACT,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,GAAG,EACb,GAAG,cAAc,EAAE,GAAG,EAAE,GACvB,IAAI,CAAC;CACT;AAED,wBAAgB,YAAY,CAC1B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,aAAa,EACvB,WAAW,GAAE,MAAM,OAAqB,GACvC,MAAM,CA2FR"}
package/dist/node.cjs CHANGED
@@ -70,6 +70,7 @@ exports.CancelledError = require_errors.CancelledError;
70
70
  exports.CombineablePromise = require_common_api.CombineablePromise;
71
71
  exports.InvocationIdParser = require_context.InvocationIdParser;
72
72
  exports.Opts = require_rpc.Opts;
73
+ exports.PauseError = require_errors.PauseError;
73
74
  exports.RestateError = require_errors.RestateError;
74
75
  exports.RestatePromise = require_context.RestatePromise;
75
76
  exports.RetryableError = require_errors.RetryableError;
package/dist/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.cjs";
1
+ import { CancelledError, PauseError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.cjs";
2
2
  import { Hooks, HooksProvider, Interceptor } from "./hooks.cjs";
3
3
  import { Client, ClientCallOptions, ClientSendOptions, InferArg, ObjectHandlerOpts, ObjectOptions, ObjectOpts, Opts, RemoveVoidArgument, RetryPolicy, SendClient, SendOpts, ServiceHandlerOpts, ServiceOptions, ServiceOpts, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, handlers, object, rpc, service, workflow } from "./types/rpc.cjs";
4
4
  import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, SignalReference, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.cjs";
@@ -86,5 +86,5 @@ declare function serve({
86
86
  ...options
87
87
  }: ServeOptions): Promise<number>;
88
88
  //#endregion
89
- export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, NodeEndpointOptions, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, ServeOptions, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, SignalReference, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
89
+ export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, NodeEndpointOptions, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, PauseError, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, ServeOptions, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, SignalReference, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
90
90
  //# sourceMappingURL=node.d.cts.map
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
1
+ import { CancelledError, PauseError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
2
2
  import { Hooks, HooksProvider, Interceptor } from "./hooks.js";
3
3
  import { Client, ClientCallOptions, ClientSendOptions, InferArg, ObjectHandlerOpts, ObjectOptions, ObjectOpts, Opts, RemoveVoidArgument, RetryPolicy, SendClient, SendOpts, ServiceHandlerOpts, ServiceOptions, ServiceOpts, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
4
4
  import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, SignalReference, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.js";
@@ -86,5 +86,5 @@ declare function serve({
86
86
  ...options
87
87
  }: ServeOptions): Promise<number>;
88
88
  //#endregion
89
- export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, NodeEndpointOptions, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, ServeOptions, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, SignalReference, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
89
+ export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, InvocationReference, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, NodeEndpointOptions, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, PauseError, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, ServeOptions, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, SignalReference, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
90
90
  //# sourceMappingURL=node.d.ts.map
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CancelledError, RestateError, RetryableError, TerminalError, TimeoutError } from "./types/errors.js";
1
+ import { CancelledError, PauseError, RestateError, RetryableError, TerminalError, TimeoutError } from "./types/errors.js";
2
2
  import { isRestatePromise } from "./promises.js";
3
3
  import { InvocationIdParser, RestatePromise } from "./context.js";
4
4
  import { Opts, SendOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
@@ -63,5 +63,5 @@ function serve({ port,...options }) {
63
63
  }
64
64
 
65
65
  //#endregion
66
- export { CancelledError, CombineablePromise, InvocationIdParser, Opts, RestateError, RestatePromise, RetryableError, SendOpts, TerminalError, TimeoutError, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
66
+ export { CancelledError, CombineablePromise, InvocationIdParser, Opts, PauseError, RestateError, RestatePromise, RetryableError, SendOpts, TerminalError, TimeoutError, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
67
67
  //# sourceMappingURL=node.js.map
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "1.15.0-rc.0";
3
+ var version = "1.15.0-rc.2";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.15.0-rc.0";
2
+ var version = "1.15.0-rc.2";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@restatedev/restate-sdk\",\n \"version\": \"1.15.0-rc.0\",\n \"description\": \"Typescript SDK for Restate\",\n \"author\": \"Restate Developers\",\n \"email\": \"code@restate.dev\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/restatedev/sdk-typescript#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/restatedev/sdk-typescript.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/restatedev/sdk-typescript/issues\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./fetch\": {\n \"import\": \"./dist/fetch.js\",\n \"require\": \"./dist/fetch.cjs\"\n },\n \"./lambda\": {\n \"import\": \"./dist/lambda.js\",\n \"require\": \"./dist/lambda.cjs\"\n },\n \"./node\": {\n \"import\": \"./dist/node.js\",\n \"require\": \"./dist/node.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"test\": \"turbo run _test --filter={.}...\",\n \"_test\": \"vitest run\",\n \"build\": \"turbo run _build --filter={.}...\",\n \"_build\": \"tsc --noEmit && tsdown\",\n \"dev\": \"tsc --noEmit --watch\",\n \"clean\": \"rm -rf dist *.tsbuildinfo .turbo\",\n \"check:types\": \"turbo run _check:types --filter={.}...\",\n \"_check:types\": \"tsc --noEmit --project tsconfig.build.json\",\n \"lint\": \"eslint .\",\n \"check:exports\": \"turbo run _check:exports --filter={.}...\",\n \"_check:exports\": \"attw --pack .\",\n \"check:api\": \"turbo run _check:api --filter={.}...\",\n \"_check:api\": \"api-extractor run --local && api-extractor run --local --config api-extractor.fetch.json && api-extractor run --local --config api-extractor.lambda.json && api-extractor run --local --config api-extractor.node.json\",\n \"prepublishOnly\": \"pnpm -w verify\"\n },\n \"dependencies\": {\n \"@restatedev/restate-sdk-core\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/aws-lambda\": \"^8.10.115\"\n },\n \"typesVersions\": {\n \"*\": {\n \"fetch\": [\n \"./dist/fetch.d.ts\"\n ],\n \"lambda\": [\n \"./dist/lambda.d.ts\"\n ],\n \"node\": [\n \"./dist/node.d.ts\"\n ]\n }\n }\n}\n"],"mappings":";cAEa"}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@restatedev/restate-sdk\",\n \"version\": \"1.15.0-rc.2\",\n \"description\": \"Typescript SDK for Restate\",\n \"author\": \"Restate Developers\",\n \"email\": \"code@restate.dev\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/restatedev/sdk-typescript#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/restatedev/sdk-typescript.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/restatedev/sdk-typescript/issues\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./fetch\": {\n \"import\": \"./dist/fetch.js\",\n \"require\": \"./dist/fetch.cjs\"\n },\n \"./lambda\": {\n \"import\": \"./dist/lambda.js\",\n \"require\": \"./dist/lambda.cjs\"\n },\n \"./node\": {\n \"import\": \"./dist/node.js\",\n \"require\": \"./dist/node.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"test\": \"turbo run _test --filter={.}...\",\n \"_test\": \"vitest run\",\n \"build\": \"turbo run _build --filter={.}...\",\n \"_build\": \"tsc --noEmit && tsdown\",\n \"dev\": \"tsc --noEmit --watch\",\n \"clean\": \"rm -rf dist *.tsbuildinfo .turbo\",\n \"check:types\": \"turbo run _check:types --filter={.}...\",\n \"_check:types\": \"tsc --noEmit --project tsconfig.build.json\",\n \"lint\": \"eslint .\",\n \"check:exports\": \"turbo run _check:exports --filter={.}...\",\n \"_check:exports\": \"attw --pack .\",\n \"check:api\": \"turbo run _check:api --filter={.}...\",\n \"_check:api\": \"api-extractor run --local && api-extractor run --local --config api-extractor.fetch.json && api-extractor run --local --config api-extractor.lambda.json && api-extractor run --local --config api-extractor.node.json\",\n \"prepublishOnly\": \"pnpm -w verify\"\n },\n \"dependencies\": {\n \"@restatedev/restate-sdk-core\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/aws-lambda\": \"^8.10.115\"\n },\n \"typesVersions\": {\n \"*\": {\n \"fetch\": [\n \"./dist/fetch.d.ts\"\n ],\n \"lambda\": [\n \"./dist/lambda.d.ts\"\n ],\n \"node\": [\n \"./dist/node.d.ts\"\n ]\n }\n }\n}\n"],"mappings":";cAEa"}
@@ -100,6 +100,31 @@ var RetryableError = class RetryableError extends RestateError {
100
100
  }
101
101
  };
102
102
  /**
103
+ * When thrown, Restate will pause the execution of the current invocation.
104
+ * This error type MUST be used only within a `ctx.run` closure. If thrown outside a `ctx.run` closure, pause will be ignored.
105
+ *
106
+ * You can wrap another error using {@link from}.
107
+ */
108
+ var PauseError = class extends RestateError {
109
+ name = "PauseError";
110
+ constructor(message, options) {
111
+ super(message, {
112
+ errorCode: options?.errorCode,
113
+ cause: options?.cause
114
+ });
115
+ }
116
+ /**
117
+ * Create a `PauseError` from the given cause.
118
+ */
119
+ static from(cause) {
120
+ const error = ensureError(cause);
121
+ return new RetryableError(error.message, {
122
+ errorCode: error["errorCode"],
123
+ cause
124
+ });
125
+ }
126
+ };
127
+ /**
103
128
  * Returns true if the error indicates the current attempt is ending without
104
129
  * a failure — e.g. the runtime suspended the invocation (waiting for
105
130
  * `ctx.sleep()` or `ctx.call()`), or the connection was dropped (kill).
@@ -115,6 +140,7 @@ function isSuspendedError(e) {
115
140
  //#endregion
116
141
  exports.CancelledError = CancelledError;
117
142
  exports.INTERNAL_ERROR_CODE = INTERNAL_ERROR_CODE;
143
+ exports.PauseError = PauseError;
118
144
  exports.RestateError = RestateError;
119
145
  exports.RetryableError = RetryableError;
120
146
  exports.TerminalError = TerminalError;
@@ -70,6 +70,23 @@ declare class RetryableError extends RestateError {
70
70
  */
71
71
  static from(cause: any, options?: RetryableErrorOptions): RetryableError;
72
72
  }
73
+ /**
74
+ * When thrown, Restate will pause the execution of the current invocation.
75
+ * This error type MUST be used only within a `ctx.run` closure. If thrown outside a `ctx.run` closure, pause will be ignored.
76
+ *
77
+ * You can wrap another error using {@link from}.
78
+ */
79
+ declare class PauseError extends RestateError {
80
+ name: string;
81
+ constructor(message: string, options?: {
82
+ errorCode?: number;
83
+ cause?: any;
84
+ });
85
+ /**
86
+ * Create a `PauseError` from the given cause.
87
+ */
88
+ static from(cause: any): RetryableError;
89
+ }
73
90
  /**
74
91
  * Returns true if the error indicates the current attempt is ending without
75
92
  * a failure — e.g. the runtime suspended the invocation (waiting for
@@ -81,5 +98,5 @@ declare class RetryableError extends RestateError {
81
98
  */
82
99
  declare function isSuspendedError(e: unknown): boolean;
83
100
  //#endregion
84
- export { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError, isSuspendedError };
101
+ export { CancelledError, PauseError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError, isSuspendedError };
85
102
  //# sourceMappingURL=errors.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/types/errors.ts"],"sourcesContent":[],"mappings":";;;;AAwHa,cA3CA,YAAA,SAAqB,KAAA,CA2Ca;EAWlC,SAAA,IAAA,EAAA,MAAe;EAQX,IAAA,EAAA,MAAA;EAaJ,WAAA,CAAA,OAAe,EAAA,MAAA,EAAA,OAuBQ,CAvBR,EAAA;IAGJ,SAAA,CAAA,EAAA,MAAA;IAIV,KAAA,CAAA,EAAA,GAAA;EAgBsB,CAAA;;;;AAmBpC;;;cAtGa,aAAA,SAAsB,YAAA;;sBAEN;;;;;;;;;;;;eAeZ;;;;;;cAWJ,YAAA,SAAqB,aAAA;;;;;;;cAWrB,cAAA,SAAuB,aAAA;;;;UAQnB,qBAAA;;;;eAIF;;;;;;;;cASF,cAAA,SAAuB,YAAA;;wBAGZ;yCAIV;;;;;;;oCAgBsB,wBAAwB;;;;;;;;;;;iBAmB5C,gBAAA"}
1
+ {"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/types/errors.ts"],"sourcesContent":[],"mappings":";;;;AAwHa,cA3CA,YAAA,SAAqB,KAAA,CA2Ca;EAWlC,SAAA,IAAA,EAAA,MAAe;EAQX,IAAA,EAAA,MAAA;EAaJ,WAAA,CAAA,OAAe,EAAA,MAAA,EAAA,OAuBQ,CAvBR,EAAA;IAGJ,SAAA,CAAA,EAAA,MAAA;IAIV,KAAA,CAAA,EAAA,GAAA;EAgBsB,CAAA;;;;AAgBpC;AAsCA;;cAzIa,aAAA,SAAsB,YAAA;;sBAEN;;;;;;;;;;;;eAeZ;;;;;;cAWJ,YAAA,SAAqB,aAAA;;;;;;;cAWrB,cAAA,SAAuB,aAAA;;;;UAQnB,qBAAA;;;;eAIF;;;;;;;;cASF,cAAA,SAAuB,YAAA;;wBAGZ;yCAIV;;;;;;;oCAgBsB,wBAAwB;;;;;;;;cAgB/C,UAAA,SAAmB,YAAA;;;;;;;;;2BAoBL;;;;;;;;;;;iBAkBX,gBAAA"}
@@ -70,6 +70,23 @@ declare class RetryableError extends RestateError {
70
70
  */
71
71
  static from(cause: any, options?: RetryableErrorOptions): RetryableError;
72
72
  }
73
+ /**
74
+ * When thrown, Restate will pause the execution of the current invocation.
75
+ * This error type MUST be used only within a `ctx.run` closure. If thrown outside a `ctx.run` closure, pause will be ignored.
76
+ *
77
+ * You can wrap another error using {@link from}.
78
+ */
79
+ declare class PauseError extends RestateError {
80
+ name: string;
81
+ constructor(message: string, options?: {
82
+ errorCode?: number;
83
+ cause?: any;
84
+ });
85
+ /**
86
+ * Create a `PauseError` from the given cause.
87
+ */
88
+ static from(cause: any): RetryableError;
89
+ }
73
90
  /**
74
91
  * Returns true if the error indicates the current attempt is ending without
75
92
  * a failure — e.g. the runtime suspended the invocation (waiting for
@@ -81,5 +98,5 @@ declare class RetryableError extends RestateError {
81
98
  */
82
99
  declare function isSuspendedError(e: unknown): boolean;
83
100
  //#endregion
84
- export { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError, isSuspendedError };
101
+ export { CancelledError, PauseError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError, isSuspendedError };
85
102
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/types/errors.ts"],"sourcesContent":[],"mappings":";;;;AAwHa,cA3CA,YAAA,SAAqB,KAAA,CA2Ca;EAWlC,SAAA,IAAA,EAAA,MAAe;EAQX,IAAA,EAAA,MAAA;EAaJ,WAAA,CAAA,OAAe,EAAA,MAAA,EAAA,OAuBQ,CAvBR,EAAA;IAGJ,SAAA,CAAA,EAAA,MAAA;IAIV,KAAA,CAAA,EAAA,GAAA;EAgBsB,CAAA;;;;AAmBpC;;;cAtGa,aAAA,SAAsB,YAAA;;sBAEN;;;;;;;;;;;;eAeZ;;;;;;cAWJ,YAAA,SAAqB,aAAA;;;;;;;cAWrB,cAAA,SAAuB,aAAA;;;;UAQnB,qBAAA;;;;eAIF;;;;;;;;cASF,cAAA,SAAuB,YAAA;;wBAGZ;yCAIV;;;;;;;oCAgBsB,wBAAwB;;;;;;;;;;;iBAmB5C,gBAAA"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/types/errors.ts"],"sourcesContent":[],"mappings":";;;;AAwHa,cA3CA,YAAA,SAAqB,KAAA,CA2Ca;EAWlC,SAAA,IAAA,EAAA,MAAe;EAQX,IAAA,EAAA,MAAA;EAaJ,WAAA,CAAA,OAAe,EAAA,MAAA,EAAA,OAuBQ,CAvBR,EAAA;IAGJ,SAAA,CAAA,EAAA,MAAA;IAIV,KAAA,CAAA,EAAA,GAAA;EAgBsB,CAAA;;;;AAgBpC;AAsCA;;cAzIa,aAAA,SAAsB,YAAA;;sBAEN;;;;;;;;;;;;eAeZ;;;;;;cAWJ,YAAA,SAAqB,aAAA;;;;;;;cAWrB,cAAA,SAAuB,aAAA;;;;UAQnB,qBAAA;;;;eAIF;;;;;;;;cASF,cAAA,SAAuB,YAAA;;wBAGZ;yCAIV;;;;;;;oCAgBsB,wBAAwB;;;;;;;;cAgB/C,UAAA,SAAmB,YAAA;;;;;;;;;2BAoBL;;;;;;;;;;;iBAkBX,gBAAA"}
@@ -99,6 +99,31 @@ var RetryableError = class RetryableError extends RestateError {
99
99
  }
100
100
  };
101
101
  /**
102
+ * When thrown, Restate will pause the execution of the current invocation.
103
+ * This error type MUST be used only within a `ctx.run` closure. If thrown outside a `ctx.run` closure, pause will be ignored.
104
+ *
105
+ * You can wrap another error using {@link from}.
106
+ */
107
+ var PauseError = class extends RestateError {
108
+ name = "PauseError";
109
+ constructor(message, options) {
110
+ super(message, {
111
+ errorCode: options?.errorCode,
112
+ cause: options?.cause
113
+ });
114
+ }
115
+ /**
116
+ * Create a `PauseError` from the given cause.
117
+ */
118
+ static from(cause) {
119
+ const error = ensureError(cause);
120
+ return new RetryableError(error.message, {
121
+ errorCode: error["errorCode"],
122
+ cause
123
+ });
124
+ }
125
+ };
126
+ /**
102
127
  * Returns true if the error indicates the current attempt is ending without
103
128
  * a failure — e.g. the runtime suspended the invocation (waiting for
104
129
  * `ctx.sleep()` or `ctx.call()`), or the connection was dropped (kill).
@@ -112,5 +137,5 @@ function isSuspendedError(e) {
112
137
  }
113
138
 
114
139
  //#endregion
115
- export { CancelledError, INTERNAL_ERROR_CODE, RestateError, RetryableError, TerminalError, TimeoutError, UNKNOWN_ERROR_CODE, ensureError, isSuspendedError, logError };
140
+ export { CancelledError, INTERNAL_ERROR_CODE, PauseError, RestateError, RetryableError, TerminalError, TimeoutError, UNKNOWN_ERROR_CODE, ensureError, isSuspendedError, logError };
116
141
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../../src/types/errors.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH\n *\n * This file is part of the Restate SDK for Node.js/TypeScript,\n * which is released under the MIT license.\n *\n * You can find a copy of the license in file LICENSE in the root\n * directory of this repository or package, or at\n * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Duration } from \"@restatedev/restate-sdk-core\";\n\nexport const INTERNAL_ERROR_CODE = 500;\nexport const TIMEOUT_ERROR_CODE = 408;\nexport const CANCEL_ERROR_CODE = 409;\nexport const UNKNOWN_ERROR_CODE = 500;\n\n// From shared core!\nexport const CLOSED_ERROR_CODE = 598;\nexport const SUSPENDED_ERROR_CODE = 599;\n\nexport function ensureError(\n e: unknown,\n asTerminalError?: (error: any) => TerminalError | undefined\n): Error {\n if (e instanceof TerminalError) {\n return e;\n }\n // Try convert to terminal error\n const maybeTerminalError = asTerminalError ? asTerminalError(e) : undefined;\n if (maybeTerminalError) {\n return maybeTerminalError;\n }\n\n if (e instanceof Error) {\n return e;\n }\n if (typeof e === \"object\" && e !== null && \"code\" in e && \"message\" in e) {\n // This is an error from the VM\n return new RestateError(e.message as string, {\n errorCode: e.code as number,\n });\n }\n\n // None of the types we know\n let msg;\n try {\n msg = JSON.stringify(e);\n } catch {\n msg = \"(no JSON representation)\";\n }\n\n return new Error(\"Non-Error value: \" + msg);\n}\n\nexport function logError(log: Console, e: unknown) {\n if (e instanceof RestateError) {\n if (e.code === SUSPENDED_ERROR_CODE) {\n log.info(\"Invocation suspended\");\n return;\n } else if (e.code === CLOSED_ERROR_CODE) {\n log.error(\n \"DANGER! The invocation is closed, but some related operation is still running. \\n\" +\n \"This might indicate that a RestatePromise is being awaited on an asynchronous task, outside the handler, or you're awaiting a RestatePromise inside a ctx.run.\\n\" +\n \"This is dangerous, and can lead the service to deadlock. Please fix the issue.\\n\" +\n \"Diagnostic: \",\n e\n );\n return;\n }\n }\n log.warn(\"Error when processing a Restate context operation.\\n\", e);\n}\n\nexport class RestateError extends Error {\n public readonly code: number;\n public override name = \"RestateError\";\n\n constructor(message: string, options?: { errorCode?: number; cause?: any }) {\n super(message, { cause: options?.cause });\n this.code = options?.errorCode ?? INTERNAL_ERROR_CODE;\n }\n}\n\n/**\n * Does not lead to Restate retries.\n *\n * Leads to an output message with a failure defined.\n */\nexport class TerminalError extends RestateError {\n public override name = \"TerminalError\";\n public readonly metadata?: Record<string, string>;\n\n constructor(\n message: string,\n options?: {\n /**\n * Error code. This should be an HTTP status code, and in case the service was invoked from the ingress, this will be propagated back to the caller.\n */\n errorCode?: number;\n /**\n * Metadata key-value pairs to attach to the terminal error.\n * These will be recorded together with error message and code.\n *\n * **Note **: requires Restate 1.6+.\n */\n metadata?: Record<string, string>;\n }\n ) {\n super(message, options);\n this.metadata = options?.metadata ?? {};\n }\n}\n\n/**\n * Returned by `RestatePromise.withTimeout` when the timeout is reached.\n */\nexport class TimeoutError extends TerminalError {\n public override name = \"TimeoutError\";\n\n constructor() {\n super(\"Timeout occurred\", { errorCode: TIMEOUT_ERROR_CODE });\n }\n}\n\n/**\n * Returned when the invocation was cancelled.\n */\nexport class CancelledError extends TerminalError {\n public override name = \"CancelledError\";\n\n constructor() {\n super(\"Cancelled\", { errorCode: CANCEL_ERROR_CODE });\n }\n}\n\nexport interface RetryableErrorOptions {\n /**\n * In how long it should retry.\n */\n retryAfter?: Duration | number;\n}\n\n/**\n * Error that Restate will retry. By using this error type within a `ctx.run` closure,\n * you can dynamically provide the retry delay specified in {@link RetryableErrorOptions}.\n *\n * You can wrap another error using {@link from}.\n */\nexport class RetryableError extends RestateError {\n public override name = \"RetryableError\";\n\n readonly retryAfter?: Duration | number;\n\n constructor(\n message: string,\n options?: RetryableErrorOptions & {\n errorCode?: number;\n cause?: any;\n }\n ) {\n super(message, {\n errorCode: options?.errorCode,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n cause: options?.cause,\n });\n this.retryAfter = options?.retryAfter;\n }\n\n /**\n * Create a `RetryableError` from the given cause.\n */\n static from(cause: any, options?: RetryableErrorOptions): RetryableError {\n const error = ensureError(cause);\n return new RetryableError(error.message, {\n errorCode: error[\"errorCode\" as keyof typeof error] as number,\n cause: cause,\n ...options,\n });\n }\n}\n\n/**\n * Returns true if the error indicates the current attempt is ending without\n * a failure — e.g. the runtime suspended the invocation (waiting for\n * `ctx.sleep()` or `ctx.call()`), or the connection was dropped (kill).\n *\n * Use this in handler interceptor catch blocks to distinguish attempt-ending\n * signals from real errors (e.g. to avoid logging it as a failure or to set\n * a neutral span status).\n */\nexport function isSuspendedError(e: unknown): boolean {\n return e instanceof RestateError && e.code === SUSPENDED_ERROR_CODE;\n}\n"],"mappings":";AAeA,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAGlC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AAEpC,SAAgB,YACd,GACA,iBACO;AACP,KAAI,aAAa,cACf,QAAO;CAGT,MAAM,qBAAqB,kBAAkB,gBAAgB,EAAE,GAAG;AAClE,KAAI,mBACF,QAAO;AAGT,KAAI,aAAa,MACf,QAAO;AAET,KAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,UAAU,KAAK,aAAa,EAErE,QAAO,IAAI,aAAa,EAAE,SAAmB,EAC3C,WAAW,EAAE,MACd,CAAC;CAIJ,IAAI;AACJ,KAAI;AACF,QAAM,KAAK,UAAU,EAAE;SACjB;AACN,QAAM;;AAGR,wBAAO,IAAI,MAAM,sBAAsB,IAAI;;AAG7C,SAAgB,SAAS,KAAc,GAAY;AACjD,KAAI,aAAa,cACf;MAAI,EAAE,SAAS,sBAAsB;AACnC,OAAI,KAAK,uBAAuB;AAChC;aACS,EAAE,SAAS,mBAAmB;AACvC,OAAI,MACF,iVAIA,EACD;AACD;;;AAGJ,KAAI,KAAK,wDAAwD,EAAE;;AAGrE,IAAa,eAAb,cAAkC,MAAM;CACtC,AAAgB;CAChB,AAAgB,OAAO;CAEvB,YAAY,SAAiB,SAA+C;AAC1E,QAAM,SAAS,EAAE,OAAO,SAAS,OAAO,CAAC;AACzC,OAAK,OAAO,SAAS,aAAa;;;;;;;;AAStC,IAAa,gBAAb,cAAmC,aAAa;CAC9C,AAAgB,OAAO;CACvB,AAAgB;CAEhB,YACE,SACA,SAaA;AACA,QAAM,SAAS,QAAQ;AACvB,OAAK,WAAW,SAAS,YAAY,EAAE;;;;;;AAO3C,IAAa,eAAb,cAAkC,cAAc;CAC9C,AAAgB,OAAO;CAEvB,cAAc;AACZ,QAAM,oBAAoB,EAAE,WAAW,oBAAoB,CAAC;;;;;;AAOhE,IAAa,iBAAb,cAAoC,cAAc;CAChD,AAAgB,OAAO;CAEvB,cAAc;AACZ,QAAM,aAAa,EAAE,WAAW,mBAAmB,CAAC;;;;;;;;;AAiBxD,IAAa,iBAAb,MAAa,uBAAuB,aAAa;CAC/C,AAAgB,OAAO;CAEvB,AAAS;CAET,YACE,SACA,SAIA;AACA,QAAM,SAAS;GACb,WAAW,SAAS;GAEpB,OAAO,SAAS;GACjB,CAAC;AACF,OAAK,aAAa,SAAS;;;;;CAM7B,OAAO,KAAK,OAAY,SAAiD;EACvE,MAAM,QAAQ,YAAY,MAAM;AAChC,SAAO,IAAI,eAAe,MAAM,SAAS;GACvC,WAAW,MAAM;GACV;GACP,GAAG;GACJ,CAAC;;;;;;;;;;;;AAaN,SAAgB,iBAAiB,GAAqB;AACpD,QAAO,aAAa,gBAAgB,EAAE,SAAS"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/types/errors.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH\n *\n * This file is part of the Restate SDK for Node.js/TypeScript,\n * which is released under the MIT license.\n *\n * You can find a copy of the license in file LICENSE in the root\n * directory of this repository or package, or at\n * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Duration } from \"@restatedev/restate-sdk-core\";\n\nexport const INTERNAL_ERROR_CODE = 500;\nexport const TIMEOUT_ERROR_CODE = 408;\nexport const CANCEL_ERROR_CODE = 409;\nexport const UNKNOWN_ERROR_CODE = 500;\n\n// From shared core!\nexport const CLOSED_ERROR_CODE = 598;\nexport const SUSPENDED_ERROR_CODE = 599;\n\nexport function ensureError(\n e: unknown,\n asTerminalError?: (error: any) => TerminalError | undefined\n): Error {\n if (e instanceof TerminalError) {\n return e;\n }\n // Try convert to terminal error\n const maybeTerminalError = asTerminalError ? asTerminalError(e) : undefined;\n if (maybeTerminalError) {\n return maybeTerminalError;\n }\n\n if (e instanceof Error) {\n return e;\n }\n if (typeof e === \"object\" && e !== null && \"code\" in e && \"message\" in e) {\n // This is an error from the VM\n return new RestateError(e.message as string, {\n errorCode: e.code as number,\n });\n }\n\n // None of the types we know\n let msg;\n try {\n msg = JSON.stringify(e);\n } catch {\n msg = \"(no JSON representation)\";\n }\n\n return new Error(\"Non-Error value: \" + msg);\n}\n\nexport function logError(log: Console, e: unknown) {\n if (e instanceof RestateError) {\n if (e.code === SUSPENDED_ERROR_CODE) {\n log.info(\"Invocation suspended\");\n return;\n } else if (e.code === CLOSED_ERROR_CODE) {\n log.error(\n \"DANGER! The invocation is closed, but some related operation is still running. \\n\" +\n \"This might indicate that a RestatePromise is being awaited on an asynchronous task, outside the handler, or you're awaiting a RestatePromise inside a ctx.run.\\n\" +\n \"This is dangerous, and can lead the service to deadlock. Please fix the issue.\\n\" +\n \"Diagnostic: \",\n e\n );\n return;\n }\n }\n log.warn(\"Error when processing a Restate context operation.\\n\", e);\n}\n\nexport class RestateError extends Error {\n public readonly code: number;\n public override name = \"RestateError\";\n\n constructor(message: string, options?: { errorCode?: number; cause?: any }) {\n super(message, { cause: options?.cause });\n this.code = options?.errorCode ?? INTERNAL_ERROR_CODE;\n }\n}\n\n/**\n * Does not lead to Restate retries.\n *\n * Leads to an output message with a failure defined.\n */\nexport class TerminalError extends RestateError {\n public override name = \"TerminalError\";\n public readonly metadata?: Record<string, string>;\n\n constructor(\n message: string,\n options?: {\n /**\n * Error code. This should be an HTTP status code, and in case the service was invoked from the ingress, this will be propagated back to the caller.\n */\n errorCode?: number;\n /**\n * Metadata key-value pairs to attach to the terminal error.\n * These will be recorded together with error message and code.\n *\n * **Note **: requires Restate 1.6+.\n */\n metadata?: Record<string, string>;\n }\n ) {\n super(message, options);\n this.metadata = options?.metadata ?? {};\n }\n}\n\n/**\n * Returned by `RestatePromise.withTimeout` when the timeout is reached.\n */\nexport class TimeoutError extends TerminalError {\n public override name = \"TimeoutError\";\n\n constructor() {\n super(\"Timeout occurred\", { errorCode: TIMEOUT_ERROR_CODE });\n }\n}\n\n/**\n * Returned when the invocation was cancelled.\n */\nexport class CancelledError extends TerminalError {\n public override name = \"CancelledError\";\n\n constructor() {\n super(\"Cancelled\", { errorCode: CANCEL_ERROR_CODE });\n }\n}\n\nexport interface RetryableErrorOptions {\n /**\n * In how long it should retry.\n */\n retryAfter?: Duration | number;\n}\n\n/**\n * Error that Restate will retry. By using this error type within a `ctx.run` closure,\n * you can dynamically provide the retry delay specified in {@link RetryableErrorOptions}.\n *\n * You can wrap another error using {@link from}.\n */\nexport class RetryableError extends RestateError {\n public override name = \"RetryableError\";\n\n readonly retryAfter?: Duration | number;\n\n constructor(\n message: string,\n options?: RetryableErrorOptions & {\n errorCode?: number;\n cause?: any;\n }\n ) {\n super(message, {\n errorCode: options?.errorCode,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n cause: options?.cause,\n });\n this.retryAfter = options?.retryAfter;\n }\n\n /**\n * Create a `RetryableError` from the given cause.\n */\n static from(cause: any, options?: RetryableErrorOptions): RetryableError {\n const error = ensureError(cause);\n return new RetryableError(error.message, {\n errorCode: error[\"errorCode\" as keyof typeof error] as number,\n cause: cause,\n ...options,\n });\n }\n}\n\n/**\n * When thrown, Restate will pause the execution of the current invocation.\n * This error type MUST be used only within a `ctx.run` closure. If thrown outside a `ctx.run` closure, pause will be ignored.\n *\n * You can wrap another error using {@link from}.\n */\nexport class PauseError extends RestateError {\n public override name = \"PauseError\";\n\n constructor(\n message: string,\n options?: {\n errorCode?: number;\n cause?: any;\n }\n ) {\n super(message, {\n errorCode: options?.errorCode,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n cause: options?.cause,\n });\n }\n\n /**\n * Create a `PauseError` from the given cause.\n */\n static from(cause: any): RetryableError {\n const error = ensureError(cause);\n return new RetryableError(error.message, {\n errorCode: error[\"errorCode\" as keyof typeof error] as number,\n cause: cause,\n });\n }\n}\n\n/**\n * Returns true if the error indicates the current attempt is ending without\n * a failure — e.g. the runtime suspended the invocation (waiting for\n * `ctx.sleep()` or `ctx.call()`), or the connection was dropped (kill).\n *\n * Use this in handler interceptor catch blocks to distinguish attempt-ending\n * signals from real errors (e.g. to avoid logging it as a failure or to set\n * a neutral span status).\n */\nexport function isSuspendedError(e: unknown): boolean {\n return e instanceof RestateError && e.code === SUSPENDED_ERROR_CODE;\n}\n"],"mappings":";AAeA,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAGlC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AAEpC,SAAgB,YACd,GACA,iBACO;AACP,KAAI,aAAa,cACf,QAAO;CAGT,MAAM,qBAAqB,kBAAkB,gBAAgB,EAAE,GAAG;AAClE,KAAI,mBACF,QAAO;AAGT,KAAI,aAAa,MACf,QAAO;AAET,KAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,UAAU,KAAK,aAAa,EAErE,QAAO,IAAI,aAAa,EAAE,SAAmB,EAC3C,WAAW,EAAE,MACd,CAAC;CAIJ,IAAI;AACJ,KAAI;AACF,QAAM,KAAK,UAAU,EAAE;SACjB;AACN,QAAM;;AAGR,wBAAO,IAAI,MAAM,sBAAsB,IAAI;;AAG7C,SAAgB,SAAS,KAAc,GAAY;AACjD,KAAI,aAAa,cACf;MAAI,EAAE,SAAS,sBAAsB;AACnC,OAAI,KAAK,uBAAuB;AAChC;aACS,EAAE,SAAS,mBAAmB;AACvC,OAAI,MACF,iVAIA,EACD;AACD;;;AAGJ,KAAI,KAAK,wDAAwD,EAAE;;AAGrE,IAAa,eAAb,cAAkC,MAAM;CACtC,AAAgB;CAChB,AAAgB,OAAO;CAEvB,YAAY,SAAiB,SAA+C;AAC1E,QAAM,SAAS,EAAE,OAAO,SAAS,OAAO,CAAC;AACzC,OAAK,OAAO,SAAS,aAAa;;;;;;;;AAStC,IAAa,gBAAb,cAAmC,aAAa;CAC9C,AAAgB,OAAO;CACvB,AAAgB;CAEhB,YACE,SACA,SAaA;AACA,QAAM,SAAS,QAAQ;AACvB,OAAK,WAAW,SAAS,YAAY,EAAE;;;;;;AAO3C,IAAa,eAAb,cAAkC,cAAc;CAC9C,AAAgB,OAAO;CAEvB,cAAc;AACZ,QAAM,oBAAoB,EAAE,WAAW,oBAAoB,CAAC;;;;;;AAOhE,IAAa,iBAAb,cAAoC,cAAc;CAChD,AAAgB,OAAO;CAEvB,cAAc;AACZ,QAAM,aAAa,EAAE,WAAW,mBAAmB,CAAC;;;;;;;;;AAiBxD,IAAa,iBAAb,MAAa,uBAAuB,aAAa;CAC/C,AAAgB,OAAO;CAEvB,AAAS;CAET,YACE,SACA,SAIA;AACA,QAAM,SAAS;GACb,WAAW,SAAS;GAEpB,OAAO,SAAS;GACjB,CAAC;AACF,OAAK,aAAa,SAAS;;;;;CAM7B,OAAO,KAAK,OAAY,SAAiD;EACvE,MAAM,QAAQ,YAAY,MAAM;AAChC,SAAO,IAAI,eAAe,MAAM,SAAS;GACvC,WAAW,MAAM;GACV;GACP,GAAG;GACJ,CAAC;;;;;;;;;AAUN,IAAa,aAAb,cAAgC,aAAa;CAC3C,AAAgB,OAAO;CAEvB,YACE,SACA,SAIA;AACA,QAAM,SAAS;GACb,WAAW,SAAS;GAEpB,OAAO,SAAS;GACjB,CAAC;;;;;CAMJ,OAAO,KAAK,OAA4B;EACtC,MAAM,QAAQ,YAAY,MAAM;AAChC,SAAO,IAAI,eAAe,MAAM,SAAS;GACvC,WAAW,MAAM;GACV;GACR,CAAC;;;;;;;;;;;;AAaN,SAAgB,iBAAiB,GAAqB;AACpD,QAAO,aAAa,gBAAgB,EAAE,SAAS"}
@@ -0,0 +1,2 @@
1
+ export declare const X_RESTATE_SERVER: string;
2
+ //# sourceMappingURL=user_agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user_agent.d.ts","sourceRoot":"","sources":["../src/user_agent.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,gBAAgB,QAA0C,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Multi-producer single-consumer unit-signal channel used to wake the
3
+ * {@link PromisesExecutor} when any external progress source (input read or
4
+ * run-closure completion) has made progress.
5
+ *
6
+ * Producers call {@link signal} to emit a progress event.
7
+ * The single consumer calls {@link awaitNext} to await the next signal.
8
+ *
9
+ * Signals emitted with no consumer waiting are buffered, so no progress signal
10
+ * is ever lost. At most one {@link awaitNext} may be pending at a time; a
11
+ * concurrent second call rejects.
12
+ */
13
+ export declare class ExternalProgressChannel {
14
+ private pending;
15
+ private waiter;
16
+ signal(): void;
17
+ awaitNext(): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=external_progress_channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external_progress_channel.d.ts","sourceRoot":"","sources":["../../src/utils/external_progress_channel.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,MAAM,CAA2B;IAEzC,MAAM,IAAI,IAAI;IAUd,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAY3B"}
@@ -0,0 +1,13 @@
1
+ import type { Rand } from "../context.js";
2
+ export declare class RandImpl implements Rand {
3
+ private readonly checkState;
4
+ private randstate256;
5
+ constructor(id: bigint | [bigint, bigint, bigint, bigint], checkState?: (state: string) => void);
6
+ static U64_MASK: bigint;
7
+ u64(): bigint;
8
+ static rotl(x: bigint, k: bigint): bigint;
9
+ static U53_MASK: bigint;
10
+ random(): number;
11
+ uuidv4(): string;
12
+ }
13
+ //# sourceMappingURL=rand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rand.d.ts","sourceRoot":"","sources":["../../src/utils/rand.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C,qBAAa,QAAS,YAAW,IAAI;IAKjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,YAAY,CAAmC;gBAGrD,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAC5B,UAAU,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAsB;IAqBxE,MAAM,CAAC,QAAQ,SAAoB;IAInC,GAAG,IAAI,MAAM;IAuBb,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIzC,MAAM,CAAC,QAAQ,SAAoB;IAE5B,MAAM,IAAI,MAAM;IAShB,MAAM,IAAI,MAAM;CAWxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/restate-sdk-cloudflare-workers",
3
- "version": "1.15.0-rc.0",
3
+ "version": "1.15.0-rc.2",
4
4
  "description": "Typescript SDK for Restate",
5
5
  "author": "Restate Developers",
6
6
  "email": "code@restate.dev",
@@ -35,11 +35,11 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@restatedev/restate-sdk-core": "1.15.0-rc.0"
38
+ "@restatedev/restate-sdk-core": "1.15.0-rc.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/aws-lambda": "^8.10.115",
42
- "@restatedev/restate-sdk": "1.15.0-rc.0"
42
+ "@restatedev/restate-sdk": "1.15.0-rc.2"
43
43
  },
44
44
  "typesVersions": {
45
45
  "*": {