@restatedev/restate-sdk 1.11.1 → 1.13.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/README.md +12 -9
- 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 +38 -22
- 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 +38 -22
- 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 +113 -39
- package/dist/endpoint/handlers/generic.d.ts.map +1 -1
- package/dist/endpoint/handlers/generic.js +113 -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 +100 -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 +95 -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 +185 -0
- package/dist/types/rpc.d.cts.map +1 -1
- package/dist/types/rpc.d.ts +185 -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/internal.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TerminalError, isSuspendedError } from "./types/errors.js";
|
|
2
|
+
import { Context, InvocationId, RestatePromise } from "./context.js";
|
|
3
|
+
import { Serde } from "@restatedev/restate-sdk-core";
|
|
2
4
|
|
|
3
5
|
//#region src/internal.d.ts
|
|
4
6
|
declare namespace internal_d_exports {
|
|
5
|
-
export { ContextInternal };
|
|
7
|
+
export { ContextInternal, InvocationReference, SignalReference, isSuspendedError };
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Internal {@link Context} interface exposing additional features.
|
|
@@ -21,6 +23,188 @@ interface ContextInternal extends Context {
|
|
|
21
23
|
* @experimental
|
|
22
24
|
*/
|
|
23
25
|
isProcessing(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a {@link RestatePromise} that resolves with `undefined` when Restate signals cancellation
|
|
28
|
+
* of the current invocation.
|
|
29
|
+
*
|
|
30
|
+
* This method **MUST** only be used when the handler (or its parent service/endpoint) is configured
|
|
31
|
+
* with `explicitCancellation: true`. Without configuring this option, cancellations are propagated automatically,
|
|
32
|
+
* and this promise will **NEVER** resolve.
|
|
33
|
+
*
|
|
34
|
+
* **Promise reuse:** calling this method multiple times returns the **same** promise instance as long as
|
|
35
|
+
* the current cancellation signal has not yet arrived. Once the promise resolves (cancellation received),
|
|
36
|
+
* later calls return a **new** promise that will resolve on the next cancellation signal.
|
|
37
|
+
*
|
|
38
|
+
* @example Race a long-running side effect against cancellation
|
|
39
|
+
* ```ts
|
|
40
|
+
* const greeter = restate.service({
|
|
41
|
+
* name: "greeter",
|
|
42
|
+
* handlers: {
|
|
43
|
+
* greet: async (ctx: restate.Context, name: string) => {
|
|
44
|
+
* ctxInternal = ctx as restate.internal.ContextInternal;
|
|
45
|
+
* const result = await RestatePromise.race([
|
|
46
|
+
* ctx.run(() => longRunningTask(name)),
|
|
47
|
+
* ctxInternal.cancellation().map(() => { throw new restate.TerminalError("Cancelled") }),
|
|
48
|
+
* ]);
|
|
49
|
+
* return result;
|
|
50
|
+
* },
|
|
51
|
+
* },
|
|
52
|
+
* options: { explicitCancellation: true },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example Use the cancellation promise to create an AbortSignal for ctx.run
|
|
57
|
+
* ```ts
|
|
58
|
+
* const greeter = restate.service({
|
|
59
|
+
* name: "greeter",
|
|
60
|
+
* handlers: {
|
|
61
|
+
* greet: async (ctx: restate.Context, name: string) => {
|
|
62
|
+
* const ctxInternal = ctx as restate.internal.ContextInternal;
|
|
63
|
+
* const controller = new AbortController();
|
|
64
|
+
* const cancellation = ctxInternal.cancellation()
|
|
65
|
+
* .map(() => {
|
|
66
|
+
* controller.abort();
|
|
67
|
+
* throw new restate.TerminalError("Cancelled");
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* return RestatePromise.race([
|
|
71
|
+
* ctx.run(() => fetch(`https://api.example.com/greet/${name}`, { signal: controller.signal })),
|
|
72
|
+
* cancellation,
|
|
73
|
+
* ]);
|
|
74
|
+
* },
|
|
75
|
+
* },
|
|
76
|
+
* options: { explicitCancellation: true },
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example Handle cancellation, perform cleanup, then listen for the next cancellation
|
|
81
|
+
* ```ts
|
|
82
|
+
* const greeter = restate.service({
|
|
83
|
+
* name: "greeter",
|
|
84
|
+
* handlers: {
|
|
85
|
+
* greet: async (ctx: restate.Context, name: string) => {
|
|
86
|
+
* const ctxInternal = ctx as restate.internal.ContextInternal;
|
|
87
|
+
* try {
|
|
88
|
+
* return await RestatePromise.race([
|
|
89
|
+
* ctx.run(() => longRunningTask(name)),
|
|
90
|
+
* ctxInternal.cancellation().map(() => { throw new restate.TerminalError("Cancelled") }),
|
|
91
|
+
* ]);
|
|
92
|
+
* } catch (e) {
|
|
93
|
+
* // Perform cleanup
|
|
94
|
+
* await ctx.run(() => cleanupResources(name));
|
|
95
|
+
*
|
|
96
|
+
* // After cancellation is resolved, ctx.cancellation() returns a fresh promise.
|
|
97
|
+
* // Race cleanup confirmation against the next cancellation signal.
|
|
98
|
+
* await RestatePromise.race([
|
|
99
|
+
* ctx.run(() => confirmCleanup(name)),
|
|
100
|
+
* ctxInternal.cancellation().map(() => { throw new restate.TerminalError("Canceled during cleanup") }),
|
|
101
|
+
* ]);
|
|
102
|
+
* }
|
|
103
|
+
* },
|
|
104
|
+
* },
|
|
105
|
+
* options: { explicitCancellation: true },
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @experimental
|
|
110
|
+
*/
|
|
111
|
+
cancellation(): RestatePromise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Cancel all previous calls made from this handler.
|
|
114
|
+
*
|
|
115
|
+
* This method **MUST** only be used when the handler (or its parent service/endpoint) is configured
|
|
116
|
+
* with `explicitCancellation: true`. Without configuring this option, this operation will always be a no-op.
|
|
117
|
+
*
|
|
118
|
+
* @return the invocation id of the canceled calls.
|
|
119
|
+
* @experimental
|
|
120
|
+
*/
|
|
121
|
+
cancelPreviousCalls(): RestatePromise<InvocationId[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Wait for a named signal to arrive on the current invocation.
|
|
124
|
+
*
|
|
125
|
+
* Signals are identified by name and are scoped to the current invocation.
|
|
126
|
+
* Another handler can send a signal to this invocation using
|
|
127
|
+
* {@link InvocationReference.signal}, specifying this invocation's
|
|
128
|
+
* ID (available via `ctx.request().id`) and the same signal name.
|
|
129
|
+
*
|
|
130
|
+
* @param name the name of the signal to wait for.
|
|
131
|
+
* @param serde optional custom serializer/deserializer for the payload.
|
|
132
|
+
* @returns a {@link RestatePromise} that resolves when the signal arrives.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const ctxInternal = ctx as restate.internal.ContextInternal;
|
|
136
|
+
* const approved = await ctxInternal.signal<boolean>("approved");
|
|
137
|
+
*
|
|
138
|
+
* @experimental
|
|
139
|
+
*/
|
|
140
|
+
signal<T>(name: string, serde?: Serde<T>): RestatePromise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Get a reference to a target invocation, to send signals to it.
|
|
143
|
+
*
|
|
144
|
+
* @param invocationId the invocation ID of the target invocation.
|
|
145
|
+
* @returns an {@link InvocationReference} for the target invocation.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* const ctxInternal = ctx as restate.internal.ContextInternal;
|
|
149
|
+
* const target = ctxInternal.invocation(targetInvocationId);
|
|
150
|
+
* target.signal("approved").resolve(true);
|
|
151
|
+
* target.signal("approved").reject("Request denied");
|
|
152
|
+
*
|
|
153
|
+
* @experimental
|
|
154
|
+
*/
|
|
155
|
+
invocation(invocationId: InvocationId): InvocationReference;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A reference to a target invocation, used to send signals.
|
|
159
|
+
*
|
|
160
|
+
* @experimental
|
|
161
|
+
*/
|
|
162
|
+
interface InvocationReference {
|
|
163
|
+
/**
|
|
164
|
+
* Get a handle to a named signal on the target invocation.
|
|
165
|
+
*
|
|
166
|
+
* @param name the name of the signal.
|
|
167
|
+
* @param serde optional custom serializer/deserializer for the payload.
|
|
168
|
+
* @returns a {@link SignalReference} to resolve or reject the signal.
|
|
169
|
+
*
|
|
170
|
+
* @experimental
|
|
171
|
+
*/
|
|
172
|
+
signal<T>(name: string, serde?: Serde<T>): SignalReference<T>;
|
|
173
|
+
/**
|
|
174
|
+
* Cancel the target invocation.
|
|
175
|
+
*/
|
|
176
|
+
cancel(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Attach to the target invocation and wait for its result.
|
|
179
|
+
*
|
|
180
|
+
* @param serde optional custom serializer/deserializer for the result.
|
|
181
|
+
* @returns a {@link RestatePromise} that resolves with the invocation result.
|
|
182
|
+
*/
|
|
183
|
+
attach<T>(serde?: Serde<T>): RestatePromise<T>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A handle to send a signal value to a target invocation.
|
|
187
|
+
*
|
|
188
|
+
* @experimental
|
|
189
|
+
*/
|
|
190
|
+
interface SignalReference<T> {
|
|
191
|
+
/**
|
|
192
|
+
* Resolve the signal with a value.
|
|
193
|
+
*
|
|
194
|
+
* @param payload the payload to send.
|
|
195
|
+
*
|
|
196
|
+
* @experimental
|
|
197
|
+
*/
|
|
198
|
+
resolve(payload?: T): void;
|
|
199
|
+
/**
|
|
200
|
+
* Reject the signal. The target invocation waiting on this signal will be
|
|
201
|
+
* woken up with a terminal error containing the provided reason.
|
|
202
|
+
*
|
|
203
|
+
* @param reason the reason for rejection, either a string message or a {@link TerminalError}.
|
|
204
|
+
*
|
|
205
|
+
* @experimental
|
|
206
|
+
*/
|
|
207
|
+
reject(reason: string | TerminalError): void;
|
|
24
208
|
}
|
|
25
209
|
//#endregion
|
|
26
210
|
export { internal_d_exports };
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","names":[],"sources":["../src/internal.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.d.ts","names":[],"sources":["../src/internal.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;UAaiB,eAAA,SAAwB;EAAxB;;;;;;;;EA+IU,YAAA,EAAA,EAAA,OAAA;EAAe;;;AAQ1C;;;;;;;;;;AA+BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAtFkB;;;;;;;;;;yBAWO,eAAe;;;;;;;;;;;;;;;;;;;kCAoBN,MAAM,KAAK,eAAe;;;;;;;;;;;;;;;2BAgBjC,eAAe;;;;;;;UAQzB,mBAAA;;;;;;;;;;kCAUiB,MAAM,KAAK,gBAAgB;;;;;;;;;;;oBAazC,MAAM,KAAK,eAAe;;;;;;;UAQ7B;;;;;;;;oBAQG;;;;;;;;;0BAUM"}
|
package/dist/internal.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { __export } from "./_virtual/rolldown_runtime.js";
|
|
2
|
+
import { isSuspendedError } from "./types/errors.js";
|
|
3
|
+
|
|
1
4
|
//#region src/internal.ts
|
|
2
|
-
var internal_exports = {};
|
|
5
|
+
var internal_exports = /* @__PURE__ */ __export({ isSuspendedError: () => isSuspendedError });
|
|
3
6
|
|
|
4
7
|
//#endregion
|
|
5
8
|
export { internal_exports };
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","names":[],"sources":["../src/internal.ts"],"sourcesContent":["import { Context } from \"./context.js\";\n\n/**\n * Internal {@link Context} interface exposing additional features.\n *\n * Please note that this API is to be considered experimental and might change without notice.\n *\n * @experimental\n */\nexport interface ContextInternal extends Context {\n /**\n * Returns true if the handler is in the processing phase.\n * This is the mechanism used by `ctx.console` to distinguish whether we should log or not in replaying/processing.\n *\n * **WARNING**: This method should not be used to influence control flow, as it will **surely** lead to non-determinism errors!\n *\n * @experimental\n */\n isProcessing(): boolean;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"internal.js","names":[],"sources":["../src/internal.ts"],"sourcesContent":["import type { Serde } from \"@restatedev/restate-sdk-core\";\nimport { Context, InvocationId, RestatePromise } from \"./context.js\";\nimport type { TerminalError } from \"./types/errors.js\";\n\nexport { isSuspendedError } from \"./types/errors.js\";\n\n/**\n * Internal {@link Context} interface exposing additional features.\n *\n * Please note that this API is to be considered experimental and might change without notice.\n *\n * @experimental\n */\nexport interface ContextInternal extends Context {\n /**\n * Returns true if the handler is in the processing phase.\n * This is the mechanism used by `ctx.console` to distinguish whether we should log or not in replaying/processing.\n *\n * **WARNING**: This method should not be used to influence control flow, as it will **surely** lead to non-determinism errors!\n *\n * @experimental\n */\n isProcessing(): boolean;\n\n /**\n * Returns a {@link RestatePromise} that resolves with `undefined` when Restate signals cancellation\n * of the current invocation.\n *\n * This method **MUST** only be used when the handler (or its parent service/endpoint) is configured\n * with `explicitCancellation: true`. Without configuring this option, cancellations are propagated automatically,\n * and this promise will **NEVER** resolve.\n *\n * **Promise reuse:** calling this method multiple times returns the **same** promise instance as long as\n * the current cancellation signal has not yet arrived. Once the promise resolves (cancellation received),\n * later calls return a **new** promise that will resolve on the next cancellation signal.\n *\n * @example Race a long-running side effect against cancellation\n * ```ts\n * const greeter = restate.service({\n * name: \"greeter\",\n * handlers: {\n * greet: async (ctx: restate.Context, name: string) => {\n * ctxInternal = ctx as restate.internal.ContextInternal;\n * const result = await RestatePromise.race([\n * ctx.run(() => longRunningTask(name)),\n * ctxInternal.cancellation().map(() => { throw new restate.TerminalError(\"Cancelled\") }),\n * ]);\n * return result;\n * },\n * },\n * options: { explicitCancellation: true },\n * });\n * ```\n *\n * @example Use the cancellation promise to create an AbortSignal for ctx.run\n * ```ts\n * const greeter = restate.service({\n * name: \"greeter\",\n * handlers: {\n * greet: async (ctx: restate.Context, name: string) => {\n * const ctxInternal = ctx as restate.internal.ContextInternal;\n * const controller = new AbortController();\n * const cancellation = ctxInternal.cancellation()\n * .map(() => {\n * controller.abort();\n * throw new restate.TerminalError(\"Cancelled\");\n * });\n *\n * return RestatePromise.race([\n * ctx.run(() => fetch(`https://api.example.com/greet/${name}`, { signal: controller.signal })),\n * cancellation,\n * ]);\n * },\n * },\n * options: { explicitCancellation: true },\n * });\n * ```\n *\n * @example Handle cancellation, perform cleanup, then listen for the next cancellation\n * ```ts\n * const greeter = restate.service({\n * name: \"greeter\",\n * handlers: {\n * greet: async (ctx: restate.Context, name: string) => {\n * const ctxInternal = ctx as restate.internal.ContextInternal;\n * try {\n * return await RestatePromise.race([\n * ctx.run(() => longRunningTask(name)),\n * ctxInternal.cancellation().map(() => { throw new restate.TerminalError(\"Cancelled\") }),\n * ]);\n * } catch (e) {\n * // Perform cleanup\n * await ctx.run(() => cleanupResources(name));\n *\n * // After cancellation is resolved, ctx.cancellation() returns a fresh promise.\n * // Race cleanup confirmation against the next cancellation signal.\n * await RestatePromise.race([\n * ctx.run(() => confirmCleanup(name)),\n * ctxInternal.cancellation().map(() => { throw new restate.TerminalError(\"Canceled during cleanup\") }),\n * ]);\n * }\n * },\n * },\n * options: { explicitCancellation: true },\n * });\n * ```\n *\n * @experimental\n */\n cancellation(): RestatePromise<void>;\n\n /**\n * Cancel all previous calls made from this handler.\n *\n * This method **MUST** only be used when the handler (or its parent service/endpoint) is configured\n * with `explicitCancellation: true`. Without configuring this option, this operation will always be a no-op.\n *\n * @return the invocation id of the canceled calls.\n * @experimental\n */\n cancelPreviousCalls(): RestatePromise<InvocationId[]>;\n\n /**\n * Wait for a named signal to arrive on the current invocation.\n *\n * Signals are identified by name and are scoped to the current invocation.\n * Another handler can send a signal to this invocation using\n * {@link InvocationReference.signal}, specifying this invocation's\n * ID (available via `ctx.request().id`) and the same signal name.\n *\n * @param name the name of the signal to wait for.\n * @param serde optional custom serializer/deserializer for the payload.\n * @returns a {@link RestatePromise} that resolves when the signal arrives.\n *\n * @example\n * const ctxInternal = ctx as restate.internal.ContextInternal;\n * const approved = await ctxInternal.signal<boolean>(\"approved\");\n *\n * @experimental\n */\n signal<T>(name: string, serde?: Serde<T>): RestatePromise<T>;\n\n /**\n * Get a reference to a target invocation, to send signals to it.\n *\n * @param invocationId the invocation ID of the target invocation.\n * @returns an {@link InvocationReference} for the target invocation.\n *\n * @example\n * const ctxInternal = ctx as restate.internal.ContextInternal;\n * const target = ctxInternal.invocation(targetInvocationId);\n * target.signal(\"approved\").resolve(true);\n * target.signal(\"approved\").reject(\"Request denied\");\n *\n * @experimental\n */\n invocation(invocationId: InvocationId): InvocationReference;\n}\n\n/**\n * A reference to a target invocation, used to send signals.\n *\n * @experimental\n */\nexport interface InvocationReference {\n /**\n * Get a handle to a named signal on the target invocation.\n *\n * @param name the name of the signal.\n * @param serde optional custom serializer/deserializer for the payload.\n * @returns a {@link SignalReference} to resolve or reject the signal.\n *\n * @experimental\n */\n signal<T>(name: string, serde?: Serde<T>): SignalReference<T>;\n\n /**\n * Cancel the target invocation.\n */\n cancel(): void;\n\n /**\n * Attach to the target invocation and wait for its result.\n *\n * @param serde optional custom serializer/deserializer for the result.\n * @returns a {@link RestatePromise} that resolves with the invocation result.\n */\n attach<T>(serde?: Serde<T>): RestatePromise<T>;\n}\n\n/**\n * A handle to send a signal value to a target invocation.\n *\n * @experimental\n */\nexport interface SignalReference<T> {\n /**\n * Resolve the signal with a value.\n *\n * @param payload the payload to send.\n *\n * @experimental\n */\n resolve(payload?: T): void;\n\n /**\n * Reject the signal. The target invocation waiting on this signal will be\n * woken up with a terminal error containing the provided reason.\n *\n * @param reason the reason for rejection, either a string message or a {@link TerminalError}.\n *\n * @experimental\n */\n reject(reason: string | TerminalError): void;\n}\n"],"mappings":""}
|
package/dist/io.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./endpoint/handlers/types.cjs";
|
package/dist/io.d.ts
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { InputReader, OutputWriter } from "./endpoint/handlers/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Adapter between input stream and vm. It moves forward when [awaitNextProgress] is invoked.
|
|
5
|
-
*/
|
|
6
|
-
export declare class InputPump {
|
|
7
|
-
private readonly coreVm;
|
|
8
|
-
private readonly inputReader;
|
|
9
|
-
private readonly errorCallback;
|
|
10
|
-
private currentRead?;
|
|
11
|
-
constructor(coreVm: vm.WasmVM, inputReader: InputReader, errorCallback: (e: any) => void);
|
|
12
|
-
awaitNextProgress(): Promise<void>;
|
|
13
|
-
private readNext;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Adapter between output stream and vm. It moves forward when [awaitNextProgress] is invoked.
|
|
17
|
-
*/
|
|
18
|
-
export declare class OutputPump {
|
|
19
|
-
private readonly coreVm;
|
|
20
|
-
private readonly outputWriter;
|
|
21
|
-
constructor(coreVm: vm.WasmVM, outputWriter: OutputWriter);
|
|
22
|
-
awaitNextProgress(): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=io.d.ts.map
|
|
1
|
+
import "./endpoint/handlers/types.js";
|
package/dist/lambda.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
|
const require_common_api = require('./common_api.cjs');
|
|
7
8
|
const require_withOptions = require('./endpoint/withOptions.cjs');
|
|
@@ -64,6 +65,7 @@ Object.defineProperty(exports, 'internal', {
|
|
|
64
65
|
return require_internal.internal_exports;
|
|
65
66
|
}
|
|
66
67
|
});
|
|
68
|
+
exports.isRestatePromise = require_promises.isRestatePromise;
|
|
67
69
|
exports.object = require_rpc.object;
|
|
68
70
|
Object.defineProperty(exports, 'rpc', {
|
|
69
71
|
enumerable: true,
|
package/dist/lambda.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 { 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.cjs";
|
|
9
11
|
import { LambdaEndpoint } from "./endpoint/lambda_endpoint.cjs";
|
|
10
12
|
|
|
@@ -29,5 +31,5 @@ declare function endpoint(): LambdaEndpoint;
|
|
|
29
31
|
*/
|
|
30
32
|
declare function createEndpointHandler(options: EndpointOptions): (event: any, ctx: any) => Promise<any>;
|
|
31
33
|
//#endregion
|
|
32
|
-
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, InferArg, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, 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,
|
|
34
|
+
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, 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, 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 };
|
|
33
35
|
//# sourceMappingURL=lambda.d.cts.map
|
package/dist/lambda.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda.d.cts","names":[],"sources":["../src/lambda.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambda.d.cts","names":[],"sources":["../src/lambda.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;iBAwBgB,QAAA,CAAA,GAAY;;;;;;AAA5B;AAiBA;;;;;;;iBAAgB,qBAAA,UAA+B,4CAAe"}
|
package/dist/lambda.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 { 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";
|
|
9
11
|
import { LambdaEndpoint } from "./endpoint/lambda_endpoint.js";
|
|
10
12
|
|
|
@@ -29,5 +31,5 @@ declare function endpoint(): LambdaEndpoint;
|
|
|
29
31
|
*/
|
|
30
32
|
declare function createEndpointHandler(options: EndpointOptions): (event: any, ctx: any) => Promise<any>;
|
|
31
33
|
//#endregion
|
|
32
|
-
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, InferArg, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, 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,
|
|
34
|
+
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, 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, 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 };
|
|
33
35
|
//# sourceMappingURL=lambda.d.ts.map
|
package/dist/lambda.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda.d.ts","names":[],"sources":["../src/lambda.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambda.d.ts","names":[],"sources":["../src/lambda.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;iBAwBgB,QAAA,CAAA,GAAY;;;;;;AAA5B;AAiBA;;;;;;;iBAAgB,qBAAA,UAA+B,4CAAe"}
|
package/dist/lambda.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";
|
|
@@ -32,5 +33,5 @@ function createEndpointHandler(options) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
//#endregion
|
|
35
|
-
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, service, workflow };
|
|
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
37
|
//# sourceMappingURL=lambda.js.map
|
package/dist/lambda.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda.js","names":[],"sources":["../src/lambda.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\";\n\nimport {\n LambdaEndpointImpl,\n type LambdaEndpoint,\n} from \"./endpoint/lambda_endpoint.js\";\nimport type { EndpointOptions } from \"./endpoint/types.js\";\nimport { withOptions } from \"./endpoint/withOptions.js\";\n\n/**\n * Create a new {@link LambdaEndpoint}.\n * @deprecated Please use {@link createEndpointHandler}\n */\nexport function endpoint(): LambdaEndpoint {\n return new LambdaEndpointImpl();\n}\n\n/**\n * Creates a Lambda handler that encapsulates all the Restate services served by this endpoint.\n *\n * @param {EndpointOptions} options - Configuration options for the endpoint handler.\n * @returns A Lambda handler function.\n *\n * @example\n * A typical endpoint served as Lambda would look like this:\n * ```\n * import { createEndpointHandler } from \"@restatedev/restate-sdk/lambda\";\n *\n * export const handler = createEndpointHandler({ services: [myService] })\n */\nexport function createEndpointHandler(options: EndpointOptions) {\n return withOptions<LambdaEndpoint>(\n new LambdaEndpointImpl(),\n options\n ).handler();\n}\nexport { type LambdaEndpoint } from \"./endpoint/lambda_endpoint.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambda.js","names":[],"sources":["../src/lambda.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\";\n\nimport {\n LambdaEndpointImpl,\n type LambdaEndpoint,\n} from \"./endpoint/lambda_endpoint.js\";\nimport type { EndpointOptions } from \"./endpoint/types.js\";\nimport { withOptions } from \"./endpoint/withOptions.js\";\n\n/**\n * Create a new {@link LambdaEndpoint}.\n * @deprecated Please use {@link createEndpointHandler}\n */\nexport function endpoint(): LambdaEndpoint {\n return new LambdaEndpointImpl();\n}\n\n/**\n * Creates a Lambda handler that encapsulates all the Restate services served by this endpoint.\n *\n * @param {EndpointOptions} options - Configuration options for the endpoint handler.\n * @returns A Lambda handler function.\n *\n * @example\n * A typical endpoint served as Lambda would look like this:\n * ```\n * import { createEndpointHandler } from \"@restatedev/restate-sdk/lambda\";\n *\n * export const handler = createEndpointHandler({ services: [myService] })\n */\nexport function createEndpointHandler(options: EndpointOptions) {\n return withOptions<LambdaEndpoint>(\n new LambdaEndpointImpl(),\n options\n ).handler();\n}\nexport { type LambdaEndpoint } from \"./endpoint/lambda_endpoint.js\";\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,WAA2B;AACzC,QAAO,IAAI,oBAAoB;;;;;;;;;;;;;;;AAgBjC,SAAgB,sBAAsB,SAA0B;AAC9D,QAAO,YACL,IAAI,oBAAoB,EACxB,QACD,CAAC,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./logger_transport.cjs";
|
package/dist/logging/logger.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RestateLogLevel } from "./logger_transport.js";
|
|
3
|
-
/**
|
|
4
|
-
* Logging facade used internally by the Restate SDK.
|
|
5
|
-
*/
|
|
6
|
-
export interface Logger extends Console {
|
|
7
|
-
logForLevel(level: RestateLogLevel, message?: any, ...optionalParams: any[]): void;
|
|
8
|
-
}
|
|
9
|
-
export declare function createLogger(loggerTransport: LoggerTransport, source: LogSource, context?: LoggerContext, isReplaying?: () => boolean): Logger;
|
|
10
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
1
|
+
import "./logger_transport.js";
|
package/dist/node.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
|
const require_common_api = require('./common_api.cjs');
|
|
7
8
|
const require_withOptions = require('./endpoint/withOptions.cjs');
|
|
@@ -18,18 +19,33 @@ function endpoint() {
|
|
|
18
19
|
return new require_node_endpoint.NodeEndpoint();
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
|
-
* Creates
|
|
22
|
+
* Creates a request handler for the provided services.
|
|
23
|
+
*
|
|
24
|
+
* The returned handler auto-detects the HTTP protocol version per request:
|
|
25
|
+
* - HTTP/2+ requests use bidirectional streaming (`BIDI_STREAM`)
|
|
26
|
+
* - HTTP/1.1 requests use request-response mode (`REQUEST_RESPONSE`) by default
|
|
22
27
|
*
|
|
23
|
-
*
|
|
28
|
+
* Set `bidirectional: true` to force `BIDI_STREAM` for all requests, or
|
|
29
|
+
* `bidirectional: false` to force `REQUEST_RESPONSE` for all requests.
|
|
30
|
+
*
|
|
31
|
+
* @example HTTP/2 server
|
|
24
32
|
* ```
|
|
25
33
|
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
|
|
26
34
|
* httpServer.listen(port);
|
|
27
35
|
* ```
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
36
|
+
*
|
|
37
|
+
* @example HTTP/1.1 server
|
|
38
|
+
* ```
|
|
39
|
+
* const httpServer = http.createServer(createEndpointHandler({ services: [myService] }));
|
|
40
|
+
* httpServer.listen(port);
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param {NodeEndpointOptions} options - Configuration options for the endpoint handler.
|
|
44
|
+
* @returns A request handler function compatible with both HTTP/1.1 and HTTP/2 servers.
|
|
30
45
|
*/
|
|
31
46
|
function createEndpointHandler(options) {
|
|
32
|
-
|
|
47
|
+
const { bidirectional,...endpointOptions } = options;
|
|
48
|
+
return require_withOptions.withOptions(new require_node_endpoint.NodeEndpoint(), endpointOptions).handler({ bidirectional });
|
|
33
49
|
}
|
|
34
50
|
/**
|
|
35
51
|
* Serves this Restate services as HTTP2 server, listening to the given port.
|
|
@@ -79,6 +95,7 @@ Object.defineProperty(exports, 'internal', {
|
|
|
79
95
|
return require_internal.internal_exports;
|
|
80
96
|
}
|
|
81
97
|
});
|
|
98
|
+
exports.isRestatePromise = require_promises.isRestatePromise;
|
|
82
99
|
exports.object = require_rpc.object;
|
|
83
100
|
Object.defineProperty(exports, 'rpc', {
|
|
84
101
|
enumerable: true,
|
package/dist/node.d.cts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
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 { 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.cjs";
|
|
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.cts.map
|
package/dist/node.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.cts","names":[],"sources":["../src/node.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.cts","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"}
|