@restatedev/restate-sdk 1.11.1 → 1.12.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.
- package/dist/_virtual/rolldown_runtime.cjs +9 -0
- package/dist/common_api.cjs +2 -1
- package/dist/common_api.d.cts +6 -2
- package/dist/common_api.d.cts.map +1 -1
- package/dist/common_api.d.ts +6 -2
- package/dist/common_api.d.ts.map +1 -1
- package/dist/common_api.js +2 -1
- package/dist/common_api.js.map +1 -1
- package/dist/context.cjs +13 -9
- package/dist/context.d.cts +36 -29
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.ts +36 -29
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +13 -9
- package/dist/context.js.map +1 -1
- package/dist/context_impl.cjs +150 -91
- package/dist/context_impl.d.cts +8 -0
- package/dist/context_impl.d.ts +8 -72
- package/dist/context_impl.d.ts.map +1 -1
- package/dist/context_impl.js +151 -93
- package/dist/context_impl.js.map +1 -1
- package/dist/endpoint/components.cjs +35 -20
- package/dist/endpoint/components.d.cts +5 -0
- package/dist/endpoint/components.d.ts +5 -97
- package/dist/endpoint/components.d.ts.map +1 -1
- package/dist/endpoint/components.js +35 -20
- package/dist/endpoint/components.js.map +1 -1
- package/dist/endpoint/endpoint.cjs +2 -2
- package/dist/endpoint/endpoint.d.cts +5 -0
- package/dist/endpoint/endpoint.d.ts +5 -39
- package/dist/endpoint/endpoint.js +2 -2
- package/dist/endpoint/endpoint.js.map +1 -1
- package/dist/endpoint/handlers/generic.cjs +115 -39
- package/dist/endpoint/handlers/generic.d.ts.map +1 -1
- package/dist/endpoint/handlers/generic.js +115 -39
- package/dist/endpoint/handlers/generic.js.map +1 -1
- package/dist/endpoint/handlers/types.d.cts +1 -0
- package/dist/endpoint/handlers/types.d.ts +1 -41
- package/dist/endpoint/handlers/utils.cjs +1 -1
- package/dist/endpoint/handlers/utils.js +1 -1
- package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.cjs +43 -3
- package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts +19 -1
- package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts.map +1 -1
- package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js +43 -3
- package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js.map +1 -1
- package/dist/endpoint/node_endpoint.cjs +28 -12
- package/dist/endpoint/node_endpoint.d.ts +14 -2
- package/dist/endpoint/node_endpoint.d.ts.map +1 -1
- package/dist/endpoint/node_endpoint.js +27 -11
- package/dist/endpoint/node_endpoint.js.map +1 -1
- package/dist/endpoint/types.d.cts +1 -1
- package/dist/endpoint/types.d.ts +1 -1
- package/dist/endpoint.d.cts +87 -5
- package/dist/endpoint.d.cts.map +1 -1
- package/dist/endpoint.d.ts +87 -5
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/error_sanitization.cjs +26 -0
- package/dist/error_sanitization.d.ts +13 -0
- package/dist/error_sanitization.d.ts.map +1 -0
- package/dist/error_sanitization.js +26 -0
- package/dist/error_sanitization.js.map +1 -0
- package/dist/fetch.cjs +3 -1
- package/dist/fetch.d.cts +5 -3
- package/dist/fetch.d.cts.map +1 -1
- package/dist/fetch.d.ts +5 -3
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +3 -2
- package/dist/fetch.js.map +1 -1
- package/dist/hooks.d.cts +87 -0
- package/dist/hooks.d.cts.map +1 -0
- package/dist/hooks.d.ts +87 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +3 -2
- package/dist/internal.cjs +3 -1
- package/dist/internal.d.cts +186 -2
- package/dist/internal.d.cts.map +1 -1
- package/dist/internal.d.ts +186 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -1
- package/dist/internal.js.map +1 -1
- package/dist/io.d.cts +1 -0
- package/dist/io.d.ts +1 -24
- package/dist/lambda.cjs +3 -1
- package/dist/lambda.d.cts +5 -3
- package/dist/lambda.d.cts.map +1 -1
- package/dist/lambda.d.ts +5 -3
- package/dist/lambda.d.ts.map +1 -1
- package/dist/lambda.js +3 -2
- package/dist/lambda.js.map +1 -1
- package/dist/logging/logger.d.cts +1 -0
- package/dist/logging/logger.d.ts +1 -10
- package/dist/node.cjs +23 -6
- package/dist/node.d.cts +46 -8
- package/dist/node.d.cts.map +1 -1
- package/dist/node.d.ts +46 -8
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +23 -7
- package/dist/node.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/promises.cjs +90 -53
- package/dist/promises.d.cts +18 -0
- package/dist/promises.d.cts.map +1 -0
- package/dist/promises.d.ts +15 -108
- package/dist/promises.d.ts.map +1 -1
- package/dist/promises.js +85 -48
- package/dist/promises.js.map +1 -1
- package/dist/types/errors.cjs +13 -0
- package/dist/types/errors.d.cts +11 -5
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +11 -5
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +13 -1
- package/dist/types/errors.js.map +1 -1
- package/dist/types/rpc.cjs +7 -19
- package/dist/types/rpc.d.cts +174 -0
- package/dist/types/rpc.d.cts.map +1 -1
- package/dist/types/rpc.d.ts +174 -0
- package/dist/types/rpc.d.ts.map +1 -1
- package/dist/types/rpc.js +7 -19
- package/dist/types/rpc.js.map +1 -1
- package/package.json +2 -2
package/dist/node.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
|
|
2
|
+
import { Hooks, HooksProvider, Interceptor } from "./hooks.js";
|
|
2
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";
|
|
3
|
-
import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions,
|
|
4
|
+
import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.js";
|
|
5
|
+
import { internal_d_exports } from "./internal.js";
|
|
4
6
|
import { LogMetadata, LogSource, LoggerContext, LoggerTransport, RestateLogLevel } from "./logging/logger_transport.js";
|
|
5
7
|
import { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase } from "./endpoint.js";
|
|
8
|
+
import { isRestatePromise } from "./promises.js";
|
|
6
9
|
import { EndpointOptions } from "./endpoint/types.js";
|
|
7
|
-
import { internal_d_exports } from "./internal.js";
|
|
8
10
|
import { CombineablePromise, Duration, JournalValueCodec, ObjectHandler, RestateContext, RestateObjectContext, RestateObjectSharedContext, RestateWorkflowContext, RestateWorkflowSharedContext, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowSharedHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, serde } from "./common_api.js";
|
|
11
|
+
import * as http0 from "http";
|
|
9
12
|
import * as http20 from "http2";
|
|
10
13
|
|
|
11
14
|
//#region src/node.d.ts
|
|
@@ -15,17 +18,52 @@ import * as http20 from "http2";
|
|
|
15
18
|
*/
|
|
16
19
|
declare function endpoint(): RestateEndpoint;
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* Options for creating a Node.js endpoint handler.
|
|
22
|
+
*
|
|
23
|
+
* Extends {@link EndpointOptions} with Node.js-specific options for controlling
|
|
24
|
+
* the protocol mode.
|
|
25
|
+
*/
|
|
26
|
+
interface NodeEndpointOptions extends EndpointOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Controls the protocol mode used by the handler.
|
|
29
|
+
*
|
|
30
|
+
* - `undefined` (default): auto-detect based on HTTP version.
|
|
31
|
+
* HTTP/2+ uses bidirectional streaming (`BIDI_STREAM`),
|
|
32
|
+
* HTTP/1.1 uses request-response mode (`REQUEST_RESPONSE`).
|
|
33
|
+
* - `true`: force `BIDI_STREAM` for all requests.
|
|
34
|
+
* - `false`: force `REQUEST_RESPONSE` for all requests.
|
|
35
|
+
*/
|
|
36
|
+
bidirectional?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a request handler for the provided services.
|
|
40
|
+
*
|
|
41
|
+
* The returned handler auto-detects the HTTP protocol version per request:
|
|
42
|
+
* - HTTP/2+ requests use bidirectional streaming (`BIDI_STREAM`)
|
|
43
|
+
* - HTTP/1.1 requests use request-response mode (`REQUEST_RESPONSE`) by default
|
|
19
44
|
*
|
|
20
|
-
*
|
|
45
|
+
* Set `bidirectional: true` to force `BIDI_STREAM` for all requests, or
|
|
46
|
+
* `bidirectional: false` to force `REQUEST_RESPONSE` for all requests.
|
|
47
|
+
*
|
|
48
|
+
* @example HTTP/2 server
|
|
21
49
|
* ```
|
|
22
50
|
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
|
|
23
51
|
* httpServer.listen(port);
|
|
24
52
|
* ```
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
53
|
+
*
|
|
54
|
+
* @example HTTP/1.1 server
|
|
55
|
+
* ```
|
|
56
|
+
* const httpServer = http.createServer(createEndpointHandler({ services: [myService] }));
|
|
57
|
+
* httpServer.listen(port);
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @param {NodeEndpointOptions} options - Configuration options for the endpoint handler.
|
|
61
|
+
* @returns A request handler function compatible with both HTTP/1.1 and HTTP/2 servers.
|
|
27
62
|
*/
|
|
28
|
-
declare function createEndpointHandler(options:
|
|
63
|
+
declare function createEndpointHandler(options: NodeEndpointOptions): {
|
|
64
|
+
(request: http0.IncomingMessage, response: http0.ServerResponse): void;
|
|
65
|
+
(request: http20.Http2ServerRequest, response: http20.Http2ServerResponse): void;
|
|
66
|
+
};
|
|
29
67
|
interface ServeOptions extends EndpointOptions {
|
|
30
68
|
port?: number;
|
|
31
69
|
}
|
|
@@ -48,5 +86,5 @@ declare function serve({
|
|
|
48
86
|
...options
|
|
49
87
|
}: ServeOptions): Promise<number>;
|
|
50
88
|
//#endregion
|
|
51
|
-
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, InferArg, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, JournalValueCodec, KeyValueStore, 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,
|
|
89
|
+
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, 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, 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 };
|
|
52
90
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","names":[],"sources":["../src/node.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","names":[],"sources":["../src/node.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;iBAqBgB,QAAA,CAAA,GAAY;;;;;;;AAAZ,UAUC,mBAAA,SAA4B,eAVF,CAAA;EAU1B;AAsCjB;;;;;;;AAQA;EAkBgB,aAAK,CAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA1BL,qBAAA,UAA+B;YAAmB,KAAA,CAAA;;;UAQjD,YAAA,SAAqB;;;;;;;;;;;;;;;;;iBAkBtB,KAAA;;;GAA4B,eAAY"}
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CancelledError, RestateError, RetryableError, TerminalError, TimeoutError } from "./types/errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isRestatePromise } from "./promises.js";
|
|
3
3
|
import { InvocationIdParser, RestatePromise } from "./context.js";
|
|
4
|
+
import { Opts, SendOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
|
|
4
5
|
import { internal_exports } from "./internal.js";
|
|
5
6
|
import { CombineablePromise, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, serde } from "./common_api.js";
|
|
6
7
|
import { withOptions } from "./endpoint/withOptions.js";
|
|
@@ -15,18 +16,33 @@ function endpoint() {
|
|
|
15
16
|
return new NodeEndpoint();
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
* Creates
|
|
19
|
+
* Creates a request handler for the provided services.
|
|
20
|
+
*
|
|
21
|
+
* The returned handler auto-detects the HTTP protocol version per request:
|
|
22
|
+
* - HTTP/2+ requests use bidirectional streaming (`BIDI_STREAM`)
|
|
23
|
+
* - HTTP/1.1 requests use request-response mode (`REQUEST_RESPONSE`) by default
|
|
19
24
|
*
|
|
20
|
-
*
|
|
25
|
+
* Set `bidirectional: true` to force `BIDI_STREAM` for all requests, or
|
|
26
|
+
* `bidirectional: false` to force `REQUEST_RESPONSE` for all requests.
|
|
27
|
+
*
|
|
28
|
+
* @example HTTP/2 server
|
|
21
29
|
* ```
|
|
22
30
|
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
|
|
23
31
|
* httpServer.listen(port);
|
|
24
32
|
* ```
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
33
|
+
*
|
|
34
|
+
* @example HTTP/1.1 server
|
|
35
|
+
* ```
|
|
36
|
+
* const httpServer = http.createServer(createEndpointHandler({ services: [myService] }));
|
|
37
|
+
* httpServer.listen(port);
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param {NodeEndpointOptions} options - Configuration options for the endpoint handler.
|
|
41
|
+
* @returns A request handler function compatible with both HTTP/1.1 and HTTP/2 servers.
|
|
27
42
|
*/
|
|
28
43
|
function createEndpointHandler(options) {
|
|
29
|
-
|
|
44
|
+
const { bidirectional,...endpointOptions } = options;
|
|
45
|
+
return withOptions(new NodeEndpoint(), endpointOptions).handler({ bidirectional });
|
|
30
46
|
}
|
|
31
47
|
/**
|
|
32
48
|
* Serves this Restate services as HTTP2 server, listening to the given port.
|
|
@@ -47,5 +63,5 @@ function serve({ port,...options }) {
|
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
//#endregion
|
|
50
|
-
export { CancelledError, CombineablePromise, InvocationIdParser, Opts, RestateError, RestatePromise, RetryableError, SendOpts, TerminalError, TimeoutError, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_exports as internal, object, rpc, serde, serve, service, workflow };
|
|
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 };
|
|
51
67
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":[],"sources":["../src/node.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\nexport * from \"./common_api.js\";\nimport type { RestateEndpoint } from \"./endpoint.js\";\nimport { NodeEndpoint } from \"./endpoint/node_endpoint.js\";\nimport type { EndpointOptions } from \"./endpoint/types.js\";\nimport { withOptions } from \"./endpoint/withOptions.js\";\n\n/**\n * Create a new {@link RestateEndpoint}.\n * @deprecated Please use {@link createEndpointHandler}\n */\nexport function endpoint(): RestateEndpoint {\n return new NodeEndpoint();\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../src/node.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\nexport * from \"./common_api.js\";\nimport type { RestateEndpoint } from \"./endpoint.js\";\nimport { NodeEndpoint } from \"./endpoint/node_endpoint.js\";\nimport type { EndpointOptions } from \"./endpoint/types.js\";\nimport { withOptions } from \"./endpoint/withOptions.js\";\n\n/**\n * Create a new {@link RestateEndpoint}.\n * @deprecated Please use {@link createEndpointHandler}\n */\nexport function endpoint(): RestateEndpoint {\n return new NodeEndpoint();\n}\n\n/**\n * Options for creating a Node.js endpoint handler.\n *\n * Extends {@link EndpointOptions} with Node.js-specific options for controlling\n * the protocol mode.\n */\nexport interface NodeEndpointOptions extends EndpointOptions {\n /**\n * Controls the protocol mode used by the handler.\n *\n * - `undefined` (default): auto-detect based on HTTP version.\n * HTTP/2+ uses bidirectional streaming (`BIDI_STREAM`),\n * HTTP/1.1 uses request-response mode (`REQUEST_RESPONSE`).\n * - `true`: force `BIDI_STREAM` for all requests.\n * - `false`: force `REQUEST_RESPONSE` for all requests.\n */\n bidirectional?: boolean;\n}\n\n/**\n * Creates a request handler for the provided services.\n *\n * The returned handler auto-detects the HTTP protocol version per request:\n * - HTTP/2+ requests use bidirectional streaming (`BIDI_STREAM`)\n * - HTTP/1.1 requests use request-response mode (`REQUEST_RESPONSE`) by default\n *\n * Set `bidirectional: true` to force `BIDI_STREAM` for all requests, or\n * `bidirectional: false` to force `REQUEST_RESPONSE` for all requests.\n *\n * @example HTTP/2 server\n * ```\n * const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));\n * httpServer.listen(port);\n * ```\n *\n * @example HTTP/1.1 server\n * ```\n * const httpServer = http.createServer(createEndpointHandler({ services: [myService] }));\n * httpServer.listen(port);\n * ```\n *\n * @param {NodeEndpointOptions} options - Configuration options for the endpoint handler.\n * @returns A request handler function compatible with both HTTP/1.1 and HTTP/2 servers.\n */\nexport function createEndpointHandler(options: NodeEndpointOptions) {\n const { bidirectional, ...endpointOptions } = options;\n return withOptions<RestateEndpoint>(\n new NodeEndpoint(),\n endpointOptions\n ).handler({ bidirectional });\n}\n\nexport interface ServeOptions extends EndpointOptions {\n port?: number;\n}\n\n/**\n * Serves this Restate services as HTTP2 server, listening to the given port.\n *\n * If the port is undefined, this method will use the port set in the `PORT`\n * environment variable. If that variable is undefined as well, the method will\n * default to port 9080.\n *\n * The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.\n *\n * If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link createEndpointHandler}.\n *\n * @param {ServeOptions} options - Configuration options for the endpoint handler.\n * @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.\n */\nexport function serve({ port, ...options }: ServeOptions) {\n return withOptions<RestateEndpoint>(new NodeEndpoint(), options).listen(port);\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,WAA4B;AAC1C,QAAO,IAAI,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+C3B,SAAgB,sBAAsB,SAA8B;CAClE,MAAM,EAAE,cAAe,GAAG,oBAAoB;AAC9C,QAAO,YACL,IAAI,cAAc,EAClB,gBACD,CAAC,QAAQ,EAAE,eAAe,CAAC;;;;;;;;;;;;;;;;AAqB9B,SAAgB,MAAM,EAAE,KAAM,GAAG,WAAyB;AACxD,QAAO,YAA6B,IAAI,cAAc,EAAE,QAAQ,CAAC,OAAO,KAAK"}
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
package/dist/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@restatedev/restate-sdk\",\n \"version\": \"1.
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@restatedev/restate-sdk\",\n \"version\": \"1.12.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"}
|
package/dist/promises.cjs
CHANGED
|
@@ -8,20 +8,31 @@ node_timers_promises = require_rolldown_runtime.__toESM(node_timers_promises);
|
|
|
8
8
|
function pendingPromise() {
|
|
9
9
|
return new Promise(() => {});
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns `true` if the given value is a {@link RestatePromise}.
|
|
13
|
+
*
|
|
14
|
+
* Use this for runtime type detection when you need to distinguish Restate promises
|
|
15
|
+
* from regular promises, e.g. for overload resolution.
|
|
16
|
+
*/
|
|
17
|
+
function isRestatePromise(p) {
|
|
18
|
+
return p instanceof InternalRestatePromise;
|
|
19
|
+
}
|
|
11
20
|
var PromiseState = /* @__PURE__ */ function(PromiseState$1) {
|
|
12
21
|
PromiseState$1[PromiseState$1["COMPLETED"] = 0] = "COMPLETED";
|
|
13
22
|
PromiseState$1[PromiseState$1["NOT_COMPLETED"] = 1] = "NOT_COMPLETED";
|
|
14
23
|
return PromiseState$1;
|
|
15
24
|
}(PromiseState || {});
|
|
25
|
+
var InternalRestatePromise = class {};
|
|
16
26
|
const RESTATE_CTX_SYMBOL = Symbol("restateContext");
|
|
17
27
|
function extractContext(n) {
|
|
18
28
|
return n[RESTATE_CTX_SYMBOL];
|
|
19
29
|
}
|
|
20
|
-
var
|
|
30
|
+
var BaseRestatePromise = class extends InternalRestatePromise {
|
|
21
31
|
[RESTATE_CTX_SYMBOL];
|
|
22
32
|
pollingPromise;
|
|
23
33
|
cancelPromise = new require_completable_promise.CompletablePromise();
|
|
24
34
|
constructor(ctx) {
|
|
35
|
+
super();
|
|
25
36
|
this[RESTATE_CTX_SYMBOL] = ctx;
|
|
26
37
|
}
|
|
27
38
|
then(onfulfilled, onrejected) {
|
|
@@ -40,7 +51,7 @@ var AbstractRestatePromise = class {
|
|
|
40
51
|
return Promise.race([this.cancelPromise.promise, this.publicPromise()]);
|
|
41
52
|
}
|
|
42
53
|
orTimeout(duration) {
|
|
43
|
-
return new
|
|
54
|
+
return new CombinatorRestatePromise(this[RESTATE_CTX_SYMBOL], ([thisPromise, sleepPromise]) => {
|
|
44
55
|
return new Promise((resolve, reject) => {
|
|
45
56
|
thisPromise.then(resolve, reject);
|
|
46
57
|
sleepPromise.then(() => {
|
|
@@ -50,13 +61,13 @@ var AbstractRestatePromise = class {
|
|
|
50
61
|
}, [this, this[RESTATE_CTX_SYMBOL].sleep(duration)]);
|
|
51
62
|
}
|
|
52
63
|
map(mapper) {
|
|
53
|
-
return new
|
|
64
|
+
return new MappedRestatePromise(this[RESTATE_CTX_SYMBOL], this, mapper);
|
|
54
65
|
}
|
|
55
66
|
tryCancel() {
|
|
56
67
|
this.cancelPromise.reject(new require_errors.CancelledError());
|
|
57
68
|
}
|
|
58
69
|
};
|
|
59
|
-
var
|
|
70
|
+
var SingleRestatePromise = class extends BaseRestatePromise {
|
|
60
71
|
state = PromiseState.NOT_COMPLETED;
|
|
61
72
|
completablePromise = new require_completable_promise.CompletablePromise();
|
|
62
73
|
constructor(ctx, handle, completer) {
|
|
@@ -77,9 +88,12 @@ var RestateSinglePromise = class extends AbstractRestatePromise {
|
|
|
77
88
|
publicPromise() {
|
|
78
89
|
return this.completablePromise.promise;
|
|
79
90
|
}
|
|
91
|
+
isCompleted() {
|
|
92
|
+
return this.state === PromiseState.COMPLETED;
|
|
93
|
+
}
|
|
80
94
|
[Symbol.toStringTag] = "RestateSinglePromise";
|
|
81
95
|
};
|
|
82
|
-
var
|
|
96
|
+
var InvocationRestatePromise = class extends SingleRestatePromise {
|
|
83
97
|
constructor(ctx, handle, completer, invocationIdPromise) {
|
|
84
98
|
super(ctx, handle, completer);
|
|
85
99
|
this.invocationIdPromise = invocationIdPromise;
|
|
@@ -88,7 +102,7 @@ var RestateInvocationPromise = class extends RestateSinglePromise {
|
|
|
88
102
|
return this.invocationIdPromise;
|
|
89
103
|
}
|
|
90
104
|
};
|
|
91
|
-
var
|
|
105
|
+
var CombinatorRestatePromise = class CombinatorRestatePromise extends BaseRestatePromise {
|
|
92
106
|
state = PromiseState.NOT_COMPLETED;
|
|
93
107
|
combinatorPromise;
|
|
94
108
|
constructor(ctx, combinatorConstructor, childs) {
|
|
@@ -98,6 +112,21 @@ var RestateCombinatorPromise = class extends AbstractRestatePromise {
|
|
|
98
112
|
this.state = PromiseState.COMPLETED;
|
|
99
113
|
});
|
|
100
114
|
}
|
|
115
|
+
static fromPromises(combinatorConstructor, promises) {
|
|
116
|
+
const castedPromises = [];
|
|
117
|
+
let foundContext = void 0;
|
|
118
|
+
for (const [idx, promise] of promises.entries()) {
|
|
119
|
+
if (!isRestatePromise(promise)) throw new Error(`Promise index ${idx} used inside the combinator is not an instance of RestatePromise. This is not supported.`);
|
|
120
|
+
else if (foundContext === void 0) foundContext = extractContext(promise);
|
|
121
|
+
else {
|
|
122
|
+
const thisContext = extractContext(promise);
|
|
123
|
+
if (thisContext !== void 0 && thisContext !== foundContext) throw new Error("You're mixing up RestatePromises from different RestateContext. This is not supported.");
|
|
124
|
+
}
|
|
125
|
+
castedPromises.push(promise);
|
|
126
|
+
}
|
|
127
|
+
if (foundContext === void 0) return ConstRestatePromise.fromPromise(combinatorConstructor(castedPromises), true);
|
|
128
|
+
return new CombinatorRestatePromise(foundContext, combinatorConstructor, castedPromises);
|
|
129
|
+
}
|
|
101
130
|
uncompletedLeaves() {
|
|
102
131
|
return this.state === PromiseState.COMPLETED ? [] : this.childs.flatMap((p) => p.uncompletedLeaves());
|
|
103
132
|
}
|
|
@@ -109,45 +138,7 @@ var RestateCombinatorPromise = class extends AbstractRestatePromise {
|
|
|
109
138
|
}
|
|
110
139
|
[Symbol.toStringTag] = "RestateCombinatorPromise";
|
|
111
140
|
};
|
|
112
|
-
var
|
|
113
|
-
[RESTATE_CTX_SYMBOL];
|
|
114
|
-
constructor(ctx) {
|
|
115
|
-
this[RESTATE_CTX_SYMBOL] = ctx;
|
|
116
|
-
}
|
|
117
|
-
then(onfulfilled, onrejected) {
|
|
118
|
-
return pendingPromise().then(onfulfilled, onrejected);
|
|
119
|
-
}
|
|
120
|
-
catch(onrejected) {
|
|
121
|
-
return pendingPromise().catch(onrejected);
|
|
122
|
-
}
|
|
123
|
-
finally(onfinally) {
|
|
124
|
-
return pendingPromise().finally(onfinally);
|
|
125
|
-
}
|
|
126
|
-
orTimeout() {
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
map() {
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
tryCancel() {}
|
|
133
|
-
async tryComplete() {}
|
|
134
|
-
uncompletedLeaves() {
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
publicPromise() {
|
|
138
|
-
return pendingPromise();
|
|
139
|
-
}
|
|
140
|
-
[Symbol.toStringTag] = "RestatePendingPromise";
|
|
141
|
-
};
|
|
142
|
-
var InvocationPendingPromise = class extends RestatePendingPromise {
|
|
143
|
-
constructor(ctx) {
|
|
144
|
-
super(ctx);
|
|
145
|
-
}
|
|
146
|
-
get invocationId() {
|
|
147
|
-
return pendingPromise();
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var RestateMappedPromise = class extends AbstractRestatePromise {
|
|
141
|
+
var MappedRestatePromise = class extends BaseRestatePromise {
|
|
151
142
|
publicPromiseMapper;
|
|
152
143
|
constructor(ctx, inner, mapper) {
|
|
153
144
|
super(ctx);
|
|
@@ -158,7 +149,7 @@ var RestateMappedPromise = class extends AbstractRestatePromise {
|
|
|
158
149
|
} catch (e) {
|
|
159
150
|
if (e instanceof require_errors.TerminalError) return Promise.reject(e);
|
|
160
151
|
else {
|
|
161
|
-
ctx.
|
|
152
|
+
ctx.abortAttempt(e);
|
|
162
153
|
return pendingPromise();
|
|
163
154
|
}
|
|
164
155
|
}
|
|
@@ -179,6 +170,52 @@ var RestateMappedPromise = class extends AbstractRestatePromise {
|
|
|
179
170
|
}
|
|
180
171
|
[Symbol.toStringTag] = "RestateMappedPromise";
|
|
181
172
|
};
|
|
173
|
+
var ConstRestatePromise = class ConstRestatePromise extends InternalRestatePromise {
|
|
174
|
+
constructor(constPromise, settled) {
|
|
175
|
+
super();
|
|
176
|
+
this.constPromise = constPromise;
|
|
177
|
+
this.settled = settled;
|
|
178
|
+
}
|
|
179
|
+
static resolve(value) {
|
|
180
|
+
return new ConstRestatePromise(Promise.resolve(value), true);
|
|
181
|
+
}
|
|
182
|
+
static reject(reason) {
|
|
183
|
+
return new ConstRestatePromise(Promise.reject(reason), true);
|
|
184
|
+
}
|
|
185
|
+
static pending() {
|
|
186
|
+
return new ConstRestatePromise(pendingPromise(), false);
|
|
187
|
+
}
|
|
188
|
+
static fromPromise(promise, settled) {
|
|
189
|
+
return new ConstRestatePromise(promise, settled);
|
|
190
|
+
}
|
|
191
|
+
then(onfulfilled, onrejected) {
|
|
192
|
+
return this.constPromise.then(onfulfilled, onrejected);
|
|
193
|
+
}
|
|
194
|
+
catch(onrejected) {
|
|
195
|
+
return this.constPromise.catch(onrejected);
|
|
196
|
+
}
|
|
197
|
+
finally(onfinally) {
|
|
198
|
+
return this.constPromise.finally(onfinally);
|
|
199
|
+
}
|
|
200
|
+
orTimeout() {
|
|
201
|
+
if (this.settled) return this;
|
|
202
|
+
return ConstRestatePromise.reject(new require_errors.TimeoutError());
|
|
203
|
+
}
|
|
204
|
+
map(mapper) {
|
|
205
|
+
return ConstRestatePromise.fromPromise(this.constPromise.then((value) => mapper(value, void 0), (reason) => mapper(void 0, reason)), this.settled);
|
|
206
|
+
}
|
|
207
|
+
tryCancel() {}
|
|
208
|
+
publicPromise() {
|
|
209
|
+
return this.constPromise;
|
|
210
|
+
}
|
|
211
|
+
tryComplete() {
|
|
212
|
+
return Promise.resolve();
|
|
213
|
+
}
|
|
214
|
+
uncompletedLeaves() {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
[Symbol.toStringTag] = "ConstRestatePromise";
|
|
218
|
+
};
|
|
182
219
|
/**
|
|
183
220
|
* Promises executor, gluing VM with I/O and Promises given to user space.
|
|
184
221
|
*/
|
|
@@ -198,7 +235,7 @@ var PromisesExecutor = class {
|
|
|
198
235
|
try {
|
|
199
236
|
await restatePromise.tryComplete();
|
|
200
237
|
} catch (e) {
|
|
201
|
-
|
|
238
|
+
this.errorCallback(e);
|
|
202
239
|
return Promise.resolve();
|
|
203
240
|
}
|
|
204
241
|
return (0, node_timers_promises.setImmediate)().then(async () => {
|
|
@@ -224,11 +261,11 @@ var PromisesExecutor = class {
|
|
|
224
261
|
};
|
|
225
262
|
|
|
226
263
|
//#endregion
|
|
227
|
-
exports.
|
|
264
|
+
exports.CombinatorRestatePromise = CombinatorRestatePromise;
|
|
265
|
+
exports.ConstRestatePromise = ConstRestatePromise;
|
|
266
|
+
exports.InternalRestatePromise = InternalRestatePromise;
|
|
267
|
+
exports.InvocationRestatePromise = InvocationRestatePromise;
|
|
228
268
|
exports.PromisesExecutor = PromisesExecutor;
|
|
229
|
-
exports.
|
|
230
|
-
exports.
|
|
231
|
-
exports.RestatePendingPromise = RestatePendingPromise;
|
|
232
|
-
exports.RestateSinglePromise = RestateSinglePromise;
|
|
233
|
-
exports.extractContext = extractContext;
|
|
269
|
+
exports.SingleRestatePromise = SingleRestatePromise;
|
|
270
|
+
exports.isRestatePromise = isRestatePromise;
|
|
234
271
|
exports.pendingPromise = pendingPromise;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./types/errors.cjs";
|
|
2
|
+
import { RestatePromise } from "./context.cjs";
|
|
3
|
+
import "./context_impl.cjs";
|
|
4
|
+
import "./io.cjs";
|
|
5
|
+
import { Duration } from "@restatedev/restate-sdk-core";
|
|
6
|
+
|
|
7
|
+
//#region src/promises.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns `true` if the given value is a {@link RestatePromise}.
|
|
11
|
+
*
|
|
12
|
+
* Use this for runtime type detection when you need to distinguish Restate promises
|
|
13
|
+
* from regular promises, e.g. for overload resolution.
|
|
14
|
+
*/
|
|
15
|
+
declare function isRestatePromise<T>(p: Promise<T>): p is RestatePromise<T>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isRestatePromise };
|
|
18
|
+
//# sourceMappingURL=promises.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promises.d.cts","names":[],"sources":["../src/promises.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;iBA8CgB,uBAAuB,QAAQ,UAAU,eAAe"}
|
package/dist/promises.d.ts
CHANGED
|
@@ -1,111 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare const RESTATE_CTX_SYMBOL: unique symbol;
|
|
10
|
-
export interface InternalRestatePromise<T> extends RestatePromise<T> {
|
|
11
|
-
[RESTATE_CTX_SYMBOL]: ContextImpl;
|
|
12
|
-
tryCancel(): void;
|
|
13
|
-
tryComplete(): Promise<void>;
|
|
14
|
-
uncompletedLeaves(): Array<number>;
|
|
15
|
-
publicPromise(): Promise<T>;
|
|
16
|
-
}
|
|
17
|
-
export type AsyncResultValue = "Empty" | {
|
|
18
|
-
Success: Uint8Array;
|
|
19
|
-
} | {
|
|
20
|
-
Failure: vm.WasmFailure;
|
|
21
|
-
} | {
|
|
22
|
-
StateKeys: string[];
|
|
23
|
-
} | {
|
|
24
|
-
InvocationId: string;
|
|
25
|
-
};
|
|
26
|
-
export declare function extractContext(n: any): ContextImpl | undefined;
|
|
27
|
-
declare abstract class AbstractRestatePromise<T> implements InternalRestatePromise<T> {
|
|
28
|
-
[RESTATE_CTX_SYMBOL]: ContextImpl;
|
|
29
|
-
private pollingPromise?;
|
|
30
|
-
private cancelPromise;
|
|
31
|
-
protected constructor(ctx: ContextImpl);
|
|
32
|
-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
33
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
34
|
-
finally(onfinally?: (() => void) | null): Promise<T>;
|
|
35
|
-
private publicPromiseOrCancelPromise;
|
|
36
|
-
orTimeout(duration: number | Duration): RestatePromise<T>;
|
|
37
|
-
map<U>(mapper: (value?: T, failure?: TerminalError) => U): RestatePromise<U>;
|
|
38
|
-
tryCancel(): void;
|
|
39
|
-
abstract tryComplete(): Promise<void>;
|
|
40
|
-
abstract uncompletedLeaves(): Array<number>;
|
|
41
|
-
abstract publicPromise(): Promise<T>;
|
|
42
|
-
abstract [Symbol.toStringTag]: string;
|
|
43
|
-
}
|
|
44
|
-
export declare class RestateSinglePromise<T> extends AbstractRestatePromise<T> {
|
|
45
|
-
readonly handle: number;
|
|
46
|
-
private readonly completer;
|
|
47
|
-
private state;
|
|
48
|
-
private completablePromise;
|
|
49
|
-
constructor(ctx: ContextImpl, handle: number, completer: (value: AsyncResultValue, prom: CompletablePromise<T>) => Promise<void>);
|
|
50
|
-
uncompletedLeaves(): number[];
|
|
51
|
-
tryComplete(): Promise<void>;
|
|
52
|
-
publicPromise(): Promise<T>;
|
|
53
|
-
readonly [Symbol.toStringTag] = "RestateSinglePromise";
|
|
54
|
-
}
|
|
55
|
-
export declare class RestateInvocationPromise<T> extends RestateSinglePromise<T> implements InvocationPromise<T> {
|
|
56
|
-
private readonly invocationIdPromise;
|
|
57
|
-
constructor(ctx: ContextImpl, handle: number, completer: (value: AsyncResultValue, prom: CompletablePromise<T>) => Promise<void>, invocationIdPromise: Promise<InvocationId>);
|
|
58
|
-
get invocationId(): Promise<InvocationId>;
|
|
59
|
-
}
|
|
60
|
-
export declare class RestateCombinatorPromise extends AbstractRestatePromise<any> {
|
|
61
|
-
readonly childs: Array<InternalRestatePromise<any>>;
|
|
62
|
-
private state;
|
|
63
|
-
private readonly combinatorPromise;
|
|
64
|
-
constructor(ctx: ContextImpl, combinatorConstructor: (promises: Promise<any>[]) => Promise<any>, childs: Array<InternalRestatePromise<any>>);
|
|
65
|
-
uncompletedLeaves(): number[];
|
|
66
|
-
tryComplete(): Promise<void>;
|
|
67
|
-
publicPromise(): Promise<unknown>;
|
|
68
|
-
readonly [Symbol.toStringTag] = "RestateCombinatorPromise";
|
|
69
|
-
}
|
|
70
|
-
export declare class RestatePendingPromise<T> implements InternalRestatePromise<T> {
|
|
71
|
-
[RESTATE_CTX_SYMBOL]: ContextImpl;
|
|
72
|
-
constructor(ctx: ContextImpl);
|
|
73
|
-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
74
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
75
|
-
finally(onfinally?: (() => void) | null): Promise<T>;
|
|
76
|
-
orTimeout(): RestatePromise<T>;
|
|
77
|
-
map<U>(): RestatePromise<U>;
|
|
78
|
-
tryCancel(): void;
|
|
79
|
-
tryComplete(): Promise<void>;
|
|
80
|
-
uncompletedLeaves(): number[];
|
|
81
|
-
publicPromise(): Promise<T>;
|
|
82
|
-
readonly [Symbol.toStringTag] = "RestatePendingPromise";
|
|
83
|
-
}
|
|
84
|
-
export declare class InvocationPendingPromise<T> extends RestatePendingPromise<T> implements InvocationPromise<T> {
|
|
85
|
-
constructor(ctx: ContextImpl);
|
|
86
|
-
get invocationId(): Promise<InvocationId>;
|
|
87
|
-
}
|
|
88
|
-
export declare class RestateMappedPromise<T, U> extends AbstractRestatePromise<U> {
|
|
89
|
-
readonly inner: InternalRestatePromise<T>;
|
|
90
|
-
private publicPromiseMapper;
|
|
91
|
-
constructor(ctx: ContextImpl, inner: InternalRestatePromise<T>, mapper: (value?: T, failure?: TerminalError) => U);
|
|
92
|
-
tryComplete(): Promise<void>;
|
|
93
|
-
uncompletedLeaves(): number[];
|
|
94
|
-
publicPromise(): Promise<U>;
|
|
95
|
-
readonly [Symbol.toStringTag] = "RestateMappedPromise";
|
|
96
|
-
}
|
|
1
|
+
import "./types/errors.js";
|
|
2
|
+
import { RestatePromise } from "./context.js";
|
|
3
|
+
import "./context_impl.js";
|
|
4
|
+
import "./io.js";
|
|
5
|
+
import { Duration } from "@restatedev/restate-sdk-core";
|
|
6
|
+
|
|
7
|
+
//#region src/promises.d.ts
|
|
8
|
+
|
|
97
9
|
/**
|
|
98
|
-
*
|
|
10
|
+
* Returns `true` if the given value is a {@link RestatePromise}.
|
|
11
|
+
*
|
|
12
|
+
* Use this for runtime type detection when you need to distinguish Restate promises
|
|
13
|
+
* from regular promises, e.g. for overload resolution.
|
|
99
14
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
private readonly outputPump;
|
|
104
|
-
private readonly runClosuresTracker;
|
|
105
|
-
private readonly errorCallback;
|
|
106
|
-
constructor(coreVm: vm.WasmVM, inputPump: InputPump, outputPump: OutputPump, runClosuresTracker: RunClosuresTracker, errorCallback: (e: any) => void);
|
|
107
|
-
doProgress(restatePromise: InternalRestatePromise<unknown>): Promise<void>;
|
|
108
|
-
private doProgressInner;
|
|
109
|
-
}
|
|
110
|
-
export {};
|
|
15
|
+
declare function isRestatePromise<T>(p: Promise<T>): p is RestatePromise<T>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isRestatePromise };
|
|
111
18
|
//# sourceMappingURL=promises.d.ts.map
|
package/dist/promises.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promises.d.ts","
|
|
1
|
+
{"version":3,"file":"promises.d.ts","names":[],"sources":["../src/promises.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;iBA8CgB,uBAAuB,QAAQ,UAAU,eAAe"}
|