@restatedev/restate-sdk-gen 0.0.0 → 1.14.3

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.
@@ -0,0 +1,1020 @@
1
+ import * as restate from "@restatedev/restate-sdk";
2
+ import { ContextDate, InvocationId, Opts, Rand, SendOpts, Target as Target$1 } from "@restatedev/restate-sdk";
3
+
4
+ //#region src/operation.d.ts
5
+ interface Operation<T> {
6
+ [Symbol.iterator](): Iterator<unknown, T, unknown>;
7
+ }
8
+ declare function gen<T>(body: () => Generator<unknown, T, unknown>): Operation<T>;
9
+ type SelectResult<B extends Record<string, Future<unknown>>> = { [K in keyof B]: {
10
+ tag: K;
11
+ future: B[K];
12
+ } }[keyof B];
13
+ declare function select<B extends Record<string, Future<unknown>>>(branches: B): Generator<unknown, SelectResult<B>, unknown>;
14
+ //#endregion
15
+ //#region src/future.d.ts
16
+ declare const futureBrand: unique symbol;
17
+ interface Future<T> extends Operation<T> {
18
+ readonly [futureBrand]: unknown;
19
+ }
20
+ /** Extract the value type from a `Future<U>`; `never` for non-Futures. */
21
+ type FutureValue<F> = F extends Future<infer U> ? U : never;
22
+ /**
23
+ * Map a tuple of Futures to the tuple of their value types.
24
+ * For `[Future<A>, Future<B>]` produces `[A, B]`.
25
+ * For an unbounded `Future<X>[]` produces `X[]`.
26
+ */
27
+ type FutureValues<T extends readonly Future<unknown>[] | []> = { -readonly [P in keyof T]: T[P] extends Future<infer U> ? U : never };
28
+ interface FutureFulfilledResult<T> {
29
+ readonly status: "fulfilled";
30
+ readonly value: T;
31
+ }
32
+ interface FutureRejectedResult {
33
+ readonly status: "rejected";
34
+ readonly reason: unknown;
35
+ }
36
+ type FutureSettledResult<T> = FutureFulfilledResult<T> | FutureRejectedResult;
37
+ //#endregion
38
+ //#region src/channel.d.ts
39
+ interface Channel<T> {
40
+ /**
41
+ * Yieldable. Use as `yield* ch.send(value)` from within a gen body.
42
+ * The first call settles the channel; subsequent calls are silently
43
+ * dropped (idempotent).
44
+ *
45
+ * Return value is `Operation<void>` rather than `void` so the only
46
+ * way to fire send is via `yield*` inside a fiber — which enforces
47
+ * the channel-is-intra-workflow contract at the type level.
48
+ */
49
+ send(value: T): Operation<void>;
50
+ readonly receive: Future<T>;
51
+ }
52
+ //#endregion
53
+ //#region src/invocation-reference.d.ts
54
+ /** Synchronous handle for resolving or rejecting a signal on a target invocation */
55
+ interface SignalReference<T> {
56
+ resolve(payload?: T): void;
57
+ reject(reason: string | restate.TerminalError): void;
58
+ }
59
+ /**
60
+ * A typed reference to a running invocation. Returned by `sendClient()` methods
61
+ * (wrapped in `Future<InvocationReference<O>>`), or created via `invocation(id)`.
62
+ *
63
+ * - `attach()` returns a `Future<O>` with the serde from the original descriptor.
64
+ * - `signal()` sends a named signal to the target invocation.
65
+ * - `cancel()` cancels the target invocation.
66
+ */
67
+ interface InvocationReference<O$1 = unknown> {
68
+ readonly id: string;
69
+ attach(serde?: restate.Serde<O$1>): Future<O$1>;
70
+ signal<T = unknown>(name: string, serde?: restate.Serde<T>): SignalReference<T>;
71
+ cancel(): void;
72
+ }
73
+ //#endregion
74
+ //#region ../restate-sdk-core/src/core.d.ts
75
+ type ServiceDefinition<P$1 extends string, M> = {
76
+ name: P$1;
77
+ };
78
+ type Service<M> = M extends ServiceDefinition<string, infer S> ? S : M;
79
+ type ServiceDefinitionFrom<M> = M extends ServiceDefinition<string, unknown> ? M : ServiceDefinition<string, M>;
80
+ type VirtualObjectDefinition<P$1 extends string, M> = {
81
+ name: P$1;
82
+ };
83
+ type VirtualObject<M> = M extends VirtualObjectDefinition<string, infer O> ? O : M;
84
+ type VirtualObjectDefinitionFrom<M> = M extends VirtualObjectDefinition<string, unknown> ? M : VirtualObjectDefinition<string, M>;
85
+ type WorkflowDefinition<P$1 extends string, M> = {
86
+ name: P$1;
87
+ };
88
+ type Workflow<M> = M extends WorkflowDefinition<string, infer W> ? W : M;
89
+ type WorkflowDefinitionFrom<M> = M extends WorkflowDefinition<string, unknown> ? M : WorkflowDefinition<string, M>;
90
+ //#endregion
91
+ //#region ../restate-sdk-core/src/standard_schema.d.ts
92
+ /**
93
+ * This file is copy pasted as is from https://standardschema.dev/
94
+ */
95
+ /** The Standard Typed interface. This is a base type extended by other specs. */
96
+ interface StandardTypedV1<Input = unknown, Output$1 = Input> {
97
+ /** The Standard properties. */
98
+ readonly "~standard": StandardTypedV1.Props<Input, Output$1>;
99
+ }
100
+ declare namespace StandardTypedV1 {
101
+ /** The Standard Typed properties interface. */
102
+ interface Props<Input = unknown, Output$1 = Input> {
103
+ /** The version number of the standard. */
104
+ readonly version: 1;
105
+ /** The vendor name of the schema library. */
106
+ readonly vendor: string;
107
+ /** Inferred types associated with the schema. */
108
+ readonly types?: Types<Input, Output$1> | undefined;
109
+ }
110
+ /** The Standard Typed types interface. */
111
+ interface Types<Input = unknown, Output$1 = Input> {
112
+ /** The input type of the schema. */
113
+ readonly input: Input;
114
+ /** The output type of the schema. */
115
+ readonly output: Output$1;
116
+ }
117
+ /** Infers the input type of a Standard Typed. */
118
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
119
+ /** Infers the output type of a Standard Typed. */
120
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
121
+ }
122
+ /** The Standard Schema interface. */
123
+ interface StandardSchemaV1<Input = unknown, Output$1 = Input> {
124
+ /** The Standard Schema properties. */
125
+ readonly "~standard": StandardSchemaV1.Props<Input, Output$1>;
126
+ }
127
+ declare namespace StandardSchemaV1 {
128
+ /** The Standard Schema properties interface. */
129
+ interface Props<Input = unknown, Output$1 = Input> extends StandardTypedV1.Props<Input, Output$1> {
130
+ /** Validates unknown input values. */
131
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output$1> | Promise<Result<Output$1>>;
132
+ }
133
+ /** The result interface of the validate function. */
134
+ type Result<Output$1> = SuccessResult<Output$1> | FailureResult;
135
+ /** The result interface if validation succeeds. */
136
+ interface SuccessResult<Output$1> {
137
+ /** The typed output value. */
138
+ readonly value: Output$1;
139
+ /** A falsy value for `issues` indicates success. */
140
+ readonly issues?: undefined;
141
+ }
142
+ interface Options {
143
+ /** Explicit support for additional vendor-specific parameters, if needed. */
144
+ readonly libraryOptions?: Record<string, unknown> | undefined;
145
+ }
146
+ /** The result interface if validation fails. */
147
+ interface FailureResult {
148
+ /** The issues of failed validation. */
149
+ readonly issues: ReadonlyArray<Issue>;
150
+ }
151
+ /** The issue interface of the failure output. */
152
+ interface Issue {
153
+ /** The error message of the issue. */
154
+ readonly message: string;
155
+ /** The path of the issue, if any. */
156
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
157
+ }
158
+ /** The path segment interface of the issue. */
159
+ interface PathSegment {
160
+ /** The key representing a path segment. */
161
+ readonly key: PropertyKey;
162
+ }
163
+ /** The Standard types interface. */
164
+ interface Types<Input = unknown, Output$1 = Input> extends StandardTypedV1.Types<Input, Output$1> {}
165
+ /** Infers the input type of a Standard. */
166
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
167
+ /** Infers the output type of a Standard. */
168
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
169
+ }
170
+ //#endregion
171
+ //#region ../restate-sdk-core/src/serde_api.d.ts
172
+ /**
173
+ * Serializer/deserializer pair for any Restate-managed value of type `T` —
174
+ * handler inputs and outputs, service state, side-effect results,
175
+ * awakeables, durable promises, and so on.
176
+ *
177
+ * A `Serde<T>` is responsible for two conversions:
178
+ *
179
+ * - **Wire format**: `serialize` / `deserialize` convert a value `T` to and
180
+ * from the raw bytes that flow over the network and get stored in the
181
+ * journal.
182
+ * - **JSON preview (optional)**: `preview.toJsonString` /
183
+ * `preview.fromJsonString` convert a value `T` to and from a JSON string,
184
+ * used by tooling to render and edit values that humans can read.
185
+ *
186
+ * It also advertises metadata (`contentType`, `jsonSchema`) that surfaces in
187
+ * service discovery.
188
+ */
189
+ interface Serde<T> {
190
+ /**
191
+ * MIME type of the bytes produced by `serialize` (and accepted by
192
+ * `deserialize`).
193
+ */
194
+ contentType?: string;
195
+ /**
196
+ * Optional JSON Schema describing the logical shape of `T`. Surfaced in
197
+ * discovery so that tooling can generate forms, auto-complete payloads,
198
+ * etc. Has no effect on serialization at runtime.
199
+ */
200
+ jsonSchema?: object;
201
+ /**
202
+ * Optional bridge between the serde's wire format and a JSON
203
+ * representation that humans (and tooling like the Restate UI) can read
204
+ * and edit.
205
+ *
206
+ * Only useful for serdes whose wire format isn't already plain JSON —
207
+ * protobuf, MessagePack, length-prefixed binary, JSON variants that need
208
+ * post-processing for bigints/dates, etc. Both methods may be async if the
209
+ * conversion needs I/O.
210
+ *
211
+ * ### Preview flow
212
+ *
213
+ * Together with `serialize` / `deserialize`, the four functions chain in
214
+ * both directions between a JSON string and on-the-wire bytes:
215
+ *
216
+ * ```text
217
+ * JSON string ──fromJsonString──► T ──serialize──► wire bytes
218
+ * wire bytes ──deserialize────► T ──toJsonString──► JSON string
219
+ * ```
220
+ *
221
+ * The split keeps `serialize` / `deserialize` responsible for the full
222
+ * on-the-wire format; `preview` only handles the JSON ↔ `T` bridge.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * // Wire format is protobuf; the protobuf-es runtime already ships
227
+ * // `toJsonString` / `fromJsonString`, so preview is a direct pass-through.
228
+ * import {
229
+ * fromBinary,
230
+ * fromJsonString,
231
+ * toBinary,
232
+ * toJsonString,
233
+ * } from "@bufbuild/protobuf";
234
+ * import { PersonSchema, type Person } from "./person_pb.js";
235
+ *
236
+ * const personSerde: Serde<Person> = {
237
+ * contentType: "application/protobuf",
238
+ * serialize(message) { return toBinary(PersonSchema, message); },
239
+ * deserialize(bytes) { return fromBinary(PersonSchema, bytes); },
240
+ * preview: {
241
+ * toJsonString: (v) => toJsonString(PersonSchema, v),
242
+ * fromJsonString: (j) => fromJsonString(PersonSchema, j),
243
+ * },
244
+ * };
245
+ * ```
246
+ */
247
+ preview?: {
248
+ /**
249
+ * Convert a value into a JSON string for display or editing by humans.
250
+ * The returned string must round-trip through `fromJsonString` back to
251
+ * the same logical value.
252
+ */
253
+ toJsonString(value: T): Promise<string> | string;
254
+ /**
255
+ * Parse a human-supplied JSON string back into a value of type `T`.
256
+ * Should throw (or reject) if `json` is invalid for this serde.
257
+ */
258
+ fromJsonString(json: string): Promise<T> | T;
259
+ };
260
+ /**
261
+ * Convert a value of type `T` into its on-the-wire bytes. This is the
262
+ * format Restate sends between services and persists in the journal.
263
+ *
264
+ * Must be the inverse of `deserialize` — `deserialize(serialize(v))`
265
+ * should produce a value equivalent to `v`.
266
+ */
267
+ serialize(value: T): Uint8Array;
268
+ /**
269
+ * Convert on-the-wire bytes back into a value of type `T`. Must be the
270
+ * inverse of `serialize`.
271
+ *
272
+ * May throw if `data` doesn't conform to the expected wire format.
273
+ */
274
+ deserialize(data: Uint8Array): T;
275
+ }
276
+ declare namespace serde {
277
+ class JsonSerde<T> implements Serde<T | undefined> {
278
+ readonly jsonSchema?: object | undefined;
279
+ contentType: string;
280
+ constructor(jsonSchema?: object | undefined);
281
+ serialize(value: T): Uint8Array;
282
+ deserialize(data: Uint8Array): T | undefined;
283
+ schema<U$1>(schema: object): Serde<U$1>;
284
+ }
285
+ const json: JsonSerde<any>;
286
+ const binary: Serde<Uint8Array>;
287
+ const empty: Serde<void>;
288
+ /**
289
+ * A Standard Schema-based serde.
290
+ *
291
+ * @param schema the standard schema
292
+ * @param validateOptions options passed to `StandardSchemaV1.Options.libraryOptions` when validating
293
+ * @param jsonSchemaOptions options passed to `StandardJsonSchemaV1.Options.libraryOptions` for code generation
294
+ * @returns a serde that will validate the data with the standard schema
295
+ */
296
+ const schema: <T extends {
297
+ "~standard": StandardSchemaV1.Props;
298
+ }>(schema: T, validateOptions?: Record<string, unknown>, jsonSchemaOptions?: Record<string, unknown>) => Serde<StandardSchemaV1.InferOutput<T>>;
299
+ }
300
+ //#endregion
301
+ //#region ../restate-sdk-core/src/duration.d.ts
302
+ /**
303
+ * Duration type. Note that fields are additive.
304
+ */
305
+ type Duration = {
306
+ days?: number;
307
+ hours?: number;
308
+ minutes?: number;
309
+ seconds?: number;
310
+ milliseconds?: number;
311
+ };
312
+ //#endregion
313
+ //#region ../restate-sdk-core/src/entry_codec.d.ts
314
+ /**
315
+ * Journal values codec.
316
+ *
317
+ * This allows to transform journal values after being serialized, before writing them to the wire.
318
+ *
319
+ * Values that are passed through the codec:
320
+ *
321
+ * * Handlers input and success output
322
+ * * ctx.run success results
323
+ * * Awakeables/Promise success results
324
+ * * State values
325
+ *
326
+ * @experimental
327
+ */
328
+ type JournalValueCodec = {
329
+ /**
330
+ * Encodes the given buffer.
331
+ *
332
+ * This will be applied *after* serialization.
333
+ *
334
+ * @param buf The buffer to encode. Empty byte buffers should be appropriately handled as well.
335
+ * @returns The encoded buffer
336
+ */
337
+ encode(buf: Uint8Array): Uint8Array;
338
+ /**
339
+ * Decodes the given buffer.
340
+ *
341
+ * This will be applied *before* deserialization.
342
+ *
343
+ * @param buf The buffer to decode.
344
+ * @returns A promise that resolves to the decoded buffer.
345
+ */
346
+ decode(buf: Uint8Array): Promise<Uint8Array>;
347
+ };
348
+ //#endregion
349
+ //#region src/define.d.ts
350
+ /**
351
+ * Minimal descriptor stored in Descriptor._handlers per handler.
352
+ */
353
+ type HandlerDescriptor<I$1 = any, O$1 = any> = {
354
+ readonly _inputSerde?: restate.Serde<I$1>;
355
+ readonly _outputSerde?: restate.Serde<O$1>;
356
+ };
357
+ /**
358
+ * The single client-facing type for all definition styles.
359
+ * - Returned by service() / object() / workflow() (also bindable to serve())
360
+ * - Returned by restate.interface.service/object/workflow (pure, not bindable)
361
+ * - Returned by implement() (also bindable)
362
+ */
363
+ type Descriptor<P$1 extends string = string, H extends Record<string, HandlerDescriptor> = Record<string, HandlerDescriptor>, Kind extends "service" | "object" | "workflow" = "service" | "object" | "workflow"> = {
364
+ readonly name: P$1;
365
+ readonly _kind: Kind;
366
+ readonly _handlers: H;
367
+ };
368
+ /** Kind-specific aliases for the common Descriptor type */
369
+ type ServiceDescriptor<P$1 extends string = string, H extends Record<string, HandlerDescriptor> = Record<string, HandlerDescriptor>> = Descriptor<P$1, H, "service">;
370
+ type ObjectDescriptor<P$1 extends string = string, H extends Record<string, HandlerDescriptor> = Record<string, HandlerDescriptor>> = Descriptor<P$1, H, "object">;
371
+ type WorkflowDescriptor<P$1 extends string = string, H extends Record<string, HandlerDescriptor> = Record<string, HandlerDescriptor>> = Descriptor<P$1, H, "workflow">;
372
+ /** Implemented definition — extends Descriptor and also bindable to serve() */
373
+ type ImplementedServiceDefinition<P$1 extends string, H extends Record<string, HandlerDescriptor>> = restate.ServiceDefinition<P$1, any> & ServiceDescriptor<P$1, H>;
374
+ type ImplementedObjectDefinition<P$1 extends string, H extends Record<string, HandlerDescriptor>> = restate.VirtualObjectDefinition<P$1, any> & ObjectDescriptor<P$1, H>;
375
+ type ImplementedWorkflowDefinition<P$1 extends string, H extends Record<string, HandlerDescriptor>> = restate.WorkflowDefinition<P$1, any> & WorkflowDescriptor<P$1, H>;
376
+ type ImplementedDefinition<P$1 extends string, H extends Record<string, HandlerDescriptor>, Kind extends "service" | "object" | "workflow"> = Kind extends "service" ? ImplementedServiceDefinition<P$1, H> : Kind extends "object" ? ImplementedObjectDefinition<P$1, H> : ImplementedWorkflowDefinition<P$1, H>;
377
+ /** @internal
378
+ * @internal - Wraps a generator function with optional serde. Produced by typed().
379
+ * Discriminated by _genFn for runtime detection (distinct from bare gen fns,
380
+ * which are plain functions rather than objects).
381
+ */
382
+ type HandlerDef<I$1 = any, O$1 = any> = {
383
+ readonly _genFn: (input: I$1) => Operation<O$1>;
384
+ } & HandlerDescriptor<I$1, O$1>;
385
+ /** @internal */
386
+ type EntryToDescriptor<E> = E extends HandlerDef<infer I, infer O> ? HandlerDescriptor<I, O> : E extends (() => Operation<infer O>) ? HandlerDescriptor<void, O> : E extends ((input: infer I) => Operation<infer O>) ? HandlerDescriptor<I, O> : HandlerDescriptor;
387
+ /** Map a full handler map type to the corresponding descriptor map type */
388
+ type HandlerDescriptors<H extends Record<string, HandlerOrHandlerDescriptor>> = { [K in keyof H]: EntryToDescriptor<H[K]> };
389
+ /** Options valid for all handler types (no serde — those live in typed()) */
390
+ type GenHandlerOpts = {
391
+ idempotencyRetention?: restate.Duration | number;
392
+ journalRetention?: restate.Duration | number;
393
+ inactivityTimeout?: restate.Duration | number;
394
+ abortTimeout?: restate.Duration | number;
395
+ retryPolicy?: restate.RetryPolicy;
396
+ description?: string;
397
+ metadata?: Record<string, string>;
398
+ ingressPrivate?: boolean;
399
+ explicitCancellation?: boolean;
400
+ };
401
+ /** Handler options for virtual object handlers */
402
+ type GenObjectHandlerOpts = GenHandlerOpts & {
403
+ shared?: boolean;
404
+ enableLazyState?: boolean;
405
+ };
406
+ /** Handler options for workflow handlers (shared is implicit from name) */
407
+ type GenWorkflowHandlerOpts = {
408
+ enableLazyState?: boolean;
409
+ };
410
+ /** @internal */
411
+ type AnyGenFn = (input: any) => Operation<any>;
412
+ /** A handler entry: either a bare generator fn or the result of typed() */
413
+ type HandlerOrHandlerDescriptor = AnyGenFn | HandlerDef<any, any>;
414
+ /** serdes(opts, fn) — explicit Serde per field */
415
+ declare function serdes<I$1, O$1>(opts: {
416
+ input: restate.Serde<I$1>;
417
+ output: restate.Serde<O$1>;
418
+ }, fn: (input: I$1) => Operation<O$1>): HandlerDef<I$1, O$1>;
419
+ /** schemas(opts, fn) — Standard Schema (Zod, TypeBox, Valibot, …) per field */
420
+ declare function schemas<SI extends StandardSchemaV1<any>, SO extends StandardSchemaV1<any>>(opts: {
421
+ input: SI;
422
+ output: SO;
423
+ }, fn: (input: StandardSchemaV1.InferOutput<SI>) => Operation<StandardSchemaV1.InferOutput<SO>>): HandlerDef<StandardSchemaV1.InferOutput<SI>, StandardSchemaV1.InferOutput<SO>>;
424
+ declare function service<P$1 extends string, H extends Record<string, HandlerOrHandlerDescriptor>>(config: {
425
+ name: P$1;
426
+ description?: string;
427
+ metadata?: Record<string, string>;
428
+ handlers: H;
429
+ options?: restate.ServiceOptions & {
430
+ handlers?: Partial<Record<keyof H, GenHandlerOpts>>;
431
+ };
432
+ }): ImplementedServiceDefinition<P$1, HandlerDescriptors<H>>;
433
+ declare function object<P$1 extends string, H extends Record<string, HandlerOrHandlerDescriptor>>(config: {
434
+ name: P$1;
435
+ description?: string;
436
+ metadata?: Record<string, string>;
437
+ handlers: H;
438
+ options?: restate.ObjectOptions & {
439
+ handlers?: Partial<Record<keyof H, GenObjectHandlerOpts>>;
440
+ };
441
+ }): ImplementedObjectDefinition<P$1, HandlerDescriptors<H>>;
442
+ declare function workflow<P$1 extends string, H extends Record<string, HandlerOrHandlerDescriptor>>(config: {
443
+ name: P$1;
444
+ description?: string;
445
+ metadata?: Record<string, string>;
446
+ handlers: H;
447
+ options?: restate.WorkflowOptions & {
448
+ handlers?: Partial<Record<keyof H, GenWorkflowHandlerOpts>>;
449
+ };
450
+ }): ImplementedWorkflowDefinition<P$1, HandlerDescriptors<H>>;
451
+ //#endregion
452
+ //#region src/clients.d.ts
453
+ /**
454
+ * A Future<O> that also carries an `invocation` field — a Future<InvocationReference<O>>
455
+ * for accessing the invocationId, attach, cancel, and signal of the underlying call.
456
+ */
457
+ type ClientFuture<O$1> = Future<O$1> & {
458
+ invocation: Future<InvocationReference<O$1>>;
459
+ };
460
+ /** Client type returned by client() — each method returns ClientFuture<O> */
461
+ type GenClient<H extends Record<string, HandlerDescriptor>> = { readonly [K in keyof H]: H[K] extends HandlerDescriptor<infer I, infer O> ? [I] extends [void] ? (opts?: Opts<I, O>) => ClientFuture<O> : (input: I, opts?: Opts<I, O>) => ClientFuture<O> : never };
462
+ /** Client type returned by sendClient() — each method returns Future<InvocationReference<O>> */
463
+ type GenSendClient<H extends Record<string, HandlerDescriptor>> = { readonly [K in keyof H]: H[K] extends HandlerDescriptor<infer I, infer O> ? [I] extends [void] ? (opts?: SendOpts<I>) => Future<InvocationReference<O>> : (input: I, opts?: SendOpts<I>) => Future<InvocationReference<O>> : never };
464
+ //#endregion
465
+ //#region src/durable-promise.d.ts
466
+ /** Same shape as the SDK's DurablePromise<T> but each method returns Future<...>. */
467
+ type GenDurablePromise<T> = {
468
+ peek(): Future<T | undefined>;
469
+ resolve(value?: T): Future<void>;
470
+ reject(errorMsg: string): Future<void>;
471
+ get(): Future<T>;
472
+ };
473
+ //#endregion
474
+ //#region src/state.d.ts
475
+ /**
476
+ * Marker types matching the SDK's typed-state convention. Pass a
477
+ * concrete shape (e.g. `{count: number; name: string}`) to enable
478
+ * keyof-checked names; leave the default to keep names as `string`
479
+ * with a per-call value generic.
480
+ */
481
+ type TypedState = Record<string, unknown>;
482
+ type UntypedState = {
483
+ _: never;
484
+ };
485
+ /**
486
+ * Read-only state, for handlers running under an
487
+ * ObjectSharedContext or WorkflowSharedContext.
488
+ */
489
+ interface SharedState<TState extends TypedState = UntypedState> {
490
+ /** Read a state value. Returns null if the key isn't set. */
491
+ get<TValue, TKey extends keyof TState = string>(name: TState extends UntypedState ? string : TKey, serde?: restate.Serde<TState extends UntypedState ? TValue : TState[TKey]>): Future<(TState extends UntypedState ? TValue : TState[TKey]) | null>;
492
+ /** List all currently-known state keys. */
493
+ keys(): Future<string[]>;
494
+ }
495
+ /**
496
+ * Read-write state, for handlers running under an ObjectContext or
497
+ * WorkflowContext. Extends SharedState with mutation methods.
498
+ *
499
+ * Writes are synchronous in the SDK — the journal entry is recorded
500
+ * immediately, no yield required — so `set` / `clear` / `clearAll`
501
+ * return `void` rather than `Operation<void>`.
502
+ */
503
+ interface State<TState extends TypedState = UntypedState> extends SharedState<TState> {
504
+ /** Write a state value. Sync; journal entry recorded immediately. */
505
+ set<TValue, TKey extends keyof TState = string>(name: TState extends UntypedState ? string : TKey, value: TState extends UntypedState ? TValue : TState[TKey], serde?: restate.Serde<TState extends UntypedState ? TValue : TState[TKey]>): void;
506
+ /** Clear a single key. */
507
+ clear<TKey extends keyof TState>(name: TState extends UntypedState ? string : TKey): void;
508
+ /** Clear all state for this invocation. */
509
+ clearAll(): void;
510
+ }
511
+ //#endregion
512
+ //#region src/restate-operations.d.ts
513
+ type HandlerRequest = {
514
+ readonly target: Target$1;
515
+ /**
516
+ * The unique id that identifies the current function invocation. This id is guaranteed to be
517
+ * unique across invocations, but constant across reties and suspensions.
518
+ */
519
+ readonly id: InvocationId;
520
+ readonly key?: string;
521
+ /**
522
+ * Request headers - the following headers capture the original invocation headers, as provided to
523
+ * the ingress.
524
+ */
525
+ readonly headers: ReadonlyMap<string, string>;
526
+ /**
527
+ * Attempt headers - the following headers are sent by the restate runtime.
528
+ * These headers are attempt specific, generated by the restate runtime uniquely for each attempt.
529
+ * These headers might contain information such as the W3C trace context, and attempt specific information.
530
+ */
531
+ readonly attemptHeaders: ReadonlyMap<string, string | string[] | undefined>;
532
+ /**
533
+ * Raw unparsed request body
534
+ */
535
+ readonly body: Uint8Array;
536
+ /**
537
+ * Extra arguments provided to the request handler:
538
+ * Lambda: [Context]
539
+ * Cloudflare workers: [Env, ExecutionContext]
540
+ * Deno: [ConnInfo]
541
+ * Bun: [Server]
542
+ * These arguments can contain request-specific values that could change after a suspension.
543
+ * Care should be taken to use them deterministically.
544
+ */
545
+ readonly extraArgs: unknown[];
546
+ };
547
+ /**
548
+ * Retry policy for `run`. Mirrors the SDK's `RunOptions` retry knobs
549
+ * but namespaced (no `Retry` prefix on each field) and grouped under
550
+ * `RunOpts.retry` for readability.
551
+ */
552
+ type RetryOptions = {
553
+ /**
554
+ * Max attempts (including the initial). When reached, `run` throws
555
+ * a `TerminalError` wrapping the original error message.
556
+ */
557
+ maxAttempts?: number;
558
+ /**
559
+ * Max total duration of retries before giving up. Number is ms.
560
+ */
561
+ maxDuration?: restate.Duration | number;
562
+ /**
563
+ * First retry delay. Subsequent delays grow by `intervalFactor`.
564
+ * Number is ms. Defaults to 50 ms.
565
+ */
566
+ initialInterval?: restate.Duration | number;
567
+ /**
568
+ * Cap on retry delay. Number is ms. Defaults to 10 s.
569
+ */
570
+ maxInterval?: restate.Duration | number;
571
+ /**
572
+ * Multiplier applied to the previous delay. Defaults to 2.
573
+ */
574
+ intervalFactor?: number;
575
+ };
576
+ /**
577
+ * Options for `run`. Both fields are optional; if `name` is omitted,
578
+ * the action's `Function.name` is used (works for named functions and
579
+ * for arrow functions assigned to a `const` since JS infers names from
580
+ * the binding site). If neither resolves, `run` throws.
581
+ */
582
+ type RunOpts<T> = {
583
+ /** Journal entry name. Falls back to `action.name` if absent. */
584
+ name?: string;
585
+ /** Retry policy. Defaults to the SDK's defaults if absent. */
586
+ retry?: RetryOptions;
587
+ /** Custom serde for the journaled value. */
588
+ serde?: restate.Serde<T>;
589
+ };
590
+ /**
591
+ * Options object passed to the closure of `run(...)`. Carries an
592
+ * AbortSignal that fires when invocation cancellation arrives.
593
+ *
594
+ * Using an object (rather than positional args) leaves room to extend
595
+ * the closure's API surface — additional fields may be added later
596
+ * without breaking existing closures.
597
+ */
598
+ type RunActionOpts = {
599
+ readonly signal: AbortSignal;
600
+ };
601
+ /**
602
+ * The closure that `run` invokes. Receives `{ signal }` — pass the
603
+ * signal into AbortSignal-aware APIs (e.g. `fetch(url, { signal })`)
604
+ * to cancel in-flight syscalls promptly.
605
+ */
606
+ type RunAction<T> = (opts: RunActionOpts) => Promise<T>;
607
+ /**
608
+ * Wrap a user-supplied `run` closure to surface the abort reason
609
+ * (typically a TerminalError(CANCELLED)) on throw paths if the signal
610
+ * aborted during execution. This converts AbortError (and any other
611
+ * abort-caused failure) into the canonical cancellation TerminalError
612
+ * for journal recording.
613
+ *
614
+ * Defensive coercion: if `signal.reason` is itself not a TerminalError
615
+ * (which shouldn't happen in production but might during testing or
616
+ * with non-cancellation race rejections), we wrap it in one. The
617
+ * journal must record a *terminal* outcome to avoid retries against
618
+ * a cancelled invocation.
619
+ *
620
+ * Exposed for testing — the wrapper's behavior is the part that has
621
+ * semantic bite, separate from the ctx.run plumbing.
622
+ */
623
+ declare function wrapActionForCancellation<T>(signal: AbortSignal, action: RunAction<T>): () => Promise<T>;
624
+ /**
625
+ * Deterministic date methods that return journal-backed Futures.
626
+ * Wraps the SDK's `ContextDate` (which returns Promises via internal
627
+ * `ctx.run()` calls) so that gen-SDK user code can `yield*` them.
628
+ */
629
+ interface GenContextDate {
630
+ now(): Future<number>;
631
+ toJSON(): Future<string>;
632
+ }
633
+ //#endregion
634
+ //#region src/free.d.ts
635
+ declare const rand: () => restate.Rand;
636
+ declare const date: () => GenContextDate;
637
+ declare const logger: () => Console;
638
+ /**
639
+ * Returns the current invocation's request metadata plus the optional
640
+ * virtual-object / workflow key. The `key` field is only present when
641
+ * the handler belongs to an object or workflow.
642
+ */
643
+ declare const handlerRequest: () => HandlerRequest;
644
+ /**
645
+ * Run a side-effecting closure as a journal entry. See
646
+ * `RestateOperations.run` for full semantics.
647
+ *
648
+ * `name` is derived from `action.name` (works for named functions and
649
+ * arrow functions assigned to a `const`) or specified explicitly via
650
+ * `opts.name`. If neither resolves, throws.
651
+ */
652
+ declare const run: <T>(action: RunAction<T>, opts?: RunOpts<T>) => Future<T>;
653
+ declare const sleep: (duration: restate.Duration | number, name?: string) => Future<void>;
654
+ declare const awakeable: <T>(serde?: restate.Serde<T>) => {
655
+ id: string;
656
+ promise: Future<T>;
657
+ };
658
+ declare const resolveAwakeable: <T>(id: string, payload?: T, serde?: restate.Serde<T>) => void;
659
+ declare const rejectAwakeable: (id: string, reason: string | restate.TerminalError) => void;
660
+ declare const signal: <T>(name: string, serde?: restate.Serde<T>) => Future<T>;
661
+ declare const attach: <T>(invocationId: restate.InvocationId, serde?: restate.Serde<T>) => Future<T>;
662
+ declare function client<H extends Record<string, HandlerDescriptor>>(def: Descriptor<string, H, "service">): GenClient<H>;
663
+ declare function client<H extends Record<string, HandlerDescriptor>>(def: Descriptor<string, H, "object" | "workflow">, key: string): GenClient<H>;
664
+ declare function sendClient<H extends Record<string, HandlerDescriptor>>(def: Descriptor<string, H, "service">): GenSendClient<H>;
665
+ declare function sendClient<H extends Record<string, HandlerDescriptor>>(def: Descriptor<string, H, "object" | "workflow">, key: string): GenSendClient<H>;
666
+ declare const call: <REQ = Uint8Array, RES = Uint8Array>(c: restate.GenericCall<REQ, RES>) => ClientFuture<RES>;
667
+ declare const send: <REQ = Uint8Array, RES = unknown>(c: restate.GenericSend<REQ>, outputSerde?: restate.Serde<RES>) => Future<InvocationReference<RES>>;
668
+ /**
669
+ * Create an InvocationReference from a known invocation ID (e.g. retrieved from state).
670
+ * `attach()` and `cancel()` on the result use the current fiber slot like all free functions.
671
+ */
672
+ declare function invocation<O$1 = unknown>(id: string, opts?: {
673
+ outputSerde?: restate.Serde<O$1>;
674
+ }): InvocationReference<O$1>;
675
+ declare const cancel: (invocationId: restate.InvocationId) => void;
676
+ declare const channel: <T>() => Channel<T>;
677
+ declare const state: <TState extends TypedState = UntypedState>() => State<TState>;
678
+ declare const sharedState: <TState extends TypedState = UntypedState>() => SharedState<TState>;
679
+ declare const workflowPromise: <T>(name: string, serde?: restate.Serde<T>) => GenDurablePromise<T>;
680
+ /**
681
+ * Wait for every future to settle; return their values in input order.
682
+ * Heterogeneous-tuple typing — `all([fA, fB])` where `fA: Future<A>`
683
+ * and `fB: Future<B>` yields `Future<[A, B]>`. Mirrors `Promise.all`.
684
+ */
685
+ declare const all: <const T extends readonly Future<unknown>[] | []>(futures: T) => Future<FutureValues<T>>;
686
+ /**
687
+ * Return the first future to settle; losers continue running but their
688
+ * results are discarded. Heterogeneous-tuple typing — `race([fA, fB])`
689
+ * yields `Future<A | B>`. Mirrors `Promise.race`.
690
+ */
691
+ declare const race: <const T extends readonly Future<unknown>[] | []>(futures: T) => Future<FutureValues<T>[number]>;
692
+ /**
693
+ * First-to-succeed wins (non-rejected). Rejects with `AggregateError(errors)`
694
+ * when every input rejects (including the empty input case). Tuple-aware —
695
+ * `any([fA, fB])` yields `Future<A | B>`. Mirrors `Promise.any`.
696
+ */
697
+ declare const any: <const T extends readonly Future<unknown>[] | []>(futures: T) => Future<FutureValues<T>[number]>;
698
+ /**
699
+ * Wait for every future to settle; never rejects. Tuple-aware —
700
+ * `allSettled([fA, fB])` yields
701
+ * `Future<[FutureSettledResult<A>, FutureSettledResult<B>]>`.
702
+ * Mirrors `Promise.allSettled`.
703
+ */
704
+ declare const allSettled: <const T extends readonly Future<unknown>[] | []>(futures: T) => Future<{ -readonly [P in keyof T]: FutureSettledResult<T[P] extends Future<infer U> ? U : never> }>;
705
+ /**
706
+ * Register `op` as a fresh routine and return a `Future<T>` for its
707
+ * eventual outcome. Eager — the child is already in flight by the time
708
+ * `spawn` returns. See `RestateOperations.spawn` for full semantics.
709
+ */
710
+ declare const spawn: <T>(op: Operation<T>) => Future<T>;
711
+ declare namespace interface_d_exports {
712
+ export { ImplementHandlers, InferInput, InferOutput, implement, json, object$1 as object, schemas$1 as schemas, serdes$1 as serdes, service$1 as service, workflow$1 as workflow };
713
+ }
714
+ /** json<I, O>() — type params, default JSON serde */
715
+ declare function json<I$1 = void, O$1 = void>(): HandlerDescriptor<I$1, O$1>;
716
+ /** serdes(opts) — explicit Serde per field */
717
+ declare function serdes$1<SI extends restate.Serde<any>, SO extends restate.Serde<any>>(opts: {
718
+ input?: SI;
719
+ output?: SO;
720
+ }): HandlerDescriptor<SI extends restate.Serde<infer I> ? I : never, SO extends restate.Serde<infer O> ? O : never>;
721
+ /** schemas(opts) — Standard Schema (Zod, TypeBox, Valibot, …) per field */
722
+ declare function schemas$1<SI extends StandardSchemaV1<any>, SO extends StandardSchemaV1<any>>(opts: {
723
+ input?: SI;
724
+ output?: SO;
725
+ }): HandlerDescriptor<StandardSchemaV1.InferOutput<NonNullable<SI>>, StandardSchemaV1.InferOutput<NonNullable<SO>>>;
726
+ declare function service$1<P$1 extends string, H extends Record<string, HandlerDescriptor>>(name: P$1, handlers: H): ServiceDescriptor<P$1, H>;
727
+ declare function object$1<P$1 extends string, H extends Record<string, HandlerDescriptor>>(name: P$1, handlers: H): ObjectDescriptor<P$1, H>;
728
+ declare function workflow$1<P$1 extends string, H extends Record<string, HandlerDescriptor>>(name: P$1, handlers: H): WorkflowDescriptor<P$1, H>;
729
+ /** @internal */
730
+ type InferInput<D> = D extends HandlerDescriptor<infer I, any> ? I : any;
731
+ /** @internal */
732
+ type InferOutput<D> = D extends HandlerDescriptor<any, infer O> ? O : any;
733
+ /** @internal */
734
+ type ImplementHandlers<H extends Record<string, HandlerDescriptor>> = { [K in keyof H]: (input: InferInput<H[K]>) => Operation<InferOutput<H[K]>> };
735
+ declare function implement<P$1 extends string, H extends Record<string, HandlerDescriptor>>(iface: ServiceDescriptor<P$1, H>, config: {
736
+ handlers: ImplementHandlers<H>;
737
+ options?: restate.ServiceOptions & {
738
+ handlers?: Partial<Record<keyof H, GenHandlerOpts>>;
739
+ };
740
+ }): ImplementedServiceDefinition<P$1, H>;
741
+ declare function implement<P$1 extends string, H extends Record<string, HandlerDescriptor>>(iface: ObjectDescriptor<P$1, H>, config: {
742
+ handlers: ImplementHandlers<H>;
743
+ options?: restate.ObjectOptions & {
744
+ handlers?: Partial<Record<keyof H, GenObjectHandlerOpts>>;
745
+ };
746
+ }): ImplementedObjectDefinition<P$1, H>;
747
+ declare function implement<P$1 extends string, H extends Record<string, HandlerDescriptor>>(iface: WorkflowDescriptor<P$1, H>, config: {
748
+ handlers: ImplementHandlers<H>;
749
+ options?: restate.WorkflowOptions & {
750
+ handlers?: Partial<Record<keyof H, GenWorkflowHandlerOpts>>;
751
+ };
752
+ }): ImplementedWorkflowDefinition<P$1, H>;
753
+ //#endregion
754
+ //#region ../restate-sdk-clients/src/api.d.ts
755
+ /**
756
+ * A remote client for a Restate service.
757
+ *
758
+ * Use the following client to interact with services defined
759
+ * - `serviceClient` to create a client for a service.
760
+ * - `workflowClient` to create a client for a workflow.
761
+ * - `objectClient` to create a client for a virtual object.
762
+ *
763
+ */
764
+ interface Ingress {
765
+ /**
766
+ * Create a client from a {@link ServiceDefinition}.
767
+ */
768
+ serviceClient<D>(opts: ServiceDefinitionFrom<D>): IngressClient<Service<D>>;
769
+ /**
770
+ * Create a client from a {@link WorkflowDefinition}.
771
+ *
772
+ * @param key the key of the workflow.
773
+ */
774
+ workflowClient<D>(opts: WorkflowDefinitionFrom<D>, key: string): IngressWorkflowClient<Workflow<D>>;
775
+ /**
776
+ * Create a client from a {@link VirtualObjectDefinition}.
777
+ * @param key the key of the virtual object.
778
+ */
779
+ objectClient<D>(opts: VirtualObjectDefinitionFrom<D>, key: string): IngressClient<VirtualObject<D>>;
780
+ /**
781
+ * Create a client from a {@link ServiceDefinition}.
782
+ */
783
+ serviceSendClient<D>(opts: ServiceDefinitionFrom<D>): IngressSendClient<Service<D>>;
784
+ /**
785
+ * Create a client from a {@link VirtualObjectDefinition}.
786
+ */
787
+ objectSendClient<D>(opts: VirtualObjectDefinitionFrom<D>, key: string): IngressSendClient<VirtualObject<D>>;
788
+ /**
789
+ * Resolve an awakeable from the ingress client.
790
+ */
791
+ resolveAwakeable<T>(id: string, payload?: T, payloadSerde?: Serde<T>): Promise<void>;
792
+ /**
793
+ * Reject an awakeable from the ingress client.
794
+ */
795
+ rejectAwakeable(id: string, reason: string): Promise<void>;
796
+ /**
797
+ * Obtain the result of a service that was asynchronously submitted (via a sendClient).
798
+ *
799
+ * @param send either the send response or the workflow submission as obtained by the respective clients.
800
+ */
801
+ result<T>(send: Send<T> | WorkflowSubmission<T>, resultSerde?: Serde<T>): Promise<T>;
802
+ /** Generic request-response call. Routes directly by service name without a typed definition. */
803
+ call<I$1 = Uint8Array, O$1 = Uint8Array>(opts: {
804
+ service: string;
805
+ handler: string;
806
+ parameter: I$1;
807
+ key?: string;
808
+ opts?: Opts$1<I$1, O$1>;
809
+ }): Promise<O$1>;
810
+ /** Generic fire-and-forget send. Routes directly by service name without a typed definition. */
811
+ send<I$1 = Uint8Array>(opts: {
812
+ service: string;
813
+ handler: string;
814
+ parameter: I$1;
815
+ key?: string;
816
+ opts?: SendOpts$1<I$1>;
817
+ }): Promise<Send>;
818
+ }
819
+ interface IngressCallOptions<I$1 = unknown, O$1 = unknown> {
820
+ /**
821
+ * Key to use for idempotency key.
822
+ *
823
+ * See https://docs.restate.dev/operate/invocation#invoke-a-handler-idempotently for more details.
824
+ */
825
+ idempotencyKey?: string;
826
+ /**
827
+ * Headers to attach to the request.
828
+ */
829
+ headers?: Record<string, string>;
830
+ input?: Serde<I$1>;
831
+ output?: Serde<O$1>;
832
+ /**
833
+ * Timeout to be used when executing the request. In milliseconds.
834
+ *
835
+ * Same as {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal#aborting_a_fetch_with_timeout_or_explicit_abort | AbortSignal.timeout()}.
836
+ *
837
+ * This field is exclusive with `signal`, and using both of them will result in a runtime failure.
838
+ */
839
+ timeout?: number;
840
+ /**
841
+ * Signal to abort the underlying `fetch` operation. See {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}.
842
+ *
843
+ * This field is exclusive with `timeout`, and using both of them will result in a runtime failure.
844
+ */
845
+ signal?: AbortSignal;
846
+ }
847
+ interface IngressSendOptions<I$1> extends IngressCallOptions<I$1, void> {
848
+ /**
849
+ * If set, the invocation will be enqueued now to be executed after the provided delay. In milliseconds.
850
+ */
851
+ delay?: number | Duration;
852
+ }
853
+ declare class Opts$1<I$1, O$1> {
854
+ readonly opts: IngressCallOptions<I$1, O$1>;
855
+ /**
856
+ * Create a call configuration from the provided options.
857
+ *
858
+ * @param opts the call configuration
859
+ */
860
+ static from<I$1 = unknown, O$1 = unknown>(opts: IngressCallOptions<I$1, O$1>): Opts$1<I$1, O$1>;
861
+ constructor(opts: IngressCallOptions<I$1, O$1>);
862
+ }
863
+ declare class SendOpts$1<I$1 = unknown> {
864
+ readonly opts: IngressSendOptions<I$1>;
865
+ /**
866
+ * @param opts Create send options
867
+ */
868
+ static from<I$1 = unknown>(opts: IngressSendOptions<I$1>): SendOpts$1<I$1>;
869
+ delay(): number | undefined;
870
+ constructor(opts: IngressSendOptions<I$1>);
871
+ }
872
+ type InferArgType<P$1> = P$1 extends [infer A, ...any[]] ? A : unknown;
873
+ type IngressClient<M> = { [K in keyof M as M[K] extends never ? never : K]: M[K] extends ((arg: any, ...args: infer P) => PromiseLike<infer O>) ? (...args: [...P, ...[opts?: Opts$1<InferArgType<P>, O>]]) => PromiseLike<O> : never };
874
+ /**
875
+ * Represents the output of a workflow.
876
+ */
877
+ interface Output<O$1> {
878
+ /**
879
+ * Whether the output is ready.
880
+ */
881
+ ready: boolean;
882
+ /**
883
+ * The output of the workflow.
884
+ */
885
+ result: O$1;
886
+ }
887
+ /**
888
+ * Represents a successful workflow submission.
889
+ *
890
+ */
891
+ type WorkflowSubmission<T> = {
892
+ /**
893
+ * The invocation id of the workflow. You can use that id to
894
+ * with the introspection tools (restate cli, logging, metrics)
895
+ *
896
+ */
897
+ readonly invocationId: string;
898
+ readonly status: "Accepted" | "PreviouslyAccepted";
899
+ readonly attachable: true;
900
+ };
901
+ /**
902
+ * A client for a workflow.
903
+ *
904
+ * This client represents the workflow definition, with the following additional methods:
905
+ * - `workflowSubmit` to submit the workflow.
906
+ * - `workflowAttach` to attach to the workflow and wait for its completion
907
+ * - `workflowOutput` to check if the workflow's output is ready/available.
908
+ *
909
+ * Once a workflow is submitted, it can be attached to, and the output can be retrieved.
910
+ *
911
+ * @typeParam M the type of the workflow.
912
+ */
913
+ type IngressWorkflowClient<M> = Omit<{ [K in keyof M as M[K] extends never ? never : K]: M[K] extends ((arg: any, ...args: infer P) => PromiseLike<infer O>) ? (...args: [...P, ...[opts?: Opts$1<InferArgType<P>, O>]]) => PromiseLike<O> : never } & {
914
+ /**
915
+ * Submit this workflow.
916
+ *
917
+ * This instructs restate to execute the 'run' handler of the workflow, idempotently.
918
+ * The workflow will be executed asynchronously, and the promise will resolve when the workflow has been accepted.
919
+ * Please note that submitting a workflow does not wait for it to completion, and it is safe to retry the submission,
920
+ * in case of failure.
921
+ *
922
+ * @param argument the same argument type as defined by the 'run' handler.
923
+ */
924
+ workflowSubmit: M extends Record<string, unknown> ? M["run"] extends ((arg: any, ...args: infer I) => Promise<infer O>) ? (...args: [...I, ...[opts?: SendOpts$1<InferArgType<I>>]]) => Promise<WorkflowSubmission<O>> : never : never;
925
+ /**
926
+ * Attach to this workflow.
927
+ *
928
+ * This instructs restate to attach to the workflow and wait for it to complete.
929
+ * It is only possible to 'attach' to a workflow that has been previously submitted.
930
+ * The promise will resolve when the workflow has completed either successfully with a result,
931
+ * or be rejected with an error.
932
+ * This operation is safe to retry many times, and it will always return the same result.
933
+ *
934
+ * @returns a promise that resolves when the workflow has completed.
935
+ */
936
+ workflowAttach: M extends Record<string, unknown> ? M["run"] extends ((...args: any) => Promise<infer O>) ? (opts?: Opts$1<void, O>) => Promise<O> : never : never;
937
+ /**
938
+ * Try retrieving the output of this workflow.
939
+ *
940
+ * This instructs restate to check if the workflow's output is ready/available.
941
+ * The returned Output object will have a 'ready' field set to true if the output is ready.
942
+ * If the output is ready, the 'result' field will contain the output.
943
+ * note: that this operation will not wait for the workflow to complete, to do so use 'workflowAttach'.
944
+ *
945
+ * @returns a promise that resolves if the workflow's output is ready/available.
946
+ */
947
+ workflowOutput: M extends Record<string, unknown> ? M["run"] extends ((...args: any) => Promise<infer O>) ? (opts?: Opts$1<void, O>) => Promise<Output<O>> : never : never;
948
+ }, "run">;
949
+ /**
950
+ * A send response.
951
+ *
952
+ * @typeParam T the type of the response.
953
+ */
954
+ type Send<T = unknown> = {
955
+ /**
956
+ * The invocation id of the send.
957
+ */
958
+ invocationId: string;
959
+ /**
960
+ * The status of the send.
961
+ */
962
+ status: "Accepted" | "PreviouslyAccepted";
963
+ attachable: boolean;
964
+ };
965
+ type IngressSendClient<M> = { [K in keyof M as M[K] extends never ? never : K]: M[K] extends ((arg: any, ...args: infer P) => PromiseLike<infer O>) ? (...args: [...P, ...[opts?: SendOpts$1<InferArgType<P>>]]) => Promise<Send<O>> : never };
966
+ type ConnectionOpts = {
967
+ /**
968
+ * Restate ingress URL.
969
+ * For example: http://localhost:8080
970
+ */
971
+ url: string;
972
+ /**
973
+ * Headers to attach on every request.
974
+ * Use this to attach authentication headers.
975
+ */
976
+ headers?: Record<string, string>;
977
+ /**
978
+ * Default serde to use for ingress payloads when no operation-specific serde
979
+ * is provided. Applies to handler calls, workflow attaches/output polling,
980
+ * awakeable resolution, and attached invocation results.
981
+ *
982
+ * Defaults to `restate.serde.json`.
983
+ */
984
+ serde?: Serde<any>;
985
+ /**
986
+ * Codec to use for input/outputs. Check {@link JournalValueCodec} for more details
987
+ *
988
+ * @experimental
989
+ */
990
+ journalValueCodec?: JournalValueCodec;
991
+ };
992
+ declare namespace ingress_d_exports {
993
+ export { ConnectionOpts, GenIngress, Ingress, IngressClient, IngressHandlerClient, IngressSendClient, IngressSendHandlerClient, IngressWorkflowClient, Opts$1 as Opts, Send, SendOpts$1 as SendOpts, client$1 as client, connect, sendClient$1 as sendClient };
994
+ }
995
+ /**
996
+ * Connect to the Restate Ingress.
997
+ *
998
+ * @param opts connection options
999
+ * @returns a connection the the restate ingress
1000
+ */
1001
+ declare function connect(opts: ConnectionOpts): GenIngress;
1002
+ /**
1003
+ * Minimal ingress interface required by the sdk-gen ingress helpers.
1004
+ * Structurally compatible with `Ingress` from `@restatedev/restate-sdk-clients`
1005
+ * — any object returned by `connect()` satisfies this.
1006
+ */
1007
+ type GenIngress = Omit<Ingress, "serviceClient" | "serviceSendClient" | "objectClient" | "objectSendClient" | "workflowClient">;
1008
+ type InferInput$1<D> = D extends HandlerDescriptor<infer I, any> ? I : unknown;
1009
+ type InferOutput$1<D> = D extends HandlerDescriptor<any, infer O> ? O : unknown;
1010
+ /** Typed ingress call client — each method returns Promise<O> */
1011
+ type IngressHandlerClient<H extends Record<string, HandlerDescriptor>> = { readonly [K in keyof H]: (input: InferInput$1<H[K]>, opts?: Opts$1<InferInput$1<H[K]>, InferOutput$1<H[K]>>) => Promise<InferOutput$1<H[K]>> };
1012
+ /** Typed ingress send client — each method returns Promise<Send> */
1013
+ type IngressSendHandlerClient<H extends Record<string, HandlerDescriptor>> = { readonly [K in keyof H]: [InferInput$1<H[K]>] extends [void] ? (opts?: SendOpts$1<void>) => Promise<Send> : (input: InferInput$1<H[K]>, opts?: SendOpts$1<InferInput$1<H[K]>>) => Promise<Send> };
1014
+ declare function client$1<H extends Record<string, HandlerDescriptor>>(ingress: GenIngress, def: Descriptor<string, H, "service">): IngressHandlerClient<H>;
1015
+ declare function client$1<H extends Record<string, HandlerDescriptor>>(ingress: GenIngress, def: Descriptor<string, H, "object" | "workflow">, key: string): IngressHandlerClient<H>;
1016
+ declare function sendClient$1<H extends Record<string, HandlerDescriptor>>(ingress: GenIngress, def: Descriptor<string, H, "service">): IngressSendHandlerClient<H>;
1017
+ declare function sendClient$1<H extends Record<string, HandlerDescriptor>>(ingress: GenIngress, def: Descriptor<string, H, "object" | "workflow">, key: string): IngressSendHandlerClient<H>;
1018
+ //#endregion
1019
+ export { type AnyGenFn, type Channel, type ClientFuture, type ContextDate, type Descriptor, type Duration, type EntryToDescriptor, type Future, type FutureFulfilledResult, type FutureRejectedResult, type FutureSettledResult, type FutureValue, type FutureValues, type GenClient, type GenContextDate, type GenDurablePromise, type GenHandlerOpts, type GenObjectHandlerOpts, type GenSendClient, type GenWorkflowHandlerOpts, type HandlerDef, type HandlerDescriptor, type HandlerDescriptors, type HandlerOrHandlerDescriptor, type HandlerRequest, type ImplementHandlers, type ImplementedDefinition, type ImplementedObjectDefinition, type ImplementedServiceDefinition, type ImplementedWorkflowDefinition, type InferInput, type InferOutput, type InvocationReference, type ObjectDescriptor, type Operation, type Rand, type RetryOptions, type RunAction, type RunActionOpts, type RunOpts, type SelectResult, type Serde, type Service, type ServiceDefinition, type ServiceDefinitionFrom, type ServiceDescriptor, type SharedState, type SignalReference, type StandardSchemaV1, type StandardTypedV1, type State, type TypedState, type UntypedState, type VirtualObject, type VirtualObjectDefinition, type VirtualObjectDefinitionFrom, type Workflow, type WorkflowDefinition, type WorkflowDefinitionFrom, type WorkflowDescriptor, all, allSettled, any, attach, awakeable, call, cancel, channel, client, ingress_d_exports as clients, date, gen, handlerRequest, interface_d_exports as iface, implement, invocation, logger, object, race, rand, rejectAwakeable, resolveAwakeable, run, schemas, select, send, sendClient, serde, serdes, service, sharedState, signal, sleep, spawn, state, workflow, workflowPromise, wrapActionForCancellation };
1020
+ //# sourceMappingURL=index.d.ts.map