@restatedev/restate-sdk 1.11.0 → 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
|
@@ -5,6 +5,14 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (all) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
8
16
|
var __copyProps = (to, from, except, desc) => {
|
|
9
17
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
18
|
key = keys[i];
|
|
@@ -22,4 +30,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
30
|
|
|
23
31
|
//#endregion
|
|
24
32
|
|
|
33
|
+
exports.__export = __export;
|
|
25
34
|
exports.__toESM = __toESM;
|
package/dist/common_api.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_errors = require('./types/errors.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_promises = require('./promises.cjs');
|
|
4
4
|
const require_context = require('./context.cjs');
|
|
5
|
+
const require_rpc = require('./types/rpc.cjs');
|
|
5
6
|
const require_internal = require('./internal.cjs');
|
|
6
7
|
let __restatedev_restate_sdk_core = require("@restatedev/restate-sdk-core");
|
|
7
8
|
__restatedev_restate_sdk_core = require_rolldown_runtime.__toESM(__restatedev_restate_sdk_core);
|
package/dist/common_api.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.cjs";
|
|
2
|
+
import { Hooks, HooksProvider, Interceptor } from "./hooks.cjs";
|
|
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.cjs";
|
|
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.cjs";
|
|
5
|
+
import { internal_d_exports } from "./internal.cjs";
|
|
4
6
|
import { LogMetadata, LogSource, LoggerContext, LoggerTransport, RestateLogLevel } from "./logging/logger_transport.cjs";
|
|
5
7
|
import { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase } from "./endpoint.cjs";
|
|
8
|
+
import { isRestatePromise } from "./promises.cjs";
|
|
6
9
|
import { EndpointOptions } from "./endpoint/types.cjs";
|
|
7
|
-
import { internal_d_exports } from "./internal.cjs";
|
|
8
10
|
import { Duration as Duration$1, JournalValueCodec as JournalValueCodec$1, ObjectHandler as ObjectHandler$1, RestateContext as RestateContext$1, RestateObjectContext as RestateObjectContext$1, RestateObjectSharedContext as RestateObjectSharedContext$1, RestateWorkflowContext as RestateWorkflowContext$1, RestateWorkflowSharedContext as RestateWorkflowSharedContext$1, Serde as Serde$1, Service as Service$1, ServiceDefinition as ServiceDefinition$1, ServiceDefinitionFrom as ServiceDefinitionFrom$1, ServiceHandler as ServiceHandler$1, VirtualObject as VirtualObject$1, VirtualObjectDefinition as VirtualObjectDefinition$1, VirtualObjectDefinitionFrom as VirtualObjectDefinitionFrom$1, Workflow as Workflow$1, WorkflowDefinition as WorkflowDefinition$1, WorkflowDefinitionFrom as WorkflowDefinitionFrom$1, WorkflowHandler as WorkflowHandler$1, WorkflowSharedHandler as WorkflowSharedHandler$1, serde } from "@restatedev/restate-sdk-core";
|
|
9
11
|
|
|
10
12
|
//#region src/common_api.d.ts
|
|
@@ -12,6 +14,8 @@ import { Duration as Duration$1, JournalValueCodec as JournalValueCodec$1, Objec
|
|
|
12
14
|
* @deprecated Use {@link RestatePromise}
|
|
13
15
|
*/
|
|
14
16
|
declare const CombineablePromise: {
|
|
17
|
+
resolve<T>(value: T): RestatePromise<Awaited<T>>;
|
|
18
|
+
reject<T = never>(reason: TerminalError): RestatePromise<T>;
|
|
15
19
|
all<const T extends readonly RestatePromise<unknown>[]>(values: T): RestatePromise<{ -readonly [P in keyof T]: Awaited<T[P]> }>;
|
|
16
20
|
race<const T extends readonly RestatePromise<unknown>[]>(values: T): RestatePromise<Awaited<T[number]>>;
|
|
17
21
|
any<const T extends readonly RestatePromise<unknown>[]>(values: T): RestatePromise<Awaited<T[number]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common_api.d.cts","names":[],"sources":["../src/common_api.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common_api.d.cts","names":[],"sources":["../src/common_api.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;cAyCa;;;6GAuG08sB,IAAA,QAAA,EAAA;;EAvG18sB,GAAA,CAAA,gBAAA,uBAAmC,CAAA,OAAA,CAAA,EAAA,CAAA,CAAA,MAAA,GAAA,CAAA,gBAAA,QAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA;oHAuG40wB,IAAA,qBAAA,QAAA,EAAA;;;;;KAlGh3wB,wBAAwB,eAAe;cA0FtC,6BAAoB,QAAA,CAAA;cACpB,4BAAmB,QAAA,CAAA,MAAA,CAAA;cACnB,kCAAyB,QAAA,CAAA,MAAA,CAAA;cACzB,8BAAqB,QAAA,CAAA,QAAA,CAAA;AAK01wB,cAJ/2wB,2BAI+2wB,EAAA,OAJp1wB,QAAA,CAAA,QAAA,CAAA,MAIo1wB"}
|
package/dist/common_api.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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 { Duration as Duration$1, JournalValueCodec as JournalValueCodec$1, ObjectHandler as ObjectHandler$1, RestateContext as RestateContext$1, RestateObjectContext as RestateObjectContext$1, RestateObjectSharedContext as RestateObjectSharedContext$1, RestateWorkflowContext as RestateWorkflowContext$1, RestateWorkflowSharedContext as RestateWorkflowSharedContext$1, Serde as Serde$1, Service as Service$1, ServiceDefinition as ServiceDefinition$1, ServiceDefinitionFrom as ServiceDefinitionFrom$1, ServiceHandler as ServiceHandler$1, VirtualObject as VirtualObject$1, VirtualObjectDefinition as VirtualObjectDefinition$1, VirtualObjectDefinitionFrom as VirtualObjectDefinitionFrom$1, Workflow as Workflow$1, WorkflowDefinition as WorkflowDefinition$1, WorkflowDefinitionFrom as WorkflowDefinitionFrom$1, WorkflowHandler as WorkflowHandler$1, WorkflowSharedHandler as WorkflowSharedHandler$1, serde as serde$1 } from "@restatedev/restate-sdk-core";
|
|
9
11
|
|
|
10
12
|
//#region src/common_api.d.ts
|
|
@@ -12,6 +14,8 @@ import { Duration as Duration$1, JournalValueCodec as JournalValueCodec$1, Objec
|
|
|
12
14
|
* @deprecated Use {@link RestatePromise}
|
|
13
15
|
*/
|
|
14
16
|
declare const CombineablePromise: {
|
|
17
|
+
resolve<T>(value: T): RestatePromise<Awaited<T>>;
|
|
18
|
+
reject<T = never>(reason: TerminalError): RestatePromise<T>;
|
|
15
19
|
all<const T extends readonly RestatePromise<unknown>[]>(values: T): RestatePromise<{ -readonly [P in keyof T]: Awaited<T[P]> }>;
|
|
16
20
|
race<const T extends readonly RestatePromise<unknown>[]>(values: T): RestatePromise<Awaited<T[number]>>;
|
|
17
21
|
any<const T extends readonly RestatePromise<unknown>[]>(values: T): RestatePromise<Awaited<T[number]>>;
|
package/dist/common_api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common_api.d.ts","names":[],"sources":["../src/common_api.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common_api.d.ts","names":[],"sources":["../src/common_api.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;cAyCa;;;6GAuG08sB,IAAA,QAAA,EAAA;;EAvG18sB,GAAA,CAAA,gBAAA,uBAAmC,CAAA,OAAA,CAAA,EAAA,CAAA,CAAA,MAAA,GAAA,CAAA,gBAAA,QAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA;oHAuG40wB,IAAA,qBAAA,QAAA,EAAA;;;;;KAlGh3wB,wBAAwB,eAAe;cA0FtC,6BAAoB,QAAA,CAAA;cACpB,4BAAmB,QAAA,CAAA,MAAA,CAAA;cACnB,kCAAyB,QAAA,CAAA,MAAA,CAAA;cACzB,8BAAqB,QAAA,CAAA,QAAA,CAAA;AAK01wB,cAJ/2wB,2BAI+2wB,EAAA,OAJp1wB,QAAA,CAAA,QAAA,CAAA,MAIo1wB"}
|
package/dist/common_api.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 { serde as serde$1 } from "@restatedev/restate-sdk-core";
|
|
6
7
|
|
package/dist/common_api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common_api.js","names":[],"sources":["../src/common_api.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\nimport { RestatePromise } from \"./context.js\";\n\nexport type {\n Context,\n ObjectContext,\n ObjectSharedContext,\n WorkflowContext,\n WorkflowSharedContext,\n Rand,\n GenericCall,\n GenericSend,\n InvocationId,\n InvocationHandle,\n InvocationPromise,\n TypedState,\n UntypedState,\n ContextDate,\n RunAction,\n RunOptions,\n
|
|
1
|
+
{"version":3,"file":"common_api.js","names":[],"sources":["../src/common_api.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\nimport { RestatePromise } from \"./context.js\";\n\nexport type {\n Context,\n ObjectContext,\n ObjectSharedContext,\n WorkflowContext,\n WorkflowSharedContext,\n Rand,\n GenericCall,\n GenericSend,\n InvocationId,\n InvocationHandle,\n InvocationPromise,\n TypedState,\n UntypedState,\n ContextDate,\n RunAction,\n RunOptions,\n KeyValueStore,\n DurablePromise,\n Request,\n Target,\n} from \"./context.js\";\nexport { InvocationIdParser, RestatePromise } from \"./context.js\";\nexport { isRestatePromise } from \"./promises.js\";\n\n/**\n * @deprecated Use {@link RestatePromise}\n */\nexport const CombineablePromise = RestatePromise;\n\n/**\n * @deprecated Use {@link RestatePromise}\n */\nexport type CombineablePromise<T> = RestatePromise<T>;\n\nexport type {\n Serde,\n RestateContext,\n ServiceDefinitionFrom,\n Service,\n VirtualObjectDefinitionFrom,\n VirtualObject,\n WorkflowDefinitionFrom,\n Workflow,\n RestateObjectContext,\n RestateObjectSharedContext,\n RestateWorkflowSharedContext,\n RestateWorkflowContext,\n ServiceHandler,\n ObjectHandler,\n WorkflowHandler,\n WorkflowSharedHandler,\n Duration,\n JournalValueCodec,\n} from \"@restatedev/restate-sdk-core\";\nexport { serde } from \"@restatedev/restate-sdk-core\";\n\nexport type {\n Client,\n SendClient,\n ClientCallOptions,\n ClientSendOptions,\n RemoveVoidArgument,\n InferArg,\n ServiceHandlerOpts,\n WorkflowHandlerOpts,\n ObjectHandlerOpts,\n ServiceOpts,\n ObjectOpts,\n WorkflowOpts,\n ServiceOptions,\n ObjectOptions,\n WorkflowOptions,\n RetryPolicy,\n} from \"./types/rpc.js\";\nexport {\n service,\n object,\n workflow,\n handlers,\n Opts,\n SendOpts,\n} from \"./types/rpc.js\";\n\nexport { rpc } from \"./types/rpc.js\";\n\nexport type {\n ServiceDefinition,\n VirtualObjectDefinition,\n WorkflowDefinition,\n} from \"@restatedev/restate-sdk-core\";\n\nexport type {\n RestateEndpoint,\n RestateEndpointBase,\n DefaultServiceOptions,\n} from \"./endpoint.js\";\n\nexport {\n /**\n * @deprecated YOU MUST NOT USE THIS TYPE\n */\n RestateError,\n TerminalError,\n TimeoutError,\n RetryableError,\n CancelledError,\n type RetryableErrorOptions,\n} from \"./types/errors.js\";\nexport type {\n LoggerTransport,\n LogMetadata,\n RestateLogLevel,\n LoggerContext,\n LogSource,\n} from \"./logging/logger_transport.js\";\nexport type { EndpointOptions } from \"./endpoint/types.js\";\nexport type { Hooks, HooksProvider, Interceptor } from \"./hooks.js\";\n\n// re-exporting createHandler shortcuts\n\nimport { handlers } from \"./types/rpc.js\";\n\nexport const createServiceHandler = handlers.handler;\nexport const createObjectHandler = handlers.object.exclusive;\nexport const createObjectSharedHandler = handlers.object.shared;\nexport const createWorkflowHandler = handlers.workflow.workflow;\nexport const createWorkflowSharedHandler = handlers.workflow.shared;\n\n// Internal APIs\nexport * as internal from \"./internal.js\";\n"],"mappings":";;;;;;;;;;;AAyCA,MAAa,qBAAqB;AA+FlC,MAAa,uBAAuB,SAAS;AAC7C,MAAa,sBAAsB,SAAS,OAAO;AACnD,MAAa,4BAA4B,SAAS,OAAO;AACzD,MAAa,wBAAwB,SAAS,SAAS;AACvD,MAAa,8BAA8B,SAAS,SAAS"}
|
package/dist/context.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_promises = require('./promises.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/context.ts
|
|
4
4
|
const InvocationIdParser = { fromString(id) {
|
|
@@ -6,21 +6,25 @@ const InvocationIdParser = { fromString(id) {
|
|
|
6
6
|
return id;
|
|
7
7
|
} };
|
|
8
8
|
const RestatePromise = {
|
|
9
|
+
resolve(value) {
|
|
10
|
+
if (value instanceof require_promises.InternalRestatePromise) return value;
|
|
11
|
+
return require_promises.ConstRestatePromise.resolve(value);
|
|
12
|
+
},
|
|
13
|
+
reject(reason) {
|
|
14
|
+
return require_promises.ConstRestatePromise.reject(reason);
|
|
15
|
+
},
|
|
9
16
|
all(values) {
|
|
10
|
-
|
|
11
|
-
return require_context_impl.ContextImpl.createCombinator((p) => Promise.all(p), values);
|
|
17
|
+
return require_promises.CombinatorRestatePromise.fromPromises((p) => Promise.all(p), values);
|
|
12
18
|
},
|
|
13
19
|
race(values) {
|
|
14
|
-
if (values.length === 0)
|
|
15
|
-
return
|
|
20
|
+
if (values.length === 0) return require_promises.ConstRestatePromise.pending();
|
|
21
|
+
return require_promises.CombinatorRestatePromise.fromPromises((p) => Promise.race(p), values);
|
|
16
22
|
},
|
|
17
23
|
any(values) {
|
|
18
|
-
|
|
19
|
-
return require_context_impl.ContextImpl.createCombinator((p) => Promise.any(p), values);
|
|
24
|
+
return require_promises.CombinatorRestatePromise.fromPromises((p) => Promise.any(p), values);
|
|
20
25
|
},
|
|
21
26
|
allSettled(values) {
|
|
22
|
-
|
|
23
|
-
return require_context_impl.ContextImpl.createCombinator((p) => Promise.allSettled(p), values);
|
|
27
|
+
return require_promises.CombinatorRestatePromise.fromPromises((p) => Promise.allSettled(p), values);
|
|
24
28
|
}
|
|
25
29
|
};
|
|
26
30
|
|
package/dist/context.d.cts
CHANGED
|
@@ -3,7 +3,12 @@ import { Client, SendClient } from "./types/rpc.cjs";
|
|
|
3
3
|
import { Duration, RestateContext, RestateObjectContext, RestateObjectSharedContext, RestateWorkflowContext, RestateWorkflowSharedContext, Serde, Service, ServiceDefinitionFrom, VirtualObject, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinitionFrom } from "@restatedev/restate-sdk-core";
|
|
4
4
|
|
|
5
5
|
//#region src/context.d.ts
|
|
6
|
-
|
|
6
|
+
interface Target {
|
|
7
|
+
service: string;
|
|
8
|
+
handler: string;
|
|
9
|
+
key?: string;
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Represents the original request as sent to this handler.
|
|
9
14
|
*
|
|
@@ -11,11 +16,12 @@ import { Duration, RestateContext, RestateObjectContext, RestateObjectSharedCont
|
|
|
11
16
|
* request body.
|
|
12
17
|
*/
|
|
13
18
|
interface Request {
|
|
19
|
+
readonly target: Target;
|
|
14
20
|
/**
|
|
15
21
|
* The unique id that identifies the current function invocation. This id is guaranteed to be
|
|
16
22
|
* unique across invocations, but constant across reties and suspensions.
|
|
17
23
|
*/
|
|
18
|
-
readonly id:
|
|
24
|
+
readonly id: InvocationId;
|
|
19
25
|
/**
|
|
20
26
|
* Request headers - the following headers capture the original invocation headers, as provided to
|
|
21
27
|
* the ingress.
|
|
@@ -97,15 +103,6 @@ interface KeyValueStore<TState extends TypedState> {
|
|
|
97
103
|
*/
|
|
98
104
|
clearAll(): void;
|
|
99
105
|
}
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated SendOptions on the client factory are deprecated, please use `restate.rpc.sendOpts` instead
|
|
102
|
-
*/
|
|
103
|
-
interface SendOptions {
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated SendOptions on the client factory are deprecated, please use `restate.rpc.sendOpts` instead
|
|
106
|
-
*/
|
|
107
|
-
delay?: number;
|
|
108
|
-
}
|
|
109
106
|
interface ContextDate {
|
|
110
107
|
/** Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
111
108
|
* This is equivalent to Date.now()
|
|
@@ -128,10 +125,6 @@ type RunOptions<T> = {
|
|
|
128
125
|
* When giving up, `ctx.run` will throw a `TerminalError` wrapping the original error message.
|
|
129
126
|
*/
|
|
130
127
|
maxRetryAttempts?: number;
|
|
131
|
-
/**
|
|
132
|
-
* @deprecated Use `maxRetryDuration` instead.
|
|
133
|
-
*/
|
|
134
|
-
maxRetryDurationMillis?: number;
|
|
135
128
|
/**
|
|
136
129
|
* Max duration of retries, before giving up.
|
|
137
130
|
*
|
|
@@ -140,10 +133,6 @@ type RunOptions<T> = {
|
|
|
140
133
|
* If a number is provided, it will be interpreted as milliseconds.
|
|
141
134
|
*/
|
|
142
135
|
maxRetryDuration?: Duration | number;
|
|
143
|
-
/**
|
|
144
|
-
* @deprecated Use `initialRetryInterval` instead.
|
|
145
|
-
*/
|
|
146
|
-
initialRetryIntervalMillis?: number;
|
|
147
136
|
/**
|
|
148
137
|
* Initial interval for the first retry attempt.
|
|
149
138
|
* Retry interval will grow by a factor specified in `retryIntervalFactor`.
|
|
@@ -153,10 +142,6 @@ type RunOptions<T> = {
|
|
|
153
142
|
* If a number is provided, it will be interpreted as milliseconds.
|
|
154
143
|
*/
|
|
155
144
|
initialRetryInterval?: Duration | number;
|
|
156
|
-
/**
|
|
157
|
-
* @deprecated Use `maxRetryInterval` instead.
|
|
158
|
-
*/
|
|
159
|
-
maxRetryIntervalMillis?: number;
|
|
160
145
|
/**
|
|
161
146
|
* Max interval between retries.
|
|
162
147
|
* Retry interval will grow by a factor specified in `retryIntervalFactor`.
|
|
@@ -355,13 +340,13 @@ interface Context extends RestateContext {
|
|
|
355
340
|
* Reject an awakeable. When rejecting, the service waiting on this awakeable will be woken up with a terminal error with the provided reason.
|
|
356
341
|
* @param id the string ID of the awakeable.
|
|
357
342
|
* This is supplied by the service that needs to be woken up.
|
|
358
|
-
* @param reason the reason of the rejection.
|
|
343
|
+
* @param reason the reason of the rejection, either a string message or a {@link TerminalError}.
|
|
359
344
|
*
|
|
360
345
|
* @example
|
|
361
346
|
* // The sleeping service should have sent the awakeableIdentifier string to this service.
|
|
362
347
|
* ctx.rejectAwakeable(awakeableIdentifier, "super bad error");
|
|
363
348
|
*/
|
|
364
|
-
rejectAwakeable(id: string, reason: string): void;
|
|
349
|
+
rejectAwakeable(id: string, reason: string | TerminalError): void;
|
|
365
350
|
/**
|
|
366
351
|
* Sleep until a timeout has passed.
|
|
367
352
|
* @param duration either Duration type or milliseconds.
|
|
@@ -474,7 +459,7 @@ interface Context extends RestateContext {
|
|
|
474
459
|
* ctx.serviceSendClient(MyService).anotherAction(1337);
|
|
475
460
|
* ```
|
|
476
461
|
*/
|
|
477
|
-
serviceSendClient<D>(service: ServiceDefinitionFrom<D
|
|
462
|
+
serviceSendClient<D>(service: ServiceDefinitionFrom<D>): SendClient<Service<D>>;
|
|
478
463
|
/**
|
|
479
464
|
* Same as {@link serviceSendClient} but for virtual objects.
|
|
480
465
|
*
|
|
@@ -482,7 +467,7 @@ interface Context extends RestateContext {
|
|
|
482
467
|
* @param key the virtual object key
|
|
483
468
|
* @param opts Send options
|
|
484
469
|
*/
|
|
485
|
-
objectSendClient<D>(obj: VirtualObjectDefinitionFrom<D>, key: string
|
|
470
|
+
objectSendClient<D>(obj: VirtualObjectDefinitionFrom<D>, key: string): SendClient<VirtualObject<D>>;
|
|
486
471
|
genericCall<REQ = Uint8Array, RES = Uint8Array>(call: GenericCall<REQ, RES>): InvocationPromise<RES>;
|
|
487
472
|
genericSend<REQ = Uint8Array>(call: GenericSend<REQ>): InvocationHandle;
|
|
488
473
|
/**
|
|
@@ -563,6 +548,8 @@ interface Rand {
|
|
|
563
548
|
}
|
|
564
549
|
/**
|
|
565
550
|
* A promise that can be combined using Promise combinators in RestateContext.
|
|
551
|
+
*
|
|
552
|
+
* To check at runtime whether a value is a {@link RestatePromise}, use {@link isRestatePromise}.
|
|
566
553
|
*/
|
|
567
554
|
type RestatePromise<T> = Promise<T> & {
|
|
568
555
|
/**
|
|
@@ -582,6 +569,9 @@ type RestatePromise<T> = Promise<T> & {
|
|
|
582
569
|
* {@link Promise.then} is used by Restate to distinguish when awaiting an asynchronous operation,
|
|
583
570
|
* thus calling `.then` on several Restate promises can lead to concurrency issues.
|
|
584
571
|
*
|
|
572
|
+
* **NOTE**: Contrary to `.then`, the closure is executed ONLY when the promise is awaited,
|
|
573
|
+
* and not eagerly as soon as the promise completes.
|
|
574
|
+
*
|
|
585
575
|
* @param mapper the function to execute when this promise is fulfilled.
|
|
586
576
|
* If the promise completed successfully, `value` is provided as input, otherwise `failure` is provided as input.
|
|
587
577
|
* If this mapper returns a value, this value will be used to resolve the returned {@link RestatePromise}.
|
|
@@ -608,6 +598,23 @@ type InvocationHandle = {
|
|
|
608
598
|
};
|
|
609
599
|
type InvocationPromise<T> = RestatePromise<T> & InvocationHandle;
|
|
610
600
|
declare const RestatePromise: {
|
|
601
|
+
/**
|
|
602
|
+
* Creates a {@link RestatePromise} that is resolved with the given value.
|
|
603
|
+
*
|
|
604
|
+
* If the value is already a {@link RestatePromise}, it is returned as-is (mirroring
|
|
605
|
+
* the behavior of {@link Promise.resolve} when given a native {@link Promise}).
|
|
606
|
+
*
|
|
607
|
+
* @param value The value to resolve, or an existing {@link RestatePromise} to return.
|
|
608
|
+
* @returns A resolved {@link RestatePromise}, or the input promise unchanged.
|
|
609
|
+
*/
|
|
610
|
+
resolve<T>(value: T): RestatePromise<Awaited<T>>;
|
|
611
|
+
/**
|
|
612
|
+
* Creates a {@link RestatePromise} that is rejected with the given {@link TerminalError}.
|
|
613
|
+
*
|
|
614
|
+
* @param reason The {@link TerminalError} to reject with.
|
|
615
|
+
* @returns A rejected {@link RestatePromise}.
|
|
616
|
+
*/
|
|
617
|
+
reject<T = never>(reason: TerminalError): RestatePromise<T>;
|
|
611
618
|
/**
|
|
612
619
|
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
613
620
|
* resolve, or rejected when any Promise is rejected.
|
|
@@ -653,7 +660,7 @@ declare const RestatePromise: {
|
|
|
653
660
|
/**
|
|
654
661
|
* Workflow bound durable promise
|
|
655
662
|
*
|
|
656
|
-
* See {@link WorkflowSharedContext}
|
|
663
|
+
* See {@link WorkflowSharedContext}.
|
|
657
664
|
*/
|
|
658
665
|
type DurablePromise<T> = Promise<T> & {
|
|
659
666
|
/**
|
|
@@ -703,5 +710,5 @@ interface WorkflowSharedContext<TState extends TypedState = UntypedState> extend
|
|
|
703
710
|
}
|
|
704
711
|
interface WorkflowContext<TState extends TypedState = UntypedState> extends WorkflowSharedContext<TState>, ObjectContext<TState>, RestateWorkflowContext {}
|
|
705
712
|
//#endregion
|
|
706
|
-
export { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions,
|
|
713
|
+
export { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext };
|
|
707
714
|
//# sourceMappingURL=context.d.cts.map
|
package/dist/context.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"sourcesContent":[],"mappings":";;;;;UAkCiB,MAAA;;EAAA,OAAA,EAAM,MAAA;EAaN,GAAA,CAAA,EAAA,MAAO;EACL,QAAA,EAAA,EAAA,MAAA;;;;;;;AA8CnB;AACY,UAhDK,OAAA,CAgDO;EAKP,SAAA,MAAA,EApDE,MAoDW;EAAgB;;;;EAaG,SAAA,EAAA,EA3DlC,YA2DkC;EAC/B;;;;EAA8C,SAAA,OAAA,EAtD5C,WAsD4C,CAAA,MAAA,EAAA,MAAA,CAAA;EAApD;;;;;EACgD,SAAA,cAAA,EAhDjC,WAgDiC,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA,CAAA;EAAvD;;;EAe4B,SAAA,IAAA,EA1DhB,UA0DgB;EACvB;;;;;;;;;EAEuB,SAAA,SAAA,EAAA,OAAA,EAAA;EAAe;;;;;EAWtC,SAAA,sBAAA,EAtDyB,WAsDzB;;AAAuC,KAlDrC,UAAA,GAAa,MAkDwB,CAAA,MAAA,EAAA,GAAA,CAAA;AAAI,KAjDzC,YAAA,GA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;uBAOU;;;;;;;0BAQG,sBAAsB,MAAM,KAAK,eAAe;;;;;;;;;;;;;;UAezD,6BAA6B,aAAa,sBACjD,SAAS,cAAc,SAAS;;;;;;;;;;;;;;UAezB,mCAAmC,aAAa,sBACvD,SAAS;;;;;;;;;;;;;iCAcc,uBACvB,eAAe,wBAAwB,cACrC,MAAM,eAAe,eAAe,SAAS,OAAO,SAC3D,SAAS,eAAe,eAAe,SAAS,OAAO;;;;eAK7C,QAAQ;;UAGN,IAAA;;;;;;;;;;;;;;;;;KAmBL,oBAAoB,QAAQ;;;;;;;;oBAQpB,oBAAoB,eAAe;;;;;;;;;;;;;;;;;;0BAmB7B,aAAa,kBAAkB,IAAI,eAAe;;;;;;KAOhE,YAAA;;;cAEC;;;;;0BAKa;;KAUd,gBAAA;yBAEa,QAAQ;;KAGrB,uBAAuB,eAAe,KAAK;cAE1C;;;;;;;;;;oBAUO,IAAI,eAAe,QAAQ;;;;;;;4BAanB,gBAAgB,eAAe;;;;;;;;;;+BAa5B,mCACnB,IACP,uCAAuC,IAAI,QAAQ,EAAE;;;;;;;;;;gCAkB1B,mCACpB,IACP,eAAe,QAAQ;;;;;;;;;;;+BAoBG,mCACnB,IACP,eAAe,QAAQ;;;;;;;;;;sCAgBU,mCAC1B,IACP,uCACqB,IAAI,qBAAqB,QAAQ,EAAE;;;;;;;KAgBjD,oBAAoB,QAAQ;;;;UAI9B,QAAQ;;;;;kBAMA,IAAI;;;;;4BAMM;;;;SAKnB,eAAe;;UAGP,qCAAqC,aAAa,sBACzD,oBAAoB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;mCAwBJ,MAAM,KAAK,eAAe;;UAG5C,+BAA+B,aAAa,sBAEzD,sBAAsB,SACtB,cAAc,SACd"}
|
package/dist/context.d.ts
CHANGED
|
@@ -3,7 +3,12 @@ import { Client, SendClient } from "./types/rpc.js";
|
|
|
3
3
|
import { Duration, RestateContext, RestateObjectContext, RestateObjectSharedContext, RestateWorkflowContext, RestateWorkflowSharedContext, Serde, Service, ServiceDefinitionFrom, VirtualObject, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinitionFrom } from "@restatedev/restate-sdk-core";
|
|
4
4
|
|
|
5
5
|
//#region src/context.d.ts
|
|
6
|
-
|
|
6
|
+
interface Target {
|
|
7
|
+
service: string;
|
|
8
|
+
handler: string;
|
|
9
|
+
key?: string;
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Represents the original request as sent to this handler.
|
|
9
14
|
*
|
|
@@ -11,11 +16,12 @@ import { Duration, RestateContext, RestateObjectContext, RestateObjectSharedCont
|
|
|
11
16
|
* request body.
|
|
12
17
|
*/
|
|
13
18
|
interface Request {
|
|
19
|
+
readonly target: Target;
|
|
14
20
|
/**
|
|
15
21
|
* The unique id that identifies the current function invocation. This id is guaranteed to be
|
|
16
22
|
* unique across invocations, but constant across reties and suspensions.
|
|
17
23
|
*/
|
|
18
|
-
readonly id:
|
|
24
|
+
readonly id: InvocationId;
|
|
19
25
|
/**
|
|
20
26
|
* Request headers - the following headers capture the original invocation headers, as provided to
|
|
21
27
|
* the ingress.
|
|
@@ -97,15 +103,6 @@ interface KeyValueStore<TState extends TypedState> {
|
|
|
97
103
|
*/
|
|
98
104
|
clearAll(): void;
|
|
99
105
|
}
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated SendOptions on the client factory are deprecated, please use `restate.rpc.sendOpts` instead
|
|
102
|
-
*/
|
|
103
|
-
interface SendOptions {
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated SendOptions on the client factory are deprecated, please use `restate.rpc.sendOpts` instead
|
|
106
|
-
*/
|
|
107
|
-
delay?: number;
|
|
108
|
-
}
|
|
109
106
|
interface ContextDate {
|
|
110
107
|
/** Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
111
108
|
* This is equivalent to Date.now()
|
|
@@ -128,10 +125,6 @@ type RunOptions<T> = {
|
|
|
128
125
|
* When giving up, `ctx.run` will throw a `TerminalError` wrapping the original error message.
|
|
129
126
|
*/
|
|
130
127
|
maxRetryAttempts?: number;
|
|
131
|
-
/**
|
|
132
|
-
* @deprecated Use `maxRetryDuration` instead.
|
|
133
|
-
*/
|
|
134
|
-
maxRetryDurationMillis?: number;
|
|
135
128
|
/**
|
|
136
129
|
* Max duration of retries, before giving up.
|
|
137
130
|
*
|
|
@@ -140,10 +133,6 @@ type RunOptions<T> = {
|
|
|
140
133
|
* If a number is provided, it will be interpreted as milliseconds.
|
|
141
134
|
*/
|
|
142
135
|
maxRetryDuration?: Duration | number;
|
|
143
|
-
/**
|
|
144
|
-
* @deprecated Use `initialRetryInterval` instead.
|
|
145
|
-
*/
|
|
146
|
-
initialRetryIntervalMillis?: number;
|
|
147
136
|
/**
|
|
148
137
|
* Initial interval for the first retry attempt.
|
|
149
138
|
* Retry interval will grow by a factor specified in `retryIntervalFactor`.
|
|
@@ -153,10 +142,6 @@ type RunOptions<T> = {
|
|
|
153
142
|
* If a number is provided, it will be interpreted as milliseconds.
|
|
154
143
|
*/
|
|
155
144
|
initialRetryInterval?: Duration | number;
|
|
156
|
-
/**
|
|
157
|
-
* @deprecated Use `maxRetryInterval` instead.
|
|
158
|
-
*/
|
|
159
|
-
maxRetryIntervalMillis?: number;
|
|
160
145
|
/**
|
|
161
146
|
* Max interval between retries.
|
|
162
147
|
* Retry interval will grow by a factor specified in `retryIntervalFactor`.
|
|
@@ -355,13 +340,13 @@ interface Context extends RestateContext {
|
|
|
355
340
|
* Reject an awakeable. When rejecting, the service waiting on this awakeable will be woken up with a terminal error with the provided reason.
|
|
356
341
|
* @param id the string ID of the awakeable.
|
|
357
342
|
* This is supplied by the service that needs to be woken up.
|
|
358
|
-
* @param reason the reason of the rejection.
|
|
343
|
+
* @param reason the reason of the rejection, either a string message or a {@link TerminalError}.
|
|
359
344
|
*
|
|
360
345
|
* @example
|
|
361
346
|
* // The sleeping service should have sent the awakeableIdentifier string to this service.
|
|
362
347
|
* ctx.rejectAwakeable(awakeableIdentifier, "super bad error");
|
|
363
348
|
*/
|
|
364
|
-
rejectAwakeable(id: string, reason: string): void;
|
|
349
|
+
rejectAwakeable(id: string, reason: string | TerminalError): void;
|
|
365
350
|
/**
|
|
366
351
|
* Sleep until a timeout has passed.
|
|
367
352
|
* @param duration either Duration type or milliseconds.
|
|
@@ -474,7 +459,7 @@ interface Context extends RestateContext {
|
|
|
474
459
|
* ctx.serviceSendClient(MyService).anotherAction(1337);
|
|
475
460
|
* ```
|
|
476
461
|
*/
|
|
477
|
-
serviceSendClient<D>(service: ServiceDefinitionFrom<D
|
|
462
|
+
serviceSendClient<D>(service: ServiceDefinitionFrom<D>): SendClient<Service<D>>;
|
|
478
463
|
/**
|
|
479
464
|
* Same as {@link serviceSendClient} but for virtual objects.
|
|
480
465
|
*
|
|
@@ -482,7 +467,7 @@ interface Context extends RestateContext {
|
|
|
482
467
|
* @param key the virtual object key
|
|
483
468
|
* @param opts Send options
|
|
484
469
|
*/
|
|
485
|
-
objectSendClient<D>(obj: VirtualObjectDefinitionFrom<D>, key: string
|
|
470
|
+
objectSendClient<D>(obj: VirtualObjectDefinitionFrom<D>, key: string): SendClient<VirtualObject<D>>;
|
|
486
471
|
genericCall<REQ = Uint8Array, RES = Uint8Array>(call: GenericCall<REQ, RES>): InvocationPromise<RES>;
|
|
487
472
|
genericSend<REQ = Uint8Array>(call: GenericSend<REQ>): InvocationHandle;
|
|
488
473
|
/**
|
|
@@ -563,6 +548,8 @@ interface Rand {
|
|
|
563
548
|
}
|
|
564
549
|
/**
|
|
565
550
|
* A promise that can be combined using Promise combinators in RestateContext.
|
|
551
|
+
*
|
|
552
|
+
* To check at runtime whether a value is a {@link RestatePromise}, use {@link isRestatePromise}.
|
|
566
553
|
*/
|
|
567
554
|
type RestatePromise<T> = Promise<T> & {
|
|
568
555
|
/**
|
|
@@ -582,6 +569,9 @@ type RestatePromise<T> = Promise<T> & {
|
|
|
582
569
|
* {@link Promise.then} is used by Restate to distinguish when awaiting an asynchronous operation,
|
|
583
570
|
* thus calling `.then` on several Restate promises can lead to concurrency issues.
|
|
584
571
|
*
|
|
572
|
+
* **NOTE**: Contrary to `.then`, the closure is executed ONLY when the promise is awaited,
|
|
573
|
+
* and not eagerly as soon as the promise completes.
|
|
574
|
+
*
|
|
585
575
|
* @param mapper the function to execute when this promise is fulfilled.
|
|
586
576
|
* If the promise completed successfully, `value` is provided as input, otherwise `failure` is provided as input.
|
|
587
577
|
* If this mapper returns a value, this value will be used to resolve the returned {@link RestatePromise}.
|
|
@@ -608,6 +598,23 @@ type InvocationHandle = {
|
|
|
608
598
|
};
|
|
609
599
|
type InvocationPromise<T> = RestatePromise<T> & InvocationHandle;
|
|
610
600
|
declare const RestatePromise: {
|
|
601
|
+
/**
|
|
602
|
+
* Creates a {@link RestatePromise} that is resolved with the given value.
|
|
603
|
+
*
|
|
604
|
+
* If the value is already a {@link RestatePromise}, it is returned as-is (mirroring
|
|
605
|
+
* the behavior of {@link Promise.resolve} when given a native {@link Promise}).
|
|
606
|
+
*
|
|
607
|
+
* @param value The value to resolve, or an existing {@link RestatePromise} to return.
|
|
608
|
+
* @returns A resolved {@link RestatePromise}, or the input promise unchanged.
|
|
609
|
+
*/
|
|
610
|
+
resolve<T>(value: T): RestatePromise<Awaited<T>>;
|
|
611
|
+
/**
|
|
612
|
+
* Creates a {@link RestatePromise} that is rejected with the given {@link TerminalError}.
|
|
613
|
+
*
|
|
614
|
+
* @param reason The {@link TerminalError} to reject with.
|
|
615
|
+
* @returns A rejected {@link RestatePromise}.
|
|
616
|
+
*/
|
|
617
|
+
reject<T = never>(reason: TerminalError): RestatePromise<T>;
|
|
611
618
|
/**
|
|
612
619
|
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
613
620
|
* resolve, or rejected when any Promise is rejected.
|
|
@@ -653,7 +660,7 @@ declare const RestatePromise: {
|
|
|
653
660
|
/**
|
|
654
661
|
* Workflow bound durable promise
|
|
655
662
|
*
|
|
656
|
-
* See {@link WorkflowSharedContext}
|
|
663
|
+
* See {@link WorkflowSharedContext}.
|
|
657
664
|
*/
|
|
658
665
|
type DurablePromise<T> = Promise<T> & {
|
|
659
666
|
/**
|
|
@@ -703,5 +710,5 @@ interface WorkflowSharedContext<TState extends TypedState = UntypedState> extend
|
|
|
703
710
|
}
|
|
704
711
|
interface WorkflowContext<TState extends TypedState = UntypedState> extends WorkflowSharedContext<TState>, ObjectContext<TState>, RestateWorkflowContext {}
|
|
705
712
|
//#endregion
|
|
706
|
-
export { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions,
|
|
713
|
+
export { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext };
|
|
707
714
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.ts"],"sourcesContent":[],"mappings":";;;;;UAkCiB,MAAA;;EAAA,OAAA,EAAM,MAAA;EAaN,GAAA,CAAA,EAAA,MAAO;EACL,QAAA,EAAA,EAAA,MAAA;;;;;;;AA8CnB;AACY,UAhDK,OAAA,CAgDO;EAKP,SAAA,MAAA,EApDE,MAoDW;EAAgB;;;;EAaG,SAAA,EAAA,EA3DlC,YA2DkC;EAC/B;;;;EAA8C,SAAA,OAAA,EAtD5C,WAsD4C,CAAA,MAAA,EAAA,MAAA,CAAA;EAApD;;;;;EACgD,SAAA,cAAA,EAhDjC,WAgDiC,CAAA,MAAA,EAAA,MAA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oB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;mCAwBJ,MAAM,KAAK,eAAe;;UAG5C,+BAA+B,aAAa,sBAEzD,sBAAsB,SACtB,cAAc,SACd"}
|
package/dist/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CombinatorRestatePromise, ConstRestatePromise, InternalRestatePromise } from "./promises.js";
|
|
2
2
|
|
|
3
3
|
//#region src/context.ts
|
|
4
4
|
const InvocationIdParser = { fromString(id) {
|
|
@@ -6,21 +6,25 @@ const InvocationIdParser = { fromString(id) {
|
|
|
6
6
|
return id;
|
|
7
7
|
} };
|
|
8
8
|
const RestatePromise = {
|
|
9
|
+
resolve(value) {
|
|
10
|
+
if (value instanceof InternalRestatePromise) return value;
|
|
11
|
+
return ConstRestatePromise.resolve(value);
|
|
12
|
+
},
|
|
13
|
+
reject(reason) {
|
|
14
|
+
return ConstRestatePromise.reject(reason);
|
|
15
|
+
},
|
|
9
16
|
all(values) {
|
|
10
|
-
|
|
11
|
-
return ContextImpl.createCombinator((p) => Promise.all(p), values);
|
|
17
|
+
return CombinatorRestatePromise.fromPromises((p) => Promise.all(p), values);
|
|
12
18
|
},
|
|
13
19
|
race(values) {
|
|
14
|
-
if (values.length === 0)
|
|
15
|
-
return
|
|
20
|
+
if (values.length === 0) return ConstRestatePromise.pending();
|
|
21
|
+
return CombinatorRestatePromise.fromPromises((p) => Promise.race(p), values);
|
|
16
22
|
},
|
|
17
23
|
any(values) {
|
|
18
|
-
|
|
19
|
-
return ContextImpl.createCombinator((p) => Promise.any(p), values);
|
|
24
|
+
return CombinatorRestatePromise.fromPromises((p) => Promise.any(p), values);
|
|
20
25
|
},
|
|
21
26
|
allSettled(values) {
|
|
22
|
-
|
|
23
|
-
return ContextImpl.createCombinator((p) => Promise.allSettled(p), values);
|
|
27
|
+
return CombinatorRestatePromise.fromPromises((p) => Promise.allSettled(p), values);
|
|
24
28
|
}
|
|
25
29
|
};
|
|
26
30
|
|