@restatedev/restate-sdk-clients 1.18.0 → 1.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.cts CHANGED
@@ -464,8 +464,11 @@ type ConnectionOpts = {
464
464
  /**
465
465
  * Restate ingress URL.
466
466
  * For example: http://localhost:8080
467
+ *
468
+ * Optional for `connect()`: when omitted, the ingress comes from
469
+ * `RESTATE_INGRESS_KEY` (see `connect()`).
467
470
  */
468
- url: string;
471
+ url?: string;
469
472
  /**
470
473
  * Headers to attach on every request.
471
474
  * Use this to attach authentication headers.
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.cts","names":[],"sources":["../src/api.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;;;AAYU,UAZO,OAAA,CAYP;EAE0B;;;EAOE,aAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAjBb,qBAiBa,CAjBS,CAiBT,CAAA,CAAA,EAjBc,aAiBd,CAjB4B,OAiB5B,CAjBoC,CAiBpC,CAAA,CAAA;EAA5B;;;;;EAQA,cAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAjBA,sBAiBA,CAjBuB,CAiBvB,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAfL,qBAeK,CAfiB,QAejB,CAf0B,CAe1B,CAAA,CAAA;EACqB;;;;EAMrB,YAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAfA,2BAeA,CAf4B,CAe5B,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAbL,aAaK,CAbS,aAaT,CAbuB,CAavB,CAAA,CAAA;EAE2B;;;EAWe,iBAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EApB1C,qBAoB0C,CApBpB,CAoBoB,CAAA,CAAA,EAnB/C,iBAmB+C,CAnB7B,OAmB6B,CAnBrB,CAmBqB,CAAA,CAAA;EAAf;;;EACf,gBAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAdZ,2BAcY,C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EAAX;;;EAAkB,KAAA,EAAA,OAAA;EA/DG;;AA4EvC;EAcY,MAAA,EAjIF,GAiIE;;;;;;AAC0C,KA1H1C,kBA0H0C,CAAA,CAAA,CAAA,GAAA;EAG/C;;;;;EAGiB,SAAA,YAAA,EAAA,MAAA;EAAL;;;AAUnB;AAiCA;;;;EAsE0B,SAAA,MAAA,EAAA,UAAA,GAAA,oBAAA;EAAY,SAAA,UAAA,EAAA,IAAA;AAGtC,CAAA;;;;;;;;;;;;;KArNY,2BAA2B,mBAEvB,KAAK,EAAE,2BAA2B,IAAI,EAAE,4CAG/C,sCAEc,cAAc,KAAK,aAAa,IAAI,SAC9C,YAAY;;;;;;;;;;;;kBAcL,UAAU,0BACtB,kDAAiD,kCAEhC,cAAc,SAAS,aAAa,UAC9C,QAAQ,mBAAmB;;;;;;;;;;;;;;kBAiBtB,UAAU,0BACtB,oCAAmC,4BACzB,WAAW,OAAO,QAAQ;;;;;;;;;;;;;kBAgBxB,UAAU,0BACtB,oCAAmC,4BACzB,WAAW,OAAO,QAAQ,OAAO;;;;;;;KAavC;;;;;;;;;;;KAcA,qCACE,KAAK,EAAE,2BAA2B,IAAI,EAAE,4CAG/C,sCAEc,cAAc,SAAS,aAAa,UAC9C,QAAQ,KAAK;;;;;;;KAUZ,YAAA;;;;;;;;oBAUY;;;;;;;;;;;;;;;;;;;;;;UAuBP,WAAA;;;;;;;;;;;;;;;;;;;;;gBAsBD;;;;;oBAMI;;;;;gBAMJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAoCU;;KAGd,cAAA;;;;;;;;;;;;;YAaA;;;;;;;;;;;;;;;;;UAkBF;;;;;;;;UASA;;;;;;sBAOY;;;;;;;;iBASL,UAAA,CAAW"}
package/dist/api.d.ts CHANGED
@@ -464,8 +464,11 @@ type ConnectionOpts = {
464
464
  /**
465
465
  * Restate ingress URL.
466
466
  * For example: http://localhost:8080
467
+ *
468
+ * Optional for `connect()`: when omitted, the ingress comes from
469
+ * `RESTATE_INGRESS_KEY` (see `connect()`).
467
470
  */
468
- url: string;
471
+ url?: string;
469
472
  /**
470
473
  * Headers to attach on every request.
471
474
  * Use this to attach authentication headers.
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","names":[],"sources":["../src/api.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;;;AAYU,UAZO,OAAA,CAYP;EAE0B;;;EAOE,aAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAjBb,qBAiBa,CAjBS,CAiBT,CAAA,CAAA,EAjBc,aAiBd,CAjB4B,OAiB5B,CAjBoC,CAiBpC,CAAA,CAAA;EAA5B;;;;;EAQA,cAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAjBA,sBAiBA,CAjBuB,CAiBvB,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAfL,qBAeK,CAfiB,QAejB,CAf0B,CAe1B,CAAA,CAAA;EACqB;;;;EAMrB,YAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAfA,2BAeA,CAf4B,CAe5B,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAbL,aAaK,CAbS,aAaT,CAbuB,CAavB,CAAA,CAAA;EAE2B;;;EAWe,iBAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EApB1C,qBAoB0C,CApBpB,CAoBoB,CAAA,CAAA,EAnB/C,iBAmB+C,CAnB7B,OAmB6B,CAnBrB,CAmBqB,CAAA,CAAA;EAAf;;;EACf,gBAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAdZ,2BAcY,CAdgB,CAchB,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAZjB,iBAYiB,CAZC,aAYD,CAZe,CAYf,CAAA,CAAA;EACY;;;;;;;;;EAI1B,MAAA,CAAA,YAAA,MAAA,EAAA,UAN6B,MAM7B,CAAA,MAAA,EAN4C,iBAM5C,CAAA,CAAA,CAAA,gBAAA,EALc,iBAKd,CALgC,GAKhC,EALmC,CA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,SAAA,UAAA,EAAA,IAAA;AAGtC,CAAA;;;;;;;;;;;;;KArNY,2BAA2B,mBAEvB,KAAK,EAAE,2BAA2B,IAAI,EAAE,4CAG/C,sCAEc,cAAc,KAAK,aAAa,IAAI,SAC9C,YAAY;;;;;;;;;;;;kBAcL,UAAU,0BACtB,kDAAiD,kCAEhC,cAAc,SAAS,aAAa,UAC9C,QAAQ,mBAAmB;;;;;;;;;;;;;;kBAiBtB,UAAU,0BACtB,oCAAmC,4BACzB,WAAW,OAAO,QAAQ;;;;;;;;;;;;;kBAgBxB,UAAU,0BACtB,oCAAmC,4BACzB,WAAW,OAAO,QAAQ,OAAO;;;;;;;KAavC;;;;;;;;;;;KAcA,qCACE,KAAK,EAAE,2BAA2B,IAAI,EAAE,4CAG/C,sCAEc,cAAc,SAAS,aAAa,UAC9C,QAAQ,KAAK;;;;;;;KAUZ,YAAA;;;;;;;;oBAUY;;;;;;;;;;;;;;;;;;;;;;UAuBP,WAAA;;;;;;;;;;;;;;;;;;;;;gBAsBD;;;;;oBAMI;;;;;gBAMJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAoCU;;KAGd,cAAA;;;;;;;;;;;;;YAaA;;;;;;;;;;;;;;;;;UAkBF;;;;;;;;UASA;;;;;;sBAOY;;;;;;;;iBASL,UAAA,CAAW"}
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","names":["opts: IngressCallOptions<I, O>","opts: IngressSendOptions<I>"],"sources":["../src/api.ts"],"sourcesContent":["import type {\n Service,\n VirtualObjectDefinitionFrom,\n Workflow,\n VirtualObject,\n ServiceDefinitionFrom,\n WorkflowDefinitionFrom,\n Serde,\n Duration,\n JournalValueCodec,\n HandlerDescriptor,\n ServiceDescriptor,\n ObjectDescriptor,\n WorkflowDescriptor,\n InferInput,\n InferOutput,\n} from \"@restatedev/restate-sdk-core\";\nimport { millisOrDurationToMillis } from \"@restatedev/restate-sdk-core\";\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * A remote client for a Restate service.\n *\n * Use the following client to interact with services defined\n * - `serviceClient` to create a client for a service.\n * - `workflowClient` to create a client for a workflow.\n * - `objectClient` to create a client for a virtual object.\n *\n */\nexport interface Ingress {\n /**\n * Create a client from a {@link ServiceDefinition}.\n */\n serviceClient<D>(opts: ServiceDefinitionFrom<D>): IngressClient<Service<D>>;\n\n /**\n * Create a client from a {@link WorkflowDefinition}.\n *\n * @param key the key of the workflow.\n */\n workflowClient<D>(\n opts: WorkflowDefinitionFrom<D>,\n key: string\n ): IngressWorkflowClient<Workflow<D>>;\n\n /**\n * Create a client from a {@link VirtualObjectDefinition}.\n * @param key the key of the virtual object.\n */\n objectClient<D>(\n opts: VirtualObjectDefinitionFrom<D>,\n key: string\n ): IngressClient<VirtualObject<D>>;\n\n /**\n * Create a send client from a {@link ServiceDefinition}.\n */\n serviceSendClient<D>(\n opts: ServiceDefinitionFrom<D>\n ): IngressSendClient<Service<D>>;\n\n /**\n * Create a send client from a {@link VirtualObjectDefinition}.\n */\n objectSendClient<D>(\n opts: VirtualObjectDefinitionFrom<D>,\n key: string\n ): IngressSendClient<VirtualObject<D>>;\n\n /**\n * Create a request/response client from a service interface / `Descriptor`.\n *\n * @example\n * ```ts\n * ingress.client(greeter).greet(req); // service\n * ingress.client(counter, \"k\").add(1); // virtual object / workflow\n * ```\n */\n client<P extends string, H extends Record<string, HandlerDescriptor>>(\n serviceInterface: ServiceDescriptor<P, H>\n ): IngressClientFromDescriptors<H>;\n client<P extends string, H extends Record<string, HandlerDescriptor>>(\n objectOrWorkflowInterface:\n | ObjectDescriptor<P, H>\n | WorkflowDescriptor<P, H>,\n key: string\n ): IngressClientFromDescriptors<H>;\n\n /**\n * Send-client (one-way) counterpart of {@link Ingress.client}.\n *\n * @example\n * ```ts\n * ingress.sendClient(greeter).greet(req);\n * ingress.sendClient(counter, \"k\").add(1);\n * ```\n */\n sendClient<P extends string, H extends Record<string, HandlerDescriptor>>(\n serviceInterface: ServiceDescriptor<P, H>\n ): IngressSendClientFromDescriptors<H>;\n sendClient<P extends string, H extends Record<string, HandlerDescriptor>>(\n objectOrWorkflowInterface:\n | ObjectDescriptor<P, H>\n | WorkflowDescriptor<P, H>,\n key: string\n ): IngressSendClientFromDescriptors<H>;\n\n /**\n * Resolve an awakeable from the ingress client.\n */\n resolveAwakeable<T>(\n id: string,\n payload?: T,\n payloadSerde?: Serde<T>\n ): Promise<void>;\n\n /**\n * Reject an awakeable from the ingress client.\n */\n rejectAwakeable(id: string, reason: string): Promise<void>;\n\n /**\n * Obtain the result of a service that was asynchronously submitted (via a sendClient).\n *\n * @param send either the send response or the workflow submission as obtained by the respective clients.\n */\n result<T>(\n send: Send<T> | WorkflowSubmission<T>,\n resultSerde?: Serde<T>\n ): Promise<T>;\n\n /** Generic request-response call. Routes directly by service name without a typed definition. */\n call<I = Uint8Array, O = Uint8Array>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n /**\n * Route this call within the given scope. See {@link Ingress.scope}.\n *\n * *NOTE:* This API is experimental. To use it you need a restate-server >= 1.7,\n * configured to enable\n * [service protocol v7](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#service-protocol-v7)\n * and [flow control](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#flow-control).\n * For example, start the restate-server with the environment variables\n * `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n *\n * @experimental\n */\n scope?: string;\n opts?: Opts<I, O>;\n }): Promise<O>;\n\n /** Generic fire-and-forget send. Routes directly by service name without a typed definition. */\n send<I = Uint8Array>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n /**\n * Route this send within the given scope. See {@link Ingress.scope}.\n *\n * *NOTE:* This API is experimental. To use it you need a restate-server >= 1.7,\n * configured to enable\n * [service protocol v7](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#service-protocol-v7)\n * and [flow control](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#flow-control).\n * For example, start the restate-server with the environment variables\n * `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n *\n * @experimental\n */\n scope?: string;\n opts?: SendOpts<I>;\n }): Promise<Send>;\n\n /**\n * Returns a {@link ScopedIngress} that routes all calls within the given scope.\n *\n * **NOTE:** This API is in preview and is not enabled by default.\n * To use it in restate-server 1.7, enable the flow control and protocol v7 experimental features,\n * via `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n * These can be enabled only on **new clusters**, for more info check out https://docs.restate.dev/services/flow-control#enabling-flow-control.\n * If these experimental features aren't enabled, the invocation won't be ingested and the client request fails.\n *\n * A scope is a sub-grouping of resources (invocations, virtual object instances, workflow\n * instances, concurrency limits) within the Restate cluster.\n * It becomes part of the target identity tuple:\n * - `scope, service, handler, idempotencyKey?`\n * - `scope, virtualObject, objectKey, handler, idempotencyKey?`\n * - `scope, workflow, workflowKey, handler`\n *\n * Under the hood, the scope contributes to the partition key, so all resources in a scope get co-located by the restate-server.\n *\n * Omitting the scope (i.e. using the regular `serviceClient` / `workflowClient` methods)\n * is equivalent to calling with no scope, which is the existing behavior.\n *\n * The scope key must consist only of `[a-zA-Z0-9_.-]` characters, with 1 <= length <= 36 chars.\n *\n * @example\n * ```ts\n * // Route a call into a named scope\n * await ingress.scope(\"tenant-123\").serviceClient(MyService).process(payload);\n *\n * // Idempotency keys are scoped — \"req-1\" in \"tenant-123\" is distinct from \"req-1\" in \"tenant-456\"\n * await ingress.scope(\"tenant-123\").serviceClient(MyService)\n * .process(payload, rpc.opts({ idempotencyKey: \"req-1\" }));\n *\n * // Combine with a limit key to enforce per-scope concurrency limits\n * await ingress.scope(\"tenant-123\").workflowClient(MyWorkflow, \"wf-key\")\n * .run(input, rpc.opts({ limitKey: \"api-key/user42\" }));\n * ```\n *\n * @param scopeKey the scope identifier\n * @see https://docs.restate.dev/services/flow-control\n * @experimental\n */\n scope(scopeKey: string): ScopedIngress;\n}\n\n/**\n * An ingress client for making RPC calls within a specific scope.\n *\n * @see {@link Ingress.scope}\n * @experimental\n * @interface\n */\nexport type ScopedIngress = Pick<\n Ingress,\n | \"serviceClient\"\n | \"serviceSendClient\"\n | \"objectClient\"\n | \"objectSendClient\"\n | \"workflowClient\"\n | \"client\"\n | \"sendClient\"\n>;\n\nexport interface IngressCallOptions<I = unknown, O = unknown> {\n /**\n * Key to use for idempotency key.\n *\n * See https://docs.restate.dev/operate/invocation#invoke-a-handler-idempotently for more details.\n */\n idempotencyKey?: string;\n\n /**\n * An optional concurrency limit key within the scope.\n * A limit key can only be used in conjunction with a scope (see {@link Ingress.scope}).\n *\n * **NOTE:** This API is in preview and is not enabled by default.\n * To use it in restate-server 1.7, enable the flow control and protocol v7 experimental features,\n * via `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n * These can be enabled only on **new clusters**, for more info check out https://docs.restate.dev/services/flow-control#enabling-flow-control.\n * If these experimental features aren't enabled, the invocation isn't ingested and the client request fails.\n *\n * The limit key enforces hierarchical concurrency limits on invocations sharing the same scope.\n * It can have one or two levels separated by `/` (e.g. `\"tenant1\"` or `\"tenant1/user42\"`).\n * Each level must consist only of `[a-zA-Z0-9_.-]` characters, and 1 <= length <= 36.\n *\n * The limit key is **not** part of the request identity: two calls to the same target with the\n * same scope and object key but different limit keys refer to the **same** resource instance.\n * The limit key only affects concurrency limits, not resource identity.\n *\n * @experimental\n */\n limitKey?: string;\n\n /**\n * Headers to attach to the request.\n */\n headers?: Record<string, string>;\n\n input?: Serde<I>;\n\n output?: Serde<O>;\n\n /**\n * Timeout to be used when executing the request. In milliseconds.\n *\n * Same as {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal#aborting_a_fetch_with_timeout_or_explicit_abort | AbortSignal.timeout()}.\n *\n * This field is exclusive with `signal`, and using both of them will result in a runtime failure.\n */\n timeout?: number;\n\n /**\n * Signal to abort the underlying `fetch` operation. See {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}.\n *\n * This field is exclusive with `timeout`, and using both of them will result in a runtime failure.\n */\n signal?: AbortSignal;\n}\n\nexport interface IngressSendOptions<I> extends IngressCallOptions<I, void> {\n /**\n * If set, the invocation will be enqueued now to be executed after the provided delay. In milliseconds.\n */\n delay?: number | Duration;\n}\n\nexport class Opts<I, O> {\n /**\n * Create a call configuration from the provided options.\n *\n * @param opts the call configuration\n */\n public static from<I = unknown, O = unknown>(\n opts: IngressCallOptions<I, O>\n ): Opts<I, O> {\n return new Opts(opts);\n }\n\n constructor(readonly opts: IngressCallOptions<I, O>) {}\n}\n\nexport class SendOpts<I = unknown> {\n /**\n * @param opts Create send options\n */\n public static from<I = unknown>(opts: IngressSendOptions<I>): SendOpts<I> {\n return new SendOpts(opts);\n }\n\n delay(): number | undefined {\n if (this.opts.delay !== undefined) {\n return millisOrDurationToMillis(this.opts.delay);\n }\n return undefined;\n }\n\n constructor(readonly opts: IngressSendOptions<I>) {}\n}\n\nexport type InferArgType<P> = P extends [infer A, ...any[]] ? A : unknown;\n\nexport type IngressClient<M> = {\n [K in keyof M as M[K] extends never ? never : K]: M[K] extends (\n arg: any,\n ...args: infer P\n ) => PromiseLike<infer O>\n ? (...args: [...P, ...[opts?: Opts<InferArgType<P>, O>]]) => PromiseLike<O>\n : never;\n};\n\n/**\n * Typed ingress request/response client derived from a service interface's\n * handler descriptor map `H` (see `iface` in `@restatedev/restate-sdk-core`).\n * Recovers the input/output types directly from the descriptors, so a code-free\n * interface value produces a fully typed client that reuses the declared serdes.\n */\nexport type IngressClientFromDescriptors<\n H extends Record<string, HandlerDescriptor>,\n> = {\n readonly [K in keyof H]: [InferInput<H[K]>] extends [void]\n ? (\n opts?: Opts<InferInput<H[K]>, InferOutput<H[K]>>\n ) => Promise<InferOutput<H[K]>>\n : (\n input: InferInput<H[K]>,\n opts?: Opts<InferInput<H[K]>, InferOutput<H[K]>>\n ) => Promise<InferOutput<H[K]>>;\n};\n\n/** One-way (send) counterpart of {@link IngressClientFromDescriptors}. */\nexport type IngressSendClientFromDescriptors<\n H extends Record<string, HandlerDescriptor>,\n> = {\n readonly [K in keyof H]: [InferInput<H[K]>] extends [void]\n ? (opts?: SendOpts<InferInput<H[K]>>) => Promise<Send<InferOutput<H[K]>>>\n : (\n input: InferInput<H[K]>,\n opts?: SendOpts<InferInput<H[K]>>\n ) => Promise<Send<InferOutput<H[K]>>>;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace rpc {\n export const opts = <I, O>(opts: IngressCallOptions<I, O>) => Opts.from(opts);\n\n export const sendOpts = <I>(opts: IngressSendOptions<I>) =>\n SendOpts.from(opts);\n}\n\n/**\n * Represents the output of a workflow.\n */\nexport interface Output<O> {\n /**\n * Whether the output is ready.\n */\n ready: boolean;\n\n /**\n * The output of the workflow.\n */\n result: O;\n}\n\n/**\n * Represents a successful workflow submission.\n *\n */\n/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\nexport type WorkflowSubmission<T> = {\n /**\n * The invocation id of the workflow. You can use that id to\n * with the introspection tools (restate cli, logging, metrics)\n *\n */\n readonly invocationId: string;\n /**\n * Whether the workflow was accepted by this request or had already been\n * accepted.\n *\n * When automatic retries are enabled, this may be `PreviouslyAccepted` if an\n * earlier attempt from the same `workflowSubmit` call was accepted but its\n * response was not observed by the client.\n */\n readonly status: \"Accepted\" | \"PreviouslyAccepted\";\n readonly attachable: true;\n};\n\n/**\n * A client for a workflow.\n *\n * This client represents the workflow definition, with the following additional methods:\n * - `workflowSubmit` to submit the workflow.\n * - `workflowAttach` to attach to the workflow and wait for its completion\n * - `workflowOutput` to check if the workflow's output is ready/available.\n *\n * Once a workflow is submitted, it can be attached to, and the output can be retrieved.\n *\n * @typeParam M the type of the workflow.\n */\nexport type IngressWorkflowClient<M> = Omit<\n {\n [K in keyof M as M[K] extends never ? never : K]: M[K] extends (\n arg: any,\n ...args: infer P\n ) => PromiseLike<infer O>\n ? (\n ...args: [...P, ...[opts?: Opts<InferArgType<P>, O>]]\n ) => PromiseLike<O>\n : never;\n } & {\n /**\n * Submit this workflow.\n *\n * This instructs restate to execute the 'run' handler of the workflow, idempotently.\n * The workflow will be executed asynchronously, and the promise will resolve when the workflow has been accepted.\n * Please note that submitting a workflow does not wait for it to completion.\n * When automatic retries are enabled on the connection, the client safely retries\n * ambiguous submission failures using the workflow ID as the request identity.\n *\n * @param argument the same argument type as defined by the 'run' handler.\n */\n workflowSubmit: M extends Record<string, unknown>\n ? M[\"run\"] extends (arg: any, ...args: infer I) => Promise<infer O>\n ? (\n ...args: [...I, ...[opts?: SendOpts<InferArgType<I>>]]\n ) => Promise<WorkflowSubmission<O>>\n : never\n : never;\n\n /**\n * Attach to this workflow.\n *\n * This instructs restate to attach to the workflow and wait for it to complete.\n * It is only possible to 'attach' to a workflow that has been previously submitted.\n * The promise will resolve when the workflow has completed either successfully with a result,\n * or be rejected with an error.\n * This operation is safe to retry many times, and it will always return the same result.\n * When automatic retries are enabled on the connection, the client retries\n * ambiguous attach failures according to the configured retry policy.\n *\n * @returns a promise that resolves when the workflow has completed.\n */\n workflowAttach: M extends Record<string, unknown>\n ? M[\"run\"] extends (...args: any) => Promise<infer O>\n ? (opts?: Opts<void, O>) => Promise<O>\n : never\n : never;\n\n /**\n * Try retrieving the output of this workflow.\n *\n * This instructs restate to check if the workflow's output is ready/available.\n * The returned Output object will have a 'ready' field set to true if the output is ready.\n * If the output is ready, the 'result' field will contain the output.\n * note: that this operation will not wait for the workflow to complete, to do so use 'workflowAttach'.\n * When automatic retries are enabled on the connection, the client retries\n * ambiguous output retrieval failures according to the configured retry policy.\n *\n * @returns a promise that resolves if the workflow's output is ready/available.\n */\n workflowOutput: M extends Record<string, unknown>\n ? M[\"run\"] extends (...args: any) => Promise<infer O>\n ? (opts?: Opts<void, O>) => Promise<Output<O>>\n : never\n : never;\n },\n \"run\"\n>;\n\n/**\n * A send response.\n *\n * @typeParam T the type of the response.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Send<T = unknown> = {\n /**\n * The invocation id of the send.\n */\n invocationId: string;\n\n /**\n * The status of the send.\n */\n status: \"Accepted\" | \"PreviouslyAccepted\";\n\n attachable: boolean;\n};\n\nexport type IngressSendClient<M> = {\n [K in keyof M as M[K] extends never ? never : K]: M[K] extends (\n arg: any,\n ...args: infer P\n ) => PromiseLike<infer O>\n ? (\n ...args: [...P, ...[opts?: SendOpts<InferArgType<P>>]]\n ) => Promise<Send<O>>\n : never;\n};\n\n/**\n * An ambiguous ingress failure that may be retried.\n *\n * Passed to {@link RetryPolicy.shouldRetry} so a caller can inspect the failure\n * and decide whether to retry.\n */\nexport type RetryFailure =\n | {\n /** The underlying `fetch` call rejected (connection refused/reset, DNS). */\n readonly kind: \"network\";\n readonly error: unknown;\n }\n | {\n /** The server returned a non-2xx response. */\n readonly kind: \"response\";\n readonly status: number;\n readonly headers: Headers;\n /**\n * The response body, decoded as text, when the response carried a\n * non-empty body; `undefined` otherwise.\n */\n readonly body?: string;\n };\n\n/**\n * Policy controlling automatic retries of ambiguous ingress failures.\n *\n * Retries are **opt-in**: they happen only when a policy is configured (see\n * {@link ConnectionOpts.retry}) and the request is safe to repeat. Regular\n * calls require an `idempotencyKey` (see\n * {@link IngressCallOptions.idempotencyKey}); workflow submissions are\n * idempotent by workflow ID, while workflow attaches and output retrieval only\n * observe the existing workflow.\n *\n * By default the following failures are retried: network errors (the underlying\n * `fetch` rejecting) and responses with a transient status (`408`, `425`, `429`,\n * or `5xx`). A terminal error of the invocation is never retried, whatever its status code.\n * Override all of this with {@link RetryPolicy.shouldRetry}.\n */\nexport interface RetryPolicy {\n /**\n * Max number of attempts (including the initial), before giving up.\n *\n * Retrying stops as soon as **either** `maxDuration` or {@link maxAttempts} is reached.\n *\n * Defaults to `6` (the initial attempt plus up to 5 retries). Pass `false` to\n * remove the attempt bound.\n */\n maxAttempts?: number | false;\n\n /**\n * Max total duration of retries, measured from the first attempt, before\n * giving up. If a number is provided, it is interpreted as milliseconds.\n *\n * This bound is checked only when deciding whether to start another\n * attempt after a failure: it never aborts an in-flight request.\n *\n * Retrying stops as soon as **either** {@link maxDuration} or {@link maxAttempts} is reached.\n *\n * Defaults to 60 seconds. Pass `false` to remove the duration bound.\n */\n maxDuration?: Duration | number | false;\n\n /**\n * Initial backoff interval. If a number is provided, it is interpreted as\n * milliseconds. Defaults to `250` milliseconds.\n */\n initialInterval?: Duration | number;\n\n /**\n * Maximum backoff interval. If a number is provided, it is interpreted as\n * milliseconds. Defaults to `3000` milliseconds.\n */\n maxInterval?: Duration | number;\n\n /**\n * Exponentiation factor to use when computing the next retry delay.\n * Defaults to `2`.\n */\n exponentiationFactor?: number;\n\n /**\n * Whether to honor a `Retry-After` response header when the server provides\n * one. When `true` (the default), a `Retry-After` value overrides the computed\n * exponential backoff for that attempt.\n *\n * Set to `false` to always use the exponential backoff and ignore the header.\n *\n * Note that `Retry-After` never extends the number of retries: {@link maxAttempts} and\n * {@link maxDuration} is always respected regardless of this setting.\n *\n * Defaults to `true`.\n */\n respectRetryAfter?: boolean;\n\n /**\n * Decide whether a given failure should be retried. When provided, this\n * fully replaces the built-in rule (network / transient `408`/`425`/`429`/`5xx`,\n * excluding invocation-sourced errors).\n *\n * The idempotency-key gate still applies to regular invocations; workflow\n * submissions, attaches, and output retrieval remain eligible without an\n * idempotency key. The `maxAttempts` cap applies to all of them. This predicate\n * only narrows or broadens *which failures* are retryable within those bounds.\n * Compose with the built-in rule via the exported `defaultShouldRetry`.\n *\n * @param failure the failure being considered\n * @param attempt the zero-based index of the attempt that just failed\n */\n shouldRetry?: (failure: RetryFailure, attempt: number) => boolean;\n}\n\nexport type ConnectionOpts = {\n /**\n * Restate ingress URL.\n * For example: http://localhost:8080\n */\n url: string;\n /**\n * Headers to attach on every request.\n * Use this to attach authentication headers.\n */\n headers?: Record<string, string>;\n\n /**\n * Opt in to automatic retries of ambiguous ingress failures (network errors\n * and transient HTTP statuses `408`/`425`/`429`/`5xx`, excluding errors\n * restate attributes to the invocation itself).\n *\n * Retries are **disabled by default**. Set `true` to enable the built-in\n * policy ({@link RetryPolicy}), or pass a {@link RetryPolicy} to tune it.\n *\n * Even when enabled, regular calls are retried **only** when an\n * `idempotencyKey` is set — without one a retry could double-execute a\n * non-idempotent invocation. Workflow submissions, attaches, and output\n * retrieval are also retried: submissions are idempotent by workflow ID,\n * while attach and output operations only observe the existing workflow. If a\n * submission retry observes a workflow accepted by an earlier attempt, its\n * status is `PreviouslyAccepted`.\n */\n retry?: RetryPolicy | boolean;\n\n /**\n * Default serde to use for ingress payloads when no operation-specific serde\n * is provided. Applies to handler calls, workflow attaches/output polling,\n * awakeable resolution, and attached invocation results.\n *\n * Defaults to `restate.serde.json`.\n */\n serde?: Serde<any>;\n\n /**\n * Codec to use for input/outputs. Check {@link JournalValueCodec} for more details\n *\n * @experimental\n */\n journalValueCodec?: JournalValueCodec;\n\n /**\n * Custom fetch client\n *\n * Allows you to provide a different fetch implementation (e.g., undici fetch for HTTP/2 support).\n *\n * @defaultValue `globalThis.fetch`\n */\n fetch?: typeof globalThis.fetch;\n};\n"],"mappings":";;;AA6SA,IAAa,OAAb,MAAa,KAAW;;;;;;CAMtB,OAAc,KACZ,MACY;AACZ,SAAO,IAAI,KAAK,KAAK;;CAGvB,YAAY,AAASA,MAAgC;EAAhC;;;AAGvB,IAAa,WAAb,MAAa,SAAsB;;;;CAIjC,OAAc,KAAkB,MAA0C;AACxE,SAAO,IAAI,SAAS,KAAK;;CAG3B,QAA4B;AAC1B,MAAI,KAAK,KAAK,UAAU,OACtB,QAAO,yBAAyB,KAAK,KAAK,MAAM;;CAKpD,YAAY,AAASC,MAA6B;EAA7B;;;;;cA+CM,SAAmC,KAAK,KAAK,KAAK;kBAEjD,SAC1B,SAAS,KAAK,KAAK"}
1
+ {"version":3,"file":"api.js","names":["opts: IngressCallOptions<I, O>","opts: IngressSendOptions<I>"],"sources":["../src/api.ts"],"sourcesContent":["import type {\n Service,\n VirtualObjectDefinitionFrom,\n Workflow,\n VirtualObject,\n ServiceDefinitionFrom,\n WorkflowDefinitionFrom,\n Serde,\n Duration,\n JournalValueCodec,\n HandlerDescriptor,\n ServiceDescriptor,\n ObjectDescriptor,\n WorkflowDescriptor,\n InferInput,\n InferOutput,\n} from \"@restatedev/restate-sdk-core\";\nimport { millisOrDurationToMillis } from \"@restatedev/restate-sdk-core\";\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * A remote client for a Restate service.\n *\n * Use the following client to interact with services defined\n * - `serviceClient` to create a client for a service.\n * - `workflowClient` to create a client for a workflow.\n * - `objectClient` to create a client for a virtual object.\n *\n */\nexport interface Ingress {\n /**\n * Create a client from a {@link ServiceDefinition}.\n */\n serviceClient<D>(opts: ServiceDefinitionFrom<D>): IngressClient<Service<D>>;\n\n /**\n * Create a client from a {@link WorkflowDefinition}.\n *\n * @param key the key of the workflow.\n */\n workflowClient<D>(\n opts: WorkflowDefinitionFrom<D>,\n key: string\n ): IngressWorkflowClient<Workflow<D>>;\n\n /**\n * Create a client from a {@link VirtualObjectDefinition}.\n * @param key the key of the virtual object.\n */\n objectClient<D>(\n opts: VirtualObjectDefinitionFrom<D>,\n key: string\n ): IngressClient<VirtualObject<D>>;\n\n /**\n * Create a send client from a {@link ServiceDefinition}.\n */\n serviceSendClient<D>(\n opts: ServiceDefinitionFrom<D>\n ): IngressSendClient<Service<D>>;\n\n /**\n * Create a send client from a {@link VirtualObjectDefinition}.\n */\n objectSendClient<D>(\n opts: VirtualObjectDefinitionFrom<D>,\n key: string\n ): IngressSendClient<VirtualObject<D>>;\n\n /**\n * Create a request/response client from a service interface / `Descriptor`.\n *\n * @example\n * ```ts\n * ingress.client(greeter).greet(req); // service\n * ingress.client(counter, \"k\").add(1); // virtual object / workflow\n * ```\n */\n client<P extends string, H extends Record<string, HandlerDescriptor>>(\n serviceInterface: ServiceDescriptor<P, H>\n ): IngressClientFromDescriptors<H>;\n client<P extends string, H extends Record<string, HandlerDescriptor>>(\n objectOrWorkflowInterface:\n | ObjectDescriptor<P, H>\n | WorkflowDescriptor<P, H>,\n key: string\n ): IngressClientFromDescriptors<H>;\n\n /**\n * Send-client (one-way) counterpart of {@link Ingress.client}.\n *\n * @example\n * ```ts\n * ingress.sendClient(greeter).greet(req);\n * ingress.sendClient(counter, \"k\").add(1);\n * ```\n */\n sendClient<P extends string, H extends Record<string, HandlerDescriptor>>(\n serviceInterface: ServiceDescriptor<P, H>\n ): IngressSendClientFromDescriptors<H>;\n sendClient<P extends string, H extends Record<string, HandlerDescriptor>>(\n objectOrWorkflowInterface:\n | ObjectDescriptor<P, H>\n | WorkflowDescriptor<P, H>,\n key: string\n ): IngressSendClientFromDescriptors<H>;\n\n /**\n * Resolve an awakeable from the ingress client.\n */\n resolveAwakeable<T>(\n id: string,\n payload?: T,\n payloadSerde?: Serde<T>\n ): Promise<void>;\n\n /**\n * Reject an awakeable from the ingress client.\n */\n rejectAwakeable(id: string, reason: string): Promise<void>;\n\n /**\n * Obtain the result of a service that was asynchronously submitted (via a sendClient).\n *\n * @param send either the send response or the workflow submission as obtained by the respective clients.\n */\n result<T>(\n send: Send<T> | WorkflowSubmission<T>,\n resultSerde?: Serde<T>\n ): Promise<T>;\n\n /** Generic request-response call. Routes directly by service name without a typed definition. */\n call<I = Uint8Array, O = Uint8Array>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n /**\n * Route this call within the given scope. See {@link Ingress.scope}.\n *\n * *NOTE:* This API is experimental. To use it you need a restate-server >= 1.7,\n * configured to enable\n * [service protocol v7](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#service-protocol-v7)\n * and [flow control](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#flow-control).\n * For example, start the restate-server with the environment variables\n * `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n *\n * @experimental\n */\n scope?: string;\n opts?: Opts<I, O>;\n }): Promise<O>;\n\n /** Generic fire-and-forget send. Routes directly by service name without a typed definition. */\n send<I = Uint8Array>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n /**\n * Route this send within the given scope. See {@link Ingress.scope}.\n *\n * *NOTE:* This API is experimental. To use it you need a restate-server >= 1.7,\n * configured to enable\n * [service protocol v7](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#service-protocol-v7)\n * and [flow control](https://github.com/restatedev/restate/blob/main/release-notes/v1.7.0.md#flow-control).\n * For example, start the restate-server with the environment variables\n * `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n *\n * @experimental\n */\n scope?: string;\n opts?: SendOpts<I>;\n }): Promise<Send>;\n\n /**\n * Returns a {@link ScopedIngress} that routes all calls within the given scope.\n *\n * **NOTE:** This API is in preview and is not enabled by default.\n * To use it in restate-server 1.7, enable the flow control and protocol v7 experimental features,\n * via `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n * These can be enabled only on **new clusters**, for more info check out https://docs.restate.dev/services/flow-control#enabling-flow-control.\n * If these experimental features aren't enabled, the invocation won't be ingested and the client request fails.\n *\n * A scope is a sub-grouping of resources (invocations, virtual object instances, workflow\n * instances, concurrency limits) within the Restate cluster.\n * It becomes part of the target identity tuple:\n * - `scope, service, handler, idempotencyKey?`\n * - `scope, virtualObject, objectKey, handler, idempotencyKey?`\n * - `scope, workflow, workflowKey, handler`\n *\n * Under the hood, the scope contributes to the partition key, so all resources in a scope get co-located by the restate-server.\n *\n * Omitting the scope (i.e. using the regular `serviceClient` / `workflowClient` methods)\n * is equivalent to calling with no scope, which is the existing behavior.\n *\n * The scope key must consist only of `[a-zA-Z0-9_.-]` characters, with 1 <= length <= 36 chars.\n *\n * @example\n * ```ts\n * // Route a call into a named scope\n * await ingress.scope(\"tenant-123\").serviceClient(MyService).process(payload);\n *\n * // Idempotency keys are scoped — \"req-1\" in \"tenant-123\" is distinct from \"req-1\" in \"tenant-456\"\n * await ingress.scope(\"tenant-123\").serviceClient(MyService)\n * .process(payload, rpc.opts({ idempotencyKey: \"req-1\" }));\n *\n * // Combine with a limit key to enforce per-scope concurrency limits\n * await ingress.scope(\"tenant-123\").workflowClient(MyWorkflow, \"wf-key\")\n * .run(input, rpc.opts({ limitKey: \"api-key/user42\" }));\n * ```\n *\n * @param scopeKey the scope identifier\n * @see https://docs.restate.dev/services/flow-control\n * @experimental\n */\n scope(scopeKey: string): ScopedIngress;\n}\n\n/**\n * An ingress client for making RPC calls within a specific scope.\n *\n * @see {@link Ingress.scope}\n * @experimental\n * @interface\n */\nexport type ScopedIngress = Pick<\n Ingress,\n | \"serviceClient\"\n | \"serviceSendClient\"\n | \"objectClient\"\n | \"objectSendClient\"\n | \"workflowClient\"\n | \"client\"\n | \"sendClient\"\n>;\n\nexport interface IngressCallOptions<I = unknown, O = unknown> {\n /**\n * Key to use for idempotency key.\n *\n * See https://docs.restate.dev/operate/invocation#invoke-a-handler-idempotently for more details.\n */\n idempotencyKey?: string;\n\n /**\n * An optional concurrency limit key within the scope.\n * A limit key can only be used in conjunction with a scope (see {@link Ingress.scope}).\n *\n * **NOTE:** This API is in preview and is not enabled by default.\n * To use it in restate-server 1.7, enable the flow control and protocol v7 experimental features,\n * via `RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true` and `RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true`.\n * These can be enabled only on **new clusters**, for more info check out https://docs.restate.dev/services/flow-control#enabling-flow-control.\n * If these experimental features aren't enabled, the invocation isn't ingested and the client request fails.\n *\n * The limit key enforces hierarchical concurrency limits on invocations sharing the same scope.\n * It can have one or two levels separated by `/` (e.g. `\"tenant1\"` or `\"tenant1/user42\"`).\n * Each level must consist only of `[a-zA-Z0-9_.-]` characters, and 1 <= length <= 36.\n *\n * The limit key is **not** part of the request identity: two calls to the same target with the\n * same scope and object key but different limit keys refer to the **same** resource instance.\n * The limit key only affects concurrency limits, not resource identity.\n *\n * @experimental\n */\n limitKey?: string;\n\n /**\n * Headers to attach to the request.\n */\n headers?: Record<string, string>;\n\n input?: Serde<I>;\n\n output?: Serde<O>;\n\n /**\n * Timeout to be used when executing the request. In milliseconds.\n *\n * Same as {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal#aborting_a_fetch_with_timeout_or_explicit_abort | AbortSignal.timeout()}.\n *\n * This field is exclusive with `signal`, and using both of them will result in a runtime failure.\n */\n timeout?: number;\n\n /**\n * Signal to abort the underlying `fetch` operation. See {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}.\n *\n * This field is exclusive with `timeout`, and using both of them will result in a runtime failure.\n */\n signal?: AbortSignal;\n}\n\nexport interface IngressSendOptions<I> extends IngressCallOptions<I, void> {\n /**\n * If set, the invocation will be enqueued now to be executed after the provided delay. In milliseconds.\n */\n delay?: number | Duration;\n}\n\nexport class Opts<I, O> {\n /**\n * Create a call configuration from the provided options.\n *\n * @param opts the call configuration\n */\n public static from<I = unknown, O = unknown>(\n opts: IngressCallOptions<I, O>\n ): Opts<I, O> {\n return new Opts(opts);\n }\n\n constructor(readonly opts: IngressCallOptions<I, O>) {}\n}\n\nexport class SendOpts<I = unknown> {\n /**\n * @param opts Create send options\n */\n public static from<I = unknown>(opts: IngressSendOptions<I>): SendOpts<I> {\n return new SendOpts(opts);\n }\n\n delay(): number | undefined {\n if (this.opts.delay !== undefined) {\n return millisOrDurationToMillis(this.opts.delay);\n }\n return undefined;\n }\n\n constructor(readonly opts: IngressSendOptions<I>) {}\n}\n\nexport type InferArgType<P> = P extends [infer A, ...any[]] ? A : unknown;\n\nexport type IngressClient<M> = {\n [K in keyof M as M[K] extends never ? never : K]: M[K] extends (\n arg: any,\n ...args: infer P\n ) => PromiseLike<infer O>\n ? (...args: [...P, ...[opts?: Opts<InferArgType<P>, O>]]) => PromiseLike<O>\n : never;\n};\n\n/**\n * Typed ingress request/response client derived from a service interface's\n * handler descriptor map `H` (see `iface` in `@restatedev/restate-sdk-core`).\n * Recovers the input/output types directly from the descriptors, so a code-free\n * interface value produces a fully typed client that reuses the declared serdes.\n */\nexport type IngressClientFromDescriptors<\n H extends Record<string, HandlerDescriptor>,\n> = {\n readonly [K in keyof H]: [InferInput<H[K]>] extends [void]\n ? (\n opts?: Opts<InferInput<H[K]>, InferOutput<H[K]>>\n ) => Promise<InferOutput<H[K]>>\n : (\n input: InferInput<H[K]>,\n opts?: Opts<InferInput<H[K]>, InferOutput<H[K]>>\n ) => Promise<InferOutput<H[K]>>;\n};\n\n/** One-way (send) counterpart of {@link IngressClientFromDescriptors}. */\nexport type IngressSendClientFromDescriptors<\n H extends Record<string, HandlerDescriptor>,\n> = {\n readonly [K in keyof H]: [InferInput<H[K]>] extends [void]\n ? (opts?: SendOpts<InferInput<H[K]>>) => Promise<Send<InferOutput<H[K]>>>\n : (\n input: InferInput<H[K]>,\n opts?: SendOpts<InferInput<H[K]>>\n ) => Promise<Send<InferOutput<H[K]>>>;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace rpc {\n export const opts = <I, O>(opts: IngressCallOptions<I, O>) => Opts.from(opts);\n\n export const sendOpts = <I>(opts: IngressSendOptions<I>) =>\n SendOpts.from(opts);\n}\n\n/**\n * Represents the output of a workflow.\n */\nexport interface Output<O> {\n /**\n * Whether the output is ready.\n */\n ready: boolean;\n\n /**\n * The output of the workflow.\n */\n result: O;\n}\n\n/**\n * Represents a successful workflow submission.\n *\n */\n/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\nexport type WorkflowSubmission<T> = {\n /**\n * The invocation id of the workflow. You can use that id to\n * with the introspection tools (restate cli, logging, metrics)\n *\n */\n readonly invocationId: string;\n /**\n * Whether the workflow was accepted by this request or had already been\n * accepted.\n *\n * When automatic retries are enabled, this may be `PreviouslyAccepted` if an\n * earlier attempt from the same `workflowSubmit` call was accepted but its\n * response was not observed by the client.\n */\n readonly status: \"Accepted\" | \"PreviouslyAccepted\";\n readonly attachable: true;\n};\n\n/**\n * A client for a workflow.\n *\n * This client represents the workflow definition, with the following additional methods:\n * - `workflowSubmit` to submit the workflow.\n * - `workflowAttach` to attach to the workflow and wait for its completion\n * - `workflowOutput` to check if the workflow's output is ready/available.\n *\n * Once a workflow is submitted, it can be attached to, and the output can be retrieved.\n *\n * @typeParam M the type of the workflow.\n */\nexport type IngressWorkflowClient<M> = Omit<\n {\n [K in keyof M as M[K] extends never ? never : K]: M[K] extends (\n arg: any,\n ...args: infer P\n ) => PromiseLike<infer O>\n ? (\n ...args: [...P, ...[opts?: Opts<InferArgType<P>, O>]]\n ) => PromiseLike<O>\n : never;\n } & {\n /**\n * Submit this workflow.\n *\n * This instructs restate to execute the 'run' handler of the workflow, idempotently.\n * The workflow will be executed asynchronously, and the promise will resolve when the workflow has been accepted.\n * Please note that submitting a workflow does not wait for it to completion.\n * When automatic retries are enabled on the connection, the client safely retries\n * ambiguous submission failures using the workflow ID as the request identity.\n *\n * @param argument the same argument type as defined by the 'run' handler.\n */\n workflowSubmit: M extends Record<string, unknown>\n ? M[\"run\"] extends (arg: any, ...args: infer I) => Promise<infer O>\n ? (\n ...args: [...I, ...[opts?: SendOpts<InferArgType<I>>]]\n ) => Promise<WorkflowSubmission<O>>\n : never\n : never;\n\n /**\n * Attach to this workflow.\n *\n * This instructs restate to attach to the workflow and wait for it to complete.\n * It is only possible to 'attach' to a workflow that has been previously submitted.\n * The promise will resolve when the workflow has completed either successfully with a result,\n * or be rejected with an error.\n * This operation is safe to retry many times, and it will always return the same result.\n * When automatic retries are enabled on the connection, the client retries\n * ambiguous attach failures according to the configured retry policy.\n *\n * @returns a promise that resolves when the workflow has completed.\n */\n workflowAttach: M extends Record<string, unknown>\n ? M[\"run\"] extends (...args: any) => Promise<infer O>\n ? (opts?: Opts<void, O>) => Promise<O>\n : never\n : never;\n\n /**\n * Try retrieving the output of this workflow.\n *\n * This instructs restate to check if the workflow's output is ready/available.\n * The returned Output object will have a 'ready' field set to true if the output is ready.\n * If the output is ready, the 'result' field will contain the output.\n * note: that this operation will not wait for the workflow to complete, to do so use 'workflowAttach'.\n * When automatic retries are enabled on the connection, the client retries\n * ambiguous output retrieval failures according to the configured retry policy.\n *\n * @returns a promise that resolves if the workflow's output is ready/available.\n */\n workflowOutput: M extends Record<string, unknown>\n ? M[\"run\"] extends (...args: any) => Promise<infer O>\n ? (opts?: Opts<void, O>) => Promise<Output<O>>\n : never\n : never;\n },\n \"run\"\n>;\n\n/**\n * A send response.\n *\n * @typeParam T the type of the response.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Send<T = unknown> = {\n /**\n * The invocation id of the send.\n */\n invocationId: string;\n\n /**\n * The status of the send.\n */\n status: \"Accepted\" | \"PreviouslyAccepted\";\n\n attachable: boolean;\n};\n\nexport type IngressSendClient<M> = {\n [K in keyof M as M[K] extends never ? never : K]: M[K] extends (\n arg: any,\n ...args: infer P\n ) => PromiseLike<infer O>\n ? (\n ...args: [...P, ...[opts?: SendOpts<InferArgType<P>>]]\n ) => Promise<Send<O>>\n : never;\n};\n\n/**\n * An ambiguous ingress failure that may be retried.\n *\n * Passed to {@link RetryPolicy.shouldRetry} so a caller can inspect the failure\n * and decide whether to retry.\n */\nexport type RetryFailure =\n | {\n /** The underlying `fetch` call rejected (connection refused/reset, DNS). */\n readonly kind: \"network\";\n readonly error: unknown;\n }\n | {\n /** The server returned a non-2xx response. */\n readonly kind: \"response\";\n readonly status: number;\n readonly headers: Headers;\n /**\n * The response body, decoded as text, when the response carried a\n * non-empty body; `undefined` otherwise.\n */\n readonly body?: string;\n };\n\n/**\n * Policy controlling automatic retries of ambiguous ingress failures.\n *\n * Retries are **opt-in**: they happen only when a policy is configured (see\n * {@link ConnectionOpts.retry}) and the request is safe to repeat. Regular\n * calls require an `idempotencyKey` (see\n * {@link IngressCallOptions.idempotencyKey}); workflow submissions are\n * idempotent by workflow ID, while workflow attaches and output retrieval only\n * observe the existing workflow.\n *\n * By default the following failures are retried: network errors (the underlying\n * `fetch` rejecting) and responses with a transient status (`408`, `425`, `429`,\n * or `5xx`). A terminal error of the invocation is never retried, whatever its status code.\n * Override all of this with {@link RetryPolicy.shouldRetry}.\n */\nexport interface RetryPolicy {\n /**\n * Max number of attempts (including the initial), before giving up.\n *\n * Retrying stops as soon as **either** `maxDuration` or {@link maxAttempts} is reached.\n *\n * Defaults to `6` (the initial attempt plus up to 5 retries). Pass `false` to\n * remove the attempt bound.\n */\n maxAttempts?: number | false;\n\n /**\n * Max total duration of retries, measured from the first attempt, before\n * giving up. If a number is provided, it is interpreted as milliseconds.\n *\n * This bound is checked only when deciding whether to start another\n * attempt after a failure: it never aborts an in-flight request.\n *\n * Retrying stops as soon as **either** {@link maxDuration} or {@link maxAttempts} is reached.\n *\n * Defaults to 60 seconds. Pass `false` to remove the duration bound.\n */\n maxDuration?: Duration | number | false;\n\n /**\n * Initial backoff interval. If a number is provided, it is interpreted as\n * milliseconds. Defaults to `250` milliseconds.\n */\n initialInterval?: Duration | number;\n\n /**\n * Maximum backoff interval. If a number is provided, it is interpreted as\n * milliseconds. Defaults to `3000` milliseconds.\n */\n maxInterval?: Duration | number;\n\n /**\n * Exponentiation factor to use when computing the next retry delay.\n * Defaults to `2`.\n */\n exponentiationFactor?: number;\n\n /**\n * Whether to honor a `Retry-After` response header when the server provides\n * one. When `true` (the default), a `Retry-After` value overrides the computed\n * exponential backoff for that attempt.\n *\n * Set to `false` to always use the exponential backoff and ignore the header.\n *\n * Note that `Retry-After` never extends the number of retries: {@link maxAttempts} and\n * {@link maxDuration} is always respected regardless of this setting.\n *\n * Defaults to `true`.\n */\n respectRetryAfter?: boolean;\n\n /**\n * Decide whether a given failure should be retried. When provided, this\n * fully replaces the built-in rule (network / transient `408`/`425`/`429`/`5xx`,\n * excluding invocation-sourced errors).\n *\n * The idempotency-key gate still applies to regular invocations; workflow\n * submissions, attaches, and output retrieval remain eligible without an\n * idempotency key. The `maxAttempts` cap applies to all of them. This predicate\n * only narrows or broadens *which failures* are retryable within those bounds.\n * Compose with the built-in rule via the exported `defaultShouldRetry`.\n *\n * @param failure the failure being considered\n * @param attempt the zero-based index of the attempt that just failed\n */\n shouldRetry?: (failure: RetryFailure, attempt: number) => boolean;\n}\n\nexport type ConnectionOpts = {\n /**\n * Restate ingress URL.\n * For example: http://localhost:8080\n *\n * Optional for `connect()`: when omitted, the ingress comes from\n * `RESTATE_INGRESS_KEY` (see `connect()`).\n */\n url?: string;\n /**\n * Headers to attach on every request.\n * Use this to attach authentication headers.\n */\n headers?: Record<string, string>;\n\n /**\n * Opt in to automatic retries of ambiguous ingress failures (network errors\n * and transient HTTP statuses `408`/`425`/`429`/`5xx`, excluding errors\n * restate attributes to the invocation itself).\n *\n * Retries are **disabled by default**. Set `true` to enable the built-in\n * policy ({@link RetryPolicy}), or pass a {@link RetryPolicy} to tune it.\n *\n * Even when enabled, regular calls are retried **only** when an\n * `idempotencyKey` is set — without one a retry could double-execute a\n * non-idempotent invocation. Workflow submissions, attaches, and output\n * retrieval are also retried: submissions are idempotent by workflow ID,\n * while attach and output operations only observe the existing workflow. If a\n * submission retry observes a workflow accepted by an earlier attempt, its\n * status is `PreviouslyAccepted`.\n */\n retry?: RetryPolicy | boolean;\n\n /**\n * Default serde to use for ingress payloads when no operation-specific serde\n * is provided. Applies to handler calls, workflow attaches/output polling,\n * awakeable resolution, and attached invocation results.\n *\n * Defaults to `restate.serde.json`.\n */\n serde?: Serde<any>;\n\n /**\n * Codec to use for input/outputs. Check {@link JournalValueCodec} for more details\n *\n * @experimental\n */\n journalValueCodec?: JournalValueCodec;\n\n /**\n * Custom fetch client\n *\n * Allows you to provide a different fetch implementation (e.g., undici fetch for HTTP/2 support).\n *\n * @defaultValue `globalThis.fetch`\n */\n fetch?: typeof globalThis.fetch;\n};\n"],"mappings":";;;AA6SA,IAAa,OAAb,MAAa,KAAW;;;;;;CAMtB,OAAc,KACZ,MACY;AACZ,SAAO,IAAI,KAAK,KAAK;;CAGvB,YAAY,AAASA,MAAgC;EAAhC;;;AAGvB,IAAa,WAAb,MAAa,SAAsB;;;;CAIjC,OAAc,KAAkB,MAA0C;AACxE,SAAO,IAAI,SAAS,KAAK;;CAG3B,QAA4B;AAC1B,MAAI,KAAK,KAAK,UAAU,OACtB,QAAO,yBAAyB,KAAK,KAAK,MAAM;;CAKpD,YAAY,AAASC,MAA6B;EAA7B;;;;;cA+CM,SAAmC,KAAK,KAAK,KAAK;kBAEjD,SAC1B,SAAS,KAAK,KAAK"}
package/dist/env.cjs ADDED
@@ -0,0 +1,94 @@
1
+
2
+ //#region src/env.ts
3
+ const INGRESS_KEY_ENV = "RESTATE_INGRESS_KEY";
4
+ /** Where to get an ingress key (Development → Configure Client), linked in every error. */
5
+ const INGRESS_KEY_URL = "https://cloud.restate.dev/to/developers/integration#configure-client";
6
+ const CLOUD_KEY_PREFIX = "rstcloudv1_";
7
+ const BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
8
+ /** The parameters an ingress key carries; anything else is ignored with a warning. */
9
+ const KNOWN_KEY_PARAMS = [
10
+ "envid",
11
+ "apikey",
12
+ "region"
13
+ ];
14
+ /** The ingress URL and bearer an ingress key stands for; see the header comment. */
15
+ function ingressFromKey(value, what = INGRESS_KEY_ENV) {
16
+ const fail = (reason) => {
17
+ throw new Error(`${what} is not a Restate Cloud key (${reason}); expected ${CLOUD_KEY_PREFIX}<base58> — copy it again from ${INGRESS_KEY_URL}`);
18
+ };
19
+ const corrupted = () => fail("it is truncated or corrupted");
20
+ const trimmed = value.trim();
21
+ if (!trimmed.startsWith(CLOUD_KEY_PREFIX)) return fail(`it does not start with ${CLOUD_KEY_PREFIX}`);
22
+ const encoded = trimmed.slice(11);
23
+ if (encoded === "") return corrupted();
24
+ let query;
25
+ try {
26
+ query = new TextDecoder("utf-8", { fatal: true }).decode(base58Decode(encoded));
27
+ } catch {
28
+ return corrupted();
29
+ }
30
+ if (!/^[\x21-\x7e]+$/.test(query)) return corrupted();
31
+ const params = /* @__PURE__ */ new Map();
32
+ const unknown = [];
33
+ for (const [name, param] of new URLSearchParams(query).entries()) {
34
+ if (name === "") return corrupted();
35
+ if (!KNOWN_KEY_PARAMS.includes(name)) unknown.push(name);
36
+ else if (params.has(name)) return fail("it is malformed");
37
+ else params.set(name, param);
38
+ }
39
+ if (unknown.length > 0) console.warn(`clients.connect(): ${what} carries data this version does not understand (${unknown.map((name) => JSON.stringify(name)).join(", ")}); ignoring it — a newer version may need it`);
40
+ const environmentId = params.get("envid");
41
+ const match = environmentId === void 0 ? null : /^env_([A-Za-z0-9_-]+)$/.exec(environmentId);
42
+ if (match === null) return fail("it is incomplete or malformed");
43
+ const region = params.get("region")?.toLowerCase();
44
+ if (region === void 0 || !/^[a-z0-9-]+(\.[a-z0-9-]+)*$/.test(region)) return fail("it is incomplete or malformed");
45
+ const token = params.get("apikey");
46
+ if (token === void 0 || token === "") throw new Error(`${what} carries no API key; copy it again from ${INGRESS_KEY_URL}`);
47
+ if (!/^[\x21-\x7e]+$/.test(token)) return fail("the API key contains characters that cannot travel in an HTTP header");
48
+ return {
49
+ url: `https://${match[1].toLowerCase()}.env.${region}:8080`,
50
+ token
51
+ };
52
+ }
53
+ /** Decode base58 (Bitcoin alphabet); throws on a character outside it. */
54
+ function base58Decode(text) {
55
+ const digits = [];
56
+ for (const char of text) {
57
+ let carry = BASE58_ALPHABET.indexOf(char);
58
+ if (carry < 0) throw new Error(`not base58: ${JSON.stringify(char)}`);
59
+ for (let i = 0; i < digits.length; i++) {
60
+ carry += digits[i] * 58;
61
+ digits[i] = carry & 255;
62
+ carry >>= 8;
63
+ }
64
+ while (carry > 0) {
65
+ digits.push(carry & 255);
66
+ carry >>= 8;
67
+ }
68
+ }
69
+ let zeros = 0;
70
+ while (zeros < text.length && text[zeros] === "1") zeros++;
71
+ const out = new Uint8Array(zeros + digits.length);
72
+ for (let i = 0; i < digits.length; i++) out[zeros + i] = digits[digits.length - 1 - i];
73
+ return out;
74
+ }
75
+ /** Resolve the connection options: the `url` (and bearer) from `RESTATE_INGRESS_KEY` when not given. */
76
+ function resolveConnectionOpts(opts) {
77
+ if (opts.url !== void 0 && opts.url !== "") return {
78
+ ...opts,
79
+ url: opts.url
80
+ };
81
+ const value = process.env[INGRESS_KEY_ENV];
82
+ if (value === void 0 || value === "") throw new Error(`clients.connect(): url is required — pass { url } (e.g. "http://localhost:8080") or set ${INGRESS_KEY_ENV} (create one at ${INGRESS_KEY_URL})`);
83
+ const { url, token } = ingressFromKey(value);
84
+ const headers = { ...opts.headers ?? {} };
85
+ if (!Object.keys(headers).some((name) => name.toLowerCase() === "authorization")) headers["Authorization"] = `Bearer ${token}`;
86
+ return {
87
+ ...opts,
88
+ url,
89
+ headers
90
+ };
91
+ }
92
+
93
+ //#endregion
94
+ exports.resolveConnectionOpts = resolveConnectionOpts;
package/dist/env.js ADDED
@@ -0,0 +1,94 @@
1
+ //#region src/env.ts
2
+ const INGRESS_KEY_ENV = "RESTATE_INGRESS_KEY";
3
+ /** Where to get an ingress key (Development → Configure Client), linked in every error. */
4
+ const INGRESS_KEY_URL = "https://cloud.restate.dev/to/developers/integration#configure-client";
5
+ const CLOUD_KEY_PREFIX = "rstcloudv1_";
6
+ const BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
7
+ /** The parameters an ingress key carries; anything else is ignored with a warning. */
8
+ const KNOWN_KEY_PARAMS = [
9
+ "envid",
10
+ "apikey",
11
+ "region"
12
+ ];
13
+ /** The ingress URL and bearer an ingress key stands for; see the header comment. */
14
+ function ingressFromKey(value, what = INGRESS_KEY_ENV) {
15
+ const fail = (reason) => {
16
+ throw new Error(`${what} is not a Restate Cloud key (${reason}); expected ${CLOUD_KEY_PREFIX}<base58> — copy it again from ${INGRESS_KEY_URL}`);
17
+ };
18
+ const corrupted = () => fail("it is truncated or corrupted");
19
+ const trimmed = value.trim();
20
+ if (!trimmed.startsWith(CLOUD_KEY_PREFIX)) return fail(`it does not start with ${CLOUD_KEY_PREFIX}`);
21
+ const encoded = trimmed.slice(11);
22
+ if (encoded === "") return corrupted();
23
+ let query;
24
+ try {
25
+ query = new TextDecoder("utf-8", { fatal: true }).decode(base58Decode(encoded));
26
+ } catch {
27
+ return corrupted();
28
+ }
29
+ if (!/^[\x21-\x7e]+$/.test(query)) return corrupted();
30
+ const params = /* @__PURE__ */ new Map();
31
+ const unknown = [];
32
+ for (const [name, param] of new URLSearchParams(query).entries()) {
33
+ if (name === "") return corrupted();
34
+ if (!KNOWN_KEY_PARAMS.includes(name)) unknown.push(name);
35
+ else if (params.has(name)) return fail("it is malformed");
36
+ else params.set(name, param);
37
+ }
38
+ if (unknown.length > 0) console.warn(`clients.connect(): ${what} carries data this version does not understand (${unknown.map((name) => JSON.stringify(name)).join(", ")}); ignoring it — a newer version may need it`);
39
+ const environmentId = params.get("envid");
40
+ const match = environmentId === void 0 ? null : /^env_([A-Za-z0-9_-]+)$/.exec(environmentId);
41
+ if (match === null) return fail("it is incomplete or malformed");
42
+ const region = params.get("region")?.toLowerCase();
43
+ if (region === void 0 || !/^[a-z0-9-]+(\.[a-z0-9-]+)*$/.test(region)) return fail("it is incomplete or malformed");
44
+ const token = params.get("apikey");
45
+ if (token === void 0 || token === "") throw new Error(`${what} carries no API key; copy it again from ${INGRESS_KEY_URL}`);
46
+ if (!/^[\x21-\x7e]+$/.test(token)) return fail("the API key contains characters that cannot travel in an HTTP header");
47
+ return {
48
+ url: `https://${match[1].toLowerCase()}.env.${region}:8080`,
49
+ token
50
+ };
51
+ }
52
+ /** Decode base58 (Bitcoin alphabet); throws on a character outside it. */
53
+ function base58Decode(text) {
54
+ const digits = [];
55
+ for (const char of text) {
56
+ let carry = BASE58_ALPHABET.indexOf(char);
57
+ if (carry < 0) throw new Error(`not base58: ${JSON.stringify(char)}`);
58
+ for (let i = 0; i < digits.length; i++) {
59
+ carry += digits[i] * 58;
60
+ digits[i] = carry & 255;
61
+ carry >>= 8;
62
+ }
63
+ while (carry > 0) {
64
+ digits.push(carry & 255);
65
+ carry >>= 8;
66
+ }
67
+ }
68
+ let zeros = 0;
69
+ while (zeros < text.length && text[zeros] === "1") zeros++;
70
+ const out = new Uint8Array(zeros + digits.length);
71
+ for (let i = 0; i < digits.length; i++) out[zeros + i] = digits[digits.length - 1 - i];
72
+ return out;
73
+ }
74
+ /** Resolve the connection options: the `url` (and bearer) from `RESTATE_INGRESS_KEY` when not given. */
75
+ function resolveConnectionOpts(opts) {
76
+ if (opts.url !== void 0 && opts.url !== "") return {
77
+ ...opts,
78
+ url: opts.url
79
+ };
80
+ const value = process.env[INGRESS_KEY_ENV];
81
+ if (value === void 0 || value === "") throw new Error(`clients.connect(): url is required — pass { url } (e.g. "http://localhost:8080") or set ${INGRESS_KEY_ENV} (create one at ${INGRESS_KEY_URL})`);
82
+ const { url, token } = ingressFromKey(value);
83
+ const headers = { ...opts.headers ?? {} };
84
+ if (!Object.keys(headers).some((name) => name.toLowerCase() === "authorization")) headers["Authorization"] = `Bearer ${token}`;
85
+ return {
86
+ ...opts,
87
+ url,
88
+ headers
89
+ };
90
+ }
91
+
92
+ //#endregion
93
+ export { resolveConnectionOpts };
94
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","names":["query: string","unknown: string[]","digits: number[]"],"sources":["../src/env.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2026 - Restate Software, Inc., Restate GmbH\n *\n * This file is part of the Restate SDK for Node.js/TypeScript,\n * which is released under the MIT license.\n *\n * You can find a copy of the license in file LICENSE in the root\n * directory of this repository or package, or at\n * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE\n */\n\n// Ingress connection from RESTATE_INGRESS_KEY.\n//\n// `connect()` without a `url` reads `RESTATE_INGRESS_KEY`, an ingress key from\n// the Cloud UI (Development → Configure Client). Explicit options always win;\n// with neither a `url` nor the variable, `connect()` fails fast, as it always\n// required a `url`.\n//\n// INTERNAL: the key is opaque to users (public docs and errors only say \"copy\n// it again\"). Its format, shared with the SDK's connect key, is\n//\n// rstcloudv1_<base58>\n//\n// where the base58 part (Bitcoin alphabet) encodes the query string\n// `envid=env_…&apikey=key_…&region=eu.restate.cloud`. The ingress is\n// `https://<envid minus env_>.env.<region>:8080` and the API key is the\n// bearer.\n\nimport type { ConnectionOpts } from \"./api.js\";\n\nexport const INGRESS_KEY_ENV = \"RESTATE_INGRESS_KEY\";\n/** Where to get an ingress key (Development → Configure Client), linked in every error. */\nconst INGRESS_KEY_URL =\n \"https://cloud.restate.dev/to/developers/integration#configure-client\";\n\nconst CLOUD_KEY_PREFIX = \"rstcloudv1_\";\nconst BASE58_ALPHABET =\n \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n/** The parameters an ingress key carries; anything else is ignored with a warning. */\nconst KNOWN_KEY_PARAMS = [\"envid\", \"apikey\", \"region\"];\n\n/** The ingress URL and bearer an ingress key stands for; see the header comment. */\nfunction ingressFromKey(\n value: string,\n what: string = INGRESS_KEY_ENV\n): { url: string; token: string } {\n // Reasons never echo parts of the value (the whole thing is a credential)\n // and never describe the encoding: the key is opaque, the fix is a fresh copy.\n const fail = (reason: string): never => {\n throw new Error(\n `${what} is not a Restate Cloud key (${reason}); expected ${CLOUD_KEY_PREFIX}<base58> — copy it again from ${INGRESS_KEY_URL}`\n );\n };\n const corrupted = () => fail(\"it is truncated or corrupted\");\n const trimmed = value.trim();\n if (!trimmed.startsWith(CLOUD_KEY_PREFIX)) {\n return fail(`it does not start with ${CLOUD_KEY_PREFIX}`);\n }\n const encoded = trimmed.slice(CLOUD_KEY_PREFIX.length);\n if (encoded === \"\") return corrupted();\n let query: string;\n try {\n query = new TextDecoder(\"utf-8\", { fatal: true }).decode(\n base58Decode(encoded)\n );\n } catch {\n return corrupted();\n }\n if (!/^[\\x21-\\x7e]+$/.test(query)) return corrupted();\n\n const params = new Map<string, string>();\n const unknown: string[] = [];\n for (const [name, param] of new URLSearchParams(query).entries()) {\n if (name === \"\") return corrupted();\n if (!KNOWN_KEY_PARAMS.includes(name)) unknown.push(name);\n else if (params.has(name)) return fail(\"it is malformed\");\n else params.set(name, param);\n }\n if (unknown.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `clients.connect(): ${what} carries data this version does not understand (${unknown.map((name) => JSON.stringify(name)).join(\", \")}); ignoring it — a newer version may need it`\n );\n }\n\n const environmentId = params.get(\"envid\");\n const match =\n environmentId === undefined\n ? null\n : /^env_([A-Za-z0-9_-]+)$/.exec(environmentId);\n if (match === null) return fail(\"it is incomplete or malformed\");\n // Hosts are case-insensitive; the UI writes them lowercase.\n const region = params.get(\"region\")?.toLowerCase();\n if (region === undefined || !/^[a-z0-9-]+(\\.[a-z0-9-]+)*$/.test(region)) {\n return fail(\"it is incomplete or malformed\");\n }\n const token = params.get(\"apikey\");\n if (token === undefined || token === \"\") {\n throw new Error(\n `${what} carries no API key; copy it again from ${INGRESS_KEY_URL}`\n );\n }\n if (!/^[\\x21-\\x7e]+$/.test(token)) {\n return fail(\n \"the API key contains characters that cannot travel in an HTTP header\"\n );\n }\n return {\n url: `https://${match[1]!.toLowerCase()}.env.${region}:8080`,\n token,\n };\n}\n\n/** Decode base58 (Bitcoin alphabet); throws on a character outside it. */\nfunction base58Decode(text: string): Uint8Array {\n // Little-endian base-256 digits, multiplied up one base58 digit at a time.\n const digits: number[] = [];\n for (const char of text) {\n let carry = BASE58_ALPHABET.indexOf(char);\n if (carry < 0) throw new Error(`not base58: ${JSON.stringify(char)}`);\n for (let i = 0; i < digits.length; i++) {\n carry += digits[i]! * 58;\n digits[i] = carry & 0xff;\n carry >>= 8;\n }\n while (carry > 0) {\n digits.push(carry & 0xff);\n carry >>= 8;\n }\n }\n // Each leading `1` is a leading zero byte.\n let zeros = 0;\n while (zeros < text.length && text[zeros] === \"1\") zeros++;\n const out = new Uint8Array(zeros + digits.length);\n for (let i = 0; i < digits.length; i++) {\n out[zeros + i] = digits[digits.length - 1 - i]!;\n }\n return out;\n}\n\n/** Connection options with the ingress URL settled. */\nexport type ResolvedConnectionOpts = ConnectionOpts & { url: string };\n\n/** Resolve the connection options: the `url` (and bearer) from `RESTATE_INGRESS_KEY` when not given. */\nexport function resolveConnectionOpts(\n opts: ConnectionOpts\n): ResolvedConnectionOpts {\n if (opts.url !== undefined && opts.url !== \"\") {\n return { ...opts, url: opts.url };\n }\n const value = process.env[INGRESS_KEY_ENV];\n if (value === undefined || value === \"\") {\n throw new Error(\n `clients.connect(): url is required — pass { url } (e.g. \"http://localhost:8080\") or set ${INGRESS_KEY_ENV} (create one at ${INGRESS_KEY_URL})`\n );\n }\n const { url, token } = ingressFromKey(value);\n const headers = { ...(opts.headers ?? {}) };\n const hasAuthorization = Object.keys(headers).some(\n (name) => name.toLowerCase() === \"authorization\"\n );\n if (!hasAuthorization) headers[\"Authorization\"] = `Bearer ${token}`;\n return { ...opts, url, headers };\n}\n"],"mappings":";AA8BA,MAAa,kBAAkB;;AAE/B,MAAM,kBACJ;AAEF,MAAM,mBAAmB;AACzB,MAAM,kBACJ;;AAEF,MAAM,mBAAmB;CAAC;CAAS;CAAU;CAAS;;AAGtD,SAAS,eACP,OACA,OAAe,iBACiB;CAGhC,MAAM,QAAQ,WAA0B;AACtC,QAAM,IAAI,MACR,GAAG,KAAK,+BAA+B,OAAO,cAAc,iBAAiB,gCAAgC,kBAC9G;;CAEH,MAAM,kBAAkB,KAAK,+BAA+B;CAC5D,MAAM,UAAU,MAAM,MAAM;AAC5B,KAAI,CAAC,QAAQ,WAAW,iBAAiB,CACvC,QAAO,KAAK,0BAA0B,mBAAmB;CAE3D,MAAM,UAAU,QAAQ,MAAM,GAAwB;AACtD,KAAI,YAAY,GAAI,QAAO,WAAW;CACtC,IAAI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K,MAAM,QAAQ,MAAM;EACvB,IAAI,QAAQ,gBAAgB,QAAQ,KAAK;AACzC,MAAI,QAAQ,EAAG,OAAM,IAAI,MAAM,eAAe,KAAK,UAAU,KAAK,GAAG;AACrE,OAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,YAAS,OAAO,KAAM;AACtB,UAAO,KAAK,QAAQ;AACpB,aAAU;;AAEZ,SAAO,QAAQ,GAAG;AAChB,UAAO,KAAK,QAAQ,IAAK;AACzB,aAAU;;;CAId,IAAI,QAAQ;AACZ,QAAO,QAAQ,KAAK,UAAU,KAAK,WAAW,IAAK;CACnD,MAAM,MAAM,IAAI,WAAW,QAAQ,OAAO,OAAO;AACjD,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,KAAI,QAAQ,KAAK,OAAO,OAAO,SAAS,IAAI;AAE9C,QAAO;;;AAOT,SAAgB,sBACd,MACwB;AACxB,KAAI,KAAK,QAAQ,UAAa,KAAK,QAAQ,GACzC,QAAO;EAAE,GAAG;EAAM,KAAK,KAAK;EAAK;CAEnC,MAAM,QAAQ,QAAQ,IAAI;AAC1B,KAAI,UAAU,UAAa,UAAU,GACnC,OAAM,IAAI,MACR,2FAA2F,gBAAgB,kBAAkB,gBAAgB,GAC9I;CAEH,MAAM,EAAE,KAAK,UAAU,eAAe,MAAM;CAC5C,MAAM,UAAU,EAAE,GAAI,KAAK,WAAW,EAAE,EAAG;AAI3C,KAAI,CAHqB,OAAO,KAAK,QAAQ,CAAC,MAC3C,SAAS,KAAK,aAAa,KAAK,gBAClC,CACsB,SAAQ,mBAAmB,UAAU;AAC5D,QAAO;EAAE,GAAG;EAAM;EAAK;EAAS"}
package/dist/ingress.cjs CHANGED
@@ -1,18 +1,29 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_api = require('./api.cjs');
3
+ const require_env = require('./env.cjs');
3
4
  const require_retry = require('./retry.cjs');
4
5
  let __restatedev_restate_sdk_core = require("@restatedev/restate-sdk-core");
5
6
  __restatedev_restate_sdk_core = require_rolldown_runtime.__toESM(__restatedev_restate_sdk_core);
6
7
 
7
8
  //#region src/ingress.ts
8
9
  /**
9
- * Connect to the restate Ingress
10
+ * Connect to the Restate ingress.
11
+ *
12
+ * With a `url`, exactly that. Without one, the ingress is taken from
13
+ * `RESTATE_INGRESS_KEY`, the ingress key from the Cloud UI (Development →
14
+ * Configure Client).
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const rs = connect({ url: "http://localhost:8080" }); // a local Restate
19
+ * const cloud = connect(); // uses RESTATE_INGRESS_KEY
20
+ * ```
10
21
  *
11
22
  * @param opts connection options
12
- * @returns a connection the the restate ingress
23
+ * @returns a connection to the Restate ingress
13
24
  */
14
- function connect(opts) {
15
- return new HttpIngress(opts);
25
+ function connect(opts = {}) {
26
+ return new HttpIngress(require_env.resolveConnectionOpts(opts));
16
27
  }
17
28
  var HttpCallError = class extends Error {
18
29
  constructor(status, responseText, message) {
@@ -3,12 +3,22 @@ import { ConnectionOpts, Ingress } from "./api.cjs";
3
3
  //#region src/ingress.d.ts
4
4
 
5
5
  /**
6
- * Connect to the restate Ingress
6
+ * Connect to the Restate ingress.
7
+ *
8
+ * With a `url`, exactly that. Without one, the ingress is taken from
9
+ * `RESTATE_INGRESS_KEY`, the ingress key from the Cloud UI (Development →
10
+ * Configure Client).
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const rs = connect({ url: "http://localhost:8080" }); // a local Restate
15
+ * const cloud = connect(); // uses RESTATE_INGRESS_KEY
16
+ * ```
7
17
  *
8
18
  * @param opts connection options
9
- * @returns a connection the the restate ingress
19
+ * @returns a connection to the Restate ingress
10
20
  */
11
- declare function connect(opts: ConnectionOpts): Ingress;
21
+ declare function connect(opts?: ConnectionOpts): Ingress;
12
22
  declare class HttpCallError extends Error {
13
23
  readonly status: number;
14
24
  readonly responseText: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ingress.d.cts","names":[],"sources":["../src/ingress.ts"],"sourcesContent":[],"mappings":";;;;;;AA8CA;AAgBA;;;iBAhBgB,OAAA,OAAc,iBAAiB;cAgBlC,aAAA,SAAsB,KAAA"}
1
+ {"version":3,"file":"ingress.d.cts","names":[],"sources":["../src/ingress.ts"],"sourcesContent":[],"mappings":";;;;;;AAyDA;AAgBA;;;;;;;;;;;;;iBAhBgB,OAAA,QAAc,iBAAsB;cAgBvC,aAAA,SAAsB,KAAA"}
package/dist/ingress.d.ts CHANGED
@@ -3,12 +3,22 @@ import { ConnectionOpts, Ingress } from "./api.js";
3
3
  //#region src/ingress.d.ts
4
4
 
5
5
  /**
6
- * Connect to the restate Ingress
6
+ * Connect to the Restate ingress.
7
+ *
8
+ * With a `url`, exactly that. Without one, the ingress is taken from
9
+ * `RESTATE_INGRESS_KEY`, the ingress key from the Cloud UI (Development →
10
+ * Configure Client).
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const rs = connect({ url: "http://localhost:8080" }); // a local Restate
15
+ * const cloud = connect(); // uses RESTATE_INGRESS_KEY
16
+ * ```
7
17
  *
8
18
  * @param opts connection options
9
- * @returns a connection the the restate ingress
19
+ * @returns a connection to the Restate ingress
10
20
  */
11
- declare function connect(opts: ConnectionOpts): Ingress;
21
+ declare function connect(opts?: ConnectionOpts): Ingress;
12
22
  declare class HttpCallError extends Error {
13
23
  readonly status: number;
14
24
  readonly responseText: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ingress.d.ts","names":[],"sources":["../src/ingress.ts"],"sourcesContent":[],"mappings":";;;;;;AA8CA;AAgBA;;;iBAhBgB,OAAA,OAAc,iBAAiB;cAgBlC,aAAA,SAAsB,KAAA"}
1
+ {"version":3,"file":"ingress.d.ts","names":[],"sources":["../src/ingress.ts"],"sourcesContent":[],"mappings":";;;;;;AAyDA;AAgBA;;;;;;;;;;;;;iBAhBgB,OAAA,QAAc,iBAAsB;cAgBvC,aAAA,SAAsB,KAAA"}
package/dist/ingress.js CHANGED
@@ -1,16 +1,27 @@
1
1
  import { Opts, SendOpts } from "./api.js";
2
+ import { resolveConnectionOpts } from "./env.js";
2
3
  import { abortableSleep, backoffDelay, defaultShouldRetry, parseRetryAfter, resolveRetryPolicy } from "./retry.js";
3
4
  import { serde } from "@restatedev/restate-sdk-core";
4
5
 
5
6
  //#region src/ingress.ts
6
7
  /**
7
- * Connect to the restate Ingress
8
+ * Connect to the Restate ingress.
9
+ *
10
+ * With a `url`, exactly that. Without one, the ingress is taken from
11
+ * `RESTATE_INGRESS_KEY`, the ingress key from the Cloud UI (Development →
12
+ * Configure Client).
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const rs = connect({ url: "http://localhost:8080" }); // a local Restate
17
+ * const cloud = connect(); // uses RESTATE_INGRESS_KEY
18
+ * ```
8
19
  *
9
20
  * @param opts connection options
10
- * @returns a connection the the restate ingress
21
+ * @returns a connection to the Restate ingress
11
22
  */
12
- function connect(opts) {
13
- return new HttpIngress(opts);
23
+ function connect(opts = {}) {
24
+ return new HttpIngress(resolveConnectionOpts(opts));
14
25
  }
15
26
  var HttpCallError = class extends Error {
16
27
  constructor(status, responseText, message) {
@@ -1 +1 @@
1
- {"version":3,"file":"ingress.js","names":["status: number","responseText: string","message: string","parameter: unknown","opts: Opts<unknown, unknown> | SendOpts<unknown> | undefined","response: Response","errorBody: string","url: string","opts: ConnectionOpts","res: Send","opts","body","serde"],"sources":["../src/ingress.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// The client methods implement the overloaded `Ingress` interface (classic\n// definition OR service interface), which requires an `any` return on the\n// implementation signatures.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n type Serde,\n serde,\n type JournalValueCodec,\n type HandlerDescriptor,\n} from \"@restatedev/restate-sdk-core\";\nimport {\n ConnectionOpts,\n Ingress,\n Output,\n Send,\n ScopedIngress,\n WorkflowSubmission,\n} from \"./api.js\";\n\nimport { Opts, SendOpts } from \"./api.js\";\nimport {\n abortableSleep,\n backoffDelay,\n defaultShouldRetry,\n parseRetryAfter,\n type ResolvedRetryPolicy,\n resolveRetryPolicy,\n} from \"./retry.js\";\n\n/**\n * Connect to the restate Ingress\n *\n * @param opts connection options\n * @returns a connection the the restate ingress\n */\nexport function connect(opts: ConnectionOpts): Ingress {\n return new HttpIngress(opts);\n}\n\n/**\n * The runtime shape a client method needs off a definition value: the service\n * name, plus (for interface / `implement()` values) the per-handler serde\n * descriptors. Classic definitions carry no `_handlers`, so serde reuse is a\n * no-op for them.\n */\ntype ClientTarget = {\n name: string;\n _handlers?: Record<string, HandlerDescriptor>;\n _kind?: \"service\" | \"object\" | \"workflow\";\n};\n\nexport class HttpCallError extends Error {\n constructor(\n public readonly status: number,\n public readonly responseText: string,\n public override readonly message: string\n ) {\n super(message);\n }\n}\n\ntype InvocationParameters<I> = {\n component: string;\n handler: string;\n key?: string;\n send?: boolean;\n opts?: Opts<I, unknown> | SendOpts<I>;\n parameter?: I;\n method?: string;\n scope?: string;\n /** Serdes declared by the callee's service interface, if the client was built from one. */\n handlerDesc?: HandlerDescriptor;\n};\n\nfunction optsFromArgs(args: unknown[]): {\n parameter?: unknown;\n opts?: Opts<unknown, unknown> | SendOpts<unknown>;\n} {\n let parameter: unknown;\n let opts: Opts<unknown, unknown> | SendOpts<unknown> | undefined;\n switch (args.length) {\n case 0: {\n break;\n }\n case 1: {\n if (args[0] instanceof Opts) {\n opts = args[0];\n } else if (args[0] instanceof SendOpts) {\n opts = args[0];\n } else {\n parameter = args[0];\n }\n break;\n }\n case 2: {\n parameter = args[0];\n if (args[1] instanceof Opts) {\n opts = args[1];\n } else if (args[1] instanceof SendOpts) {\n opts = args[1];\n } else {\n throw new TypeError(\n \"The second argument must be either Opts or SendOpts\"\n );\n }\n break;\n }\n default: {\n throw new TypeError(\"unexpected number of arguments\");\n }\n }\n return {\n parameter,\n opts,\n };\n}\n\nconst IDEMPOTENCY_KEY_HEADER = \"idempotency-key\";\nconst LIMIT_KEY_HEADER = \"x-restate-limit-key\";\n// Carries the 1-based attempt number on every request so the server can observe\n// how many times the client has (re)issued it.\nconst ATTEMPT_HEADER = \"x-restateclient-retry-attempt\";\n\nconst getFetch = (opts: ConnectionOpts): NonNullable<ConnectionOpts[\"fetch\"]> =>\n opts.fetch ?? globalThis.fetch;\n\nconst fetchWithRetries = async (\n opts: ConnectionOpts,\n url: string,\n init: RequestInit,\n callOpts: Opts<unknown, unknown> | SendOpts<unknown> | undefined,\n retryPolicy: ResolvedRetryPolicy | undefined\n): Promise<Uint8Array> => {\n const userSignal = callOpts?.opts.signal;\n const timeout = callOpts?.opts.timeout;\n if (userSignal !== undefined && timeout !== undefined) {\n // The caller configured two mutually exclusive ways to abort each attempt.\n throw new Error(\n \"You can't specify both signal and timeout options at the same time\"\n );\n }\n // A fresh timeout signal is minted per attempt below — a single\n // AbortSignal.timeout() would already be aborted on the second attempt.\n const attemptSignal = (): AbortSignal | undefined =>\n userSignal ??\n (timeout !== undefined ? AbortSignal.timeout(timeout) : undefined);\n const shouldRetry = retryPolicy?.shouldRetry ?? defaultShouldRetry;\n\n // Whether waiting `delay` and then starting the next attempt would still fall\n // within the maxDuration budget (measured from the first attempt; a non-finite\n // maxDuration disables the bound). Checked *after* the delay is known so we\n // never sleep out a backoff — or a long Retry-After — only to give up on the\n // attempt it precedes. This is a decision-time gate only: it never aborts an\n // in-flight request. The maxAttempts count is gated separately, before the\n // delay is computed.\n const startTime = Date.now();\n const nextAttemptFitsBudget = (\n policy: ResolvedRetryPolicy,\n delay: number\n ): boolean => Date.now() - startTime + delay < policy.maxDuration;\n\n // Headers are always a plain record in this codebase; carry them forward and\n // stamp the attempt number afresh on each try.\n const baseHeaders = (init.headers ?? {}) as Record<string, string>;\n\n for (let attempt = 0; ; attempt++) {\n let response: Response;\n let errorBody: string;\n try {\n response = await getFetch(opts)(url, {\n ...init,\n headers: { ...baseHeaders, [ATTEMPT_HEADER]: String(attempt + 1) },\n signal: attemptSignal(),\n });\n if (response.ok) {\n // A 2xx response was received. Keep the body read inside this try so a\n // connection failure while streaming the body is retried as ambiguous.\n return new Uint8Array(await response.arrayBuffer());\n }\n // fetch resolves normally for non-2xx statuses. Read the body here both\n // for RetryFailure inspection and the final HttpCallError.\n errorBody = await response.text();\n } catch (e) {\n // fetch rejected, or the response body failed while streaming. Both are\n // ambiguous because the server may already have processed the request.\n if (\n retryPolicy &&\n attempt < retryPolicy.maxAttempts - 1 &&\n !userSignal?.aborted &&\n shouldRetry({ kind: \"network\", error: e }, attempt)\n ) {\n // Retries are enabled, attempts remain, the caller did not abort, and\n // the policy accepted this failure. Retry only if the backoff still\n // leaves us within the duration budget.\n const delay = backoffDelay(retryPolicy, attempt);\n if (nextAttemptFitsBudget(retryPolicy, delay)) {\n await abortableSleep(delay, userSignal);\n continue;\n }\n }\n // Retries are disabled or exhausted, the caller aborted, the policy\n // rejected this failure, or the duration budget is spent.\n throw e;\n }\n if (\n retryPolicy &&\n attempt < retryPolicy.maxAttempts - 1 &&\n !userSignal?.aborted &&\n shouldRetry(\n {\n kind: \"response\",\n status: response.status,\n headers: response.headers,\n body: errorBody || undefined,\n },\n attempt\n )\n ) {\n // A non-2xx response was received, attempts remain, and the policy chose\n // to retry it (by default, transient statuses 408/425/429/5xx, unless the\n // error is attributed to the invocation via x-restate-error-source). The\n // delay is the server's Retry-After when present, else the computed\n // backoff; either way we only retry if it still fits the duration budget.\n const retryAfter = retryPolicy.respectRetryAfter\n ? parseRetryAfter(response.headers)\n : undefined;\n const delay = retryAfter ?? backoffDelay(retryPolicy, attempt);\n if (nextAttemptFitsBudget(retryPolicy, delay)) {\n await abortableSleep(delay, userSignal);\n continue;\n }\n }\n // The response is not retryable, retries are disabled or exhausted, the\n // caller aborted, or the policy rejected this response.\n throw new HttpCallError(\n response.status,\n errorBody,\n `Request failed: ${response.status}\\n${errorBody}`\n );\n }\n};\n\nconst doComponentInvocation = async <I, O>(\n opts: ConnectionOpts,\n params: InvocationParameters<I>,\n canBeRetried = Boolean(params.opts?.opts.idempotencyKey)\n): Promise<O> => {\n let attachable = false;\n //\n // ingress URL\n //\n let url: string;\n if (params.scope) {\n // Scoped path: /restate/scope/{scope}/{call|send}/{service}/{key?}/{handler}\n const pathType = params.send ? \"send\" : \"call\";\n const parts = [\n opts.url,\n \"restate/scope\",\n encodeURIComponent(params.scope),\n pathType,\n params.component,\n ];\n if (params.key) {\n parts.push(encodeURIComponent(params.key));\n }\n parts.push(params.handler);\n url = parts.join(\"/\");\n if (params.send && params.opts instanceof SendOpts) {\n const delay = params.opts.delay();\n if (delay) url += `?delay=${delay}ms`;\n }\n } else {\n const fragments = [opts.url, params.component];\n if (params.key) {\n fragments.push(encodeURIComponent(params.key));\n }\n fragments.push(params.handler);\n if (params.send ?? false) {\n if (params.opts instanceof SendOpts) {\n fragments.push(computeDelayAsIso(params.opts));\n } else {\n fragments.push(\"send\");\n }\n }\n url = fragments.join(\"/\");\n }\n //\n // request body\n //\n const inputSerde =\n params.opts?.opts.input ??\n params.handlerDesc?._inputSerde ??\n opts.serde ??\n serde.json;\n\n const { body, contentType } = serializeBodyWithContentType(\n params.parameter,\n inputSerde,\n opts.journalValueCodec\n );\n //\n // headers\n //\n const headers = {\n ...(opts.headers ?? {}),\n ...(params.opts?.opts?.headers ?? {}),\n };\n if (contentType) {\n headers[\"Content-Type\"] = contentType;\n }\n //\n // idempotency\n //\n const idempotencyKey = params.opts?.opts.idempotencyKey;\n if (idempotencyKey) {\n headers[IDEMPOTENCY_KEY_HEADER] = idempotencyKey;\n attachable = true;\n }\n //\n // limit key\n //\n const limitKey = params.opts?.opts.limitKey;\n if (limitKey) {\n headers[LIMIT_KEY_HEADER] = limitKey;\n }\n\n //\n // retries\n //\n // Regular invocations default eligibility from the idempotency key, while\n // workflow submissions opt in because the workflow ID identifies the run.\n const retryPolicy = canBeRetried ? resolveRetryPolicy(opts.retry) : undefined;\n\n //\n // make the call\n //\n const responseBuf = await fetchWithRetries(\n opts,\n url,\n {\n method: params.method ?? \"POST\",\n headers,\n body,\n },\n params.opts,\n retryPolicy\n );\n if (!params.send) {\n const decodedBuf = opts.journalValueCodec\n ? await opts.journalValueCodec.decode(responseBuf)\n : responseBuf;\n const outputSerde =\n params.opts?.opts.output ??\n params.handlerDesc?._outputSerde ??\n opts.serde ??\n serde.json;\n return outputSerde.deserialize(decodedBuf) as O;\n }\n const json = serde.json.deserialize(responseBuf) as O;\n return { ...json, attachable };\n};\n\nconst doWorkflowHandleCall = async <O>(\n opts: ConnectionOpts,\n wfName: string,\n wfKey: string,\n op: \"output\" | \"attach\",\n callOpts?: Opts<unknown, O> | SendOpts<unknown>,\n runOutputSerde?: Serde<unknown>\n): Promise<O> => {\n const outputSerde =\n callOpts?.opts.output ?? runOutputSerde ?? opts.serde ?? serde.json;\n //\n // headers\n //\n const headers = {\n ...(opts.headers ?? {}),\n };\n //\n // make the call\n //\n const url = `${opts.url}/restate/workflow/${wfName}/${encodeURIComponent(\n wfKey\n )}/${op}`;\n // Attach and output only observe the existing workflow, so both are eligible\n // when the connection has a retry policy.\n const retryPolicy = resolveRetryPolicy(opts.retry);\n\n const responseBuf = await fetchWithRetries(\n opts,\n url,\n { method: \"GET\", headers },\n callOpts,\n retryPolicy\n );\n const decodedBuf = opts.journalValueCodec\n ? await opts.journalValueCodec.decode(responseBuf)\n : responseBuf;\n return outputSerde.deserialize(decodedBuf) as O;\n};\n\nclass HttpIngress implements Ingress {\n constructor(private readonly opts: ConnectionOpts) {}\n\n private proxy(\n component: string,\n key?: string,\n send?: boolean,\n handlers?: Record<string, HandlerDescriptor>\n ) {\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation<unknown, unknown>(this.opts, {\n component,\n handler,\n key,\n parameter,\n opts,\n send,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n }\n\n serviceClient(opts: ClientTarget): any {\n return this.proxy(opts.name, undefined, undefined, opts._handlers);\n }\n\n objectClient(opts: ClientTarget, key: string): any {\n return this.proxy(opts.name, key, undefined, opts._handlers);\n }\n\n workflowClient(opts: ClientTarget, key: string): any {\n const component = opts.name;\n const handlers = opts._handlers;\n const runOutputSerde = handlers?.run?._outputSerde;\n const conn = this.opts;\n\n const workflowSubmit = async (\n ...args: unknown[]\n ): Promise<WorkflowSubmission<unknown>> => {\n const { parameter, opts } = optsFromArgs(args);\n const res: Send = await doComponentInvocation(\n conn,\n {\n component,\n handler: \"run\",\n key,\n send: true,\n parameter,\n opts,\n handlerDesc: handlers?.run,\n },\n true\n );\n\n return {\n invocationId: res.invocationId,\n status: res.status,\n attachable: true,\n };\n };\n\n const workflowAttach = (opts?: Opts<void, unknown>) =>\n doWorkflowHandleCall(\n conn,\n component,\n key,\n \"attach\",\n opts,\n runOutputSerde\n );\n\n const workflowOutput = async (\n opts?: Opts<void, unknown>\n ): Promise<Output<unknown>> => {\n try {\n const result = await doWorkflowHandleCall(\n conn,\n component,\n key,\n \"output\",\n opts,\n runOutputSerde\n );\n\n return {\n ready: true,\n result,\n };\n } catch (e) {\n if (!(e instanceof HttpCallError) || e.status !== 470) {\n throw e;\n }\n return {\n ready: false,\n get result() {\n throw new Error(\"Calling result() on a non ready workflow\");\n },\n };\n }\n };\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n if (handler === \"workflowSubmit\") {\n return workflowSubmit;\n } else if (handler === \"workflowAttach\") {\n return workflowAttach;\n } else if (handler === \"workflowOutput\") {\n return workflowOutput;\n }\n // shared handlers pass trough via the ingress's normal invocation form\n // i.e. POST /<svc>/<key>/<handler>\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation(conn, {\n component,\n handler,\n key,\n parameter,\n opts,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n }\n\n objectSendClient(opts: ClientTarget, key: string): any {\n return this.proxy(opts.name, key, true, opts._handlers);\n }\n\n serviceSendClient(opts: ClientTarget): any {\n return this.proxy(opts.name, undefined, true, opts._handlers);\n }\n\n // Factory that dispatches on the interface's kind — mirrors the generator\n // SDK's `client(ingress, def)` / `sendClient(ingress, def)` ergonomics.\n client(opts: ClientTarget, key?: string): any {\n return opts._kind === \"service\"\n ? this.serviceClient(opts)\n : this.objectClient(opts, key as string);\n }\n\n sendClient(opts: ClientTarget, key?: string): any {\n return opts._kind === \"service\"\n ? this.serviceSendClient(opts)\n : this.objectSendClient(opts, key as string);\n }\n\n scope(scopeKey: string): ScopedIngress {\n const conn = this.opts;\n const scopedProxy = (\n component: string,\n key?: string,\n send?: boolean,\n handlers?: Record<string, HandlerDescriptor>\n ) =>\n new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation<unknown, unknown>(conn, {\n component,\n handler,\n key,\n parameter,\n opts,\n send,\n scope: scopeKey,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n\n return {\n serviceClient: (opts: ClientTarget): any =>\n scopedProxy(opts.name, undefined, undefined, opts._handlers),\n serviceSendClient: (opts: ClientTarget): any =>\n scopedProxy(opts.name, undefined, true, opts._handlers),\n objectClient: (opts: ClientTarget, key: string): any =>\n scopedProxy(opts.name, key, undefined, opts._handlers),\n objectSendClient: (opts: ClientTarget, key: string): any =>\n scopedProxy(opts.name, key, true, opts._handlers),\n client: (opts: ClientTarget, key?: string): any =>\n opts._kind === \"service\"\n ? scopedProxy(opts.name, undefined, undefined, opts._handlers)\n : scopedProxy(opts.name, key, undefined, opts._handlers),\n sendClient: (opts: ClientTarget, key?: string): any =>\n opts._kind === \"service\"\n ? scopedProxy(opts.name, undefined, true, opts._handlers)\n : scopedProxy(opts.name, key, true, opts._handlers),\n workflowClient: (opts: ClientTarget, key: string): any => {\n const component = opts.name;\n const handlers = opts._handlers;\n const runOutputSerde = handlers?.run?._outputSerde;\n\n const workflowSubmit = async (\n ...args: unknown[]\n ): Promise<WorkflowSubmission<unknown>> => {\n const { parameter, opts } = optsFromArgs(args);\n const res: Send = await doComponentInvocation(\n conn,\n {\n component,\n handler: \"run\",\n key,\n send: true,\n parameter,\n opts,\n scope: scopeKey,\n handlerDesc: handlers?.run,\n },\n true\n );\n return {\n invocationId: res.invocationId,\n status: res.status,\n attachable: true,\n };\n };\n\n const workflowAttach = (opts?: Opts<void, unknown>) =>\n doWorkflowHandleCall(\n conn,\n component,\n key,\n \"attach\",\n opts,\n runOutputSerde\n );\n\n const workflowOutput = async (\n opts?: Opts<void, unknown>\n ): Promise<Output<unknown>> => {\n try {\n const result = await doWorkflowHandleCall(\n conn,\n component,\n key,\n \"output\",\n opts,\n runOutputSerde\n );\n return { ready: true, result };\n } catch (e) {\n if (!(e instanceof HttpCallError) || e.status !== 470) {\n throw e;\n }\n return {\n ready: false,\n get result() {\n throw new Error(\"Calling result() on a non ready workflow\");\n },\n };\n }\n };\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n if (handler === \"workflowSubmit\") {\n return workflowSubmit;\n } else if (handler === \"workflowAttach\") {\n return workflowAttach;\n } else if (handler === \"workflowOutput\") {\n return workflowOutput;\n }\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation(conn, {\n component,\n handler,\n key,\n parameter,\n opts,\n scope: scopeKey,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n },\n };\n }\n\n async call<I, O>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n scope?: string;\n opts?: Opts<I, O>;\n }): Promise<O> {\n return doComponentInvocation<I, O>(this.opts, {\n component: opts.service,\n handler: opts.handler,\n key: opts.key,\n scope: opts.scope,\n parameter: opts.parameter,\n send: false,\n opts: opts.opts,\n });\n }\n\n async send<I>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n scope?: string;\n opts?: SendOpts<I>;\n }): Promise<Send> {\n return doComponentInvocation<I, Send>(this.opts, {\n component: opts.service,\n handler: opts.handler,\n key: opts.key,\n scope: opts.scope,\n parameter: opts.parameter,\n send: true,\n opts: opts.opts,\n });\n }\n\n async resolveAwakeable<T>(\n id: string,\n payload?: T,\n payloadSerde?: Serde<T>\n ): Promise<void> {\n const url = `${this.opts.url}/restate/a/${id}/resolve`;\n const { body, contentType } = serializeBodyWithContentType(\n payload,\n payloadSerde ?? this.opts.serde ?? serde.json,\n this.opts.journalValueCodec\n );\n const headers = {\n ...(this.opts.headers ?? {}),\n };\n if (contentType) {\n headers[\"Content-Type\"] = contentType;\n }\n const httpResponse = await getFetch(this.opts)(url, {\n method: \"POST\",\n headers,\n body,\n });\n if (!httpResponse.ok) {\n const body = await httpResponse.text();\n throw new HttpCallError(\n httpResponse.status,\n body,\n `Request failed: ${httpResponse.status}\\n${body}`\n );\n }\n }\n\n async rejectAwakeable(id: string, reason: string): Promise<void> {\n const url = `${this.opts.url}/restate/a/${id}/reject`;\n const headers = {\n \"Content-Type\": \"text/plain\",\n ...(this.opts.headers ?? {}),\n };\n const httpResponse = await getFetch(this.opts)(url, {\n method: \"POST\",\n headers,\n body: reason,\n });\n if (!httpResponse.ok) {\n const body = await httpResponse.text();\n throw new HttpCallError(\n httpResponse.status,\n body,\n `Request failed: ${httpResponse.status}\\n${body}`\n );\n }\n }\n\n async result<T>(\n send: Send<T> | WorkflowSubmission<T>,\n resultSerde?: Serde<T>\n ): Promise<T> {\n if (!send.attachable) {\n throw new Error(\n `Unable to fetch the result for ${send.invocationId}.\n A service's result is stored only with an idempotencyKey is supplied when invocating the service.`\n );\n }\n //\n // headers\n //\n const headers = {\n ...(this.opts.headers ?? {}),\n };\n //\n // make the call\n //\n const url = `${this.opts.url}/restate/invocation/${send.invocationId}/attach`;\n // Attaching only observes the existing invocation, so it is safe to retry\n // when the connection has a retry policy.\n const retryPolicy = resolveRetryPolicy(this.opts.retry);\n\n const responseBuf = await fetchWithRetries(\n this.opts,\n url,\n { method: \"GET\", headers },\n undefined,\n retryPolicy\n );\n const decodedBuf = this.opts.journalValueCodec\n ? await this.opts.journalValueCodec.decode(responseBuf)\n : responseBuf;\n return (resultSerde ?? this.opts.serde ?? serde.json).deserialize(\n decodedBuf\n ) as T;\n }\n}\n\nfunction computeDelayAsIso(opts: SendOpts): string {\n const delay = opts.delay();\n if (!delay) {\n return \"send\";\n }\n return `send?delay=${delay}ms`;\n}\n\nfunction serializeBodyWithContentType(\n body: unknown,\n serde: Serde<unknown>,\n journalValueCodec?: JournalValueCodec\n): {\n body?: Uint8Array;\n contentType?: string;\n} {\n let buffer = serde.serialize(body);\n if (journalValueCodec) {\n buffer = journalValueCodec.encode(buffer);\n }\n return {\n body: buffer,\n contentType: serde.contentType,\n };\n}\n"],"mappings":";;;;;;;;;;;AA8CA,SAAgB,QAAQ,MAA+B;AACrD,QAAO,IAAI,YAAY,KAAK;;AAe9B,IAAa,gBAAb,cAAmC,MAAM;CACvC,YACE,AAAgBA,QAChB,AAAgBC,cAChB,AAAyBC,SACzB;AACA,QAAM,QAAQ;EAJE;EACA;EACS;;;AAmB7B,SAAS,aAAa,MAGpB;CACA,IAAIC;CACJ,IAAIC;AACJ,SAAQ,KAAK,QAAb;EACE,KAAK,EACH;EAEF,KAAK;AACH,OAAI,KAAK,cAAc,KACrB,QAAO,KAAK;YACH,KAAK,cAAc,SAC5B,QAAO,KAAK;OAEZ,aAAY,KAAK;AAEnB;EAEF,KAAK;AACH,eAAY,KAAK;AACjB,OAAI,KAAK,cAAc,KACrB,QAAO,KAAK;YACH,KAAK,cAAc,SAC5B,QAAO,KAAK;OAEZ,OAAM,IAAI,UACR,sDACD;AAEH;EAEF,QACE,OAAM,IAAI,UAAU,iCAAiC;;AAGzD,QAAO;EACL;EACA;EACD;;AAGH,MAAM,yBAAyB;AAC/B,MAAM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;GACpB,MAAM,OAAO,MAAM,aAAa,MAAM;AACtC,SAAM,IAAI,cACR,aAAa,QACb,MACA,mBAAmB,aAAa,OAAO,IAAI,OAC5C;;;CAIL,MAAM,OACJ,MACA,aACY;AACZ,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MACR,kCAAkC,KAAK,aAAa;2GAErD;EAKH,MAAM,UAAU,EACd,GAAI,KAAK,KAAK,WAAW,EAAE,EAC5B;EAID,MAAM,MAAM,GAAG,KAAK,KAAK,IAAI,sBAAsB,KAAK,aAAa;EAGrE,MAAM,cAAc,mBAAmB,KAAK,KAAK,MAAM;EAEvD,MAAM,cAAc,MAAM,iBACxB,KAAK,MACL,KACA;GAAE,QAAQ;GAAO;GAAS,EAC1B,QACA,YACD;EACD,MAAM,aAAa,KAAK,KAAK,oBACzB,MAAM,KAAK,KAAK,kBAAkB,OAAO,YAAY,GACrD;AACJ,UAAQ,eAAe,KAAK,KAAK,SAAS,MAAM,MAAM,YACpD,WACD;;;AAIL,SAAS,kBAAkB,MAAwB;CACjD,MAAM,QAAQ,KAAK,OAAO;AAC1B,KAAI,CAAC,MACH,QAAO;AAET,QAAO,cAAc,MAAM;;AAG7B,SAAS,6BACP,MACA,SACA,mBAIA;CACA,IAAI,SAASC,QAAM,UAAU,KAAK;AAClC,KAAI,kBACF,UAAS,kBAAkB,OAAO,OAAO;AAE3C,QAAO;EACL,MAAM;EACN,aAAaA,QAAM;EACpB"}
1
+ {"version":3,"file":"ingress.js","names":["status: number","responseText: string","message: string","parameter: unknown","opts: Opts<unknown, unknown> | SendOpts<unknown> | undefined","response: Response","errorBody: string","url: string","opts: ResolvedConnectionOpts","res: Send","opts","body","serde"],"sources":["../src/ingress.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// The client methods implement the overloaded `Ingress` interface (classic\n// definition OR service interface), which requires an `any` return on the\n// implementation signatures.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n type Serde,\n serde,\n type JournalValueCodec,\n type HandlerDescriptor,\n} from \"@restatedev/restate-sdk-core\";\nimport {\n ConnectionOpts,\n Ingress,\n Output,\n Send,\n ScopedIngress,\n WorkflowSubmission,\n} from \"./api.js\";\n\nimport { Opts, SendOpts } from \"./api.js\";\nimport { resolveConnectionOpts, type ResolvedConnectionOpts } from \"./env.js\";\nimport {\n abortableSleep,\n backoffDelay,\n defaultShouldRetry,\n parseRetryAfter,\n type ResolvedRetryPolicy,\n resolveRetryPolicy,\n} from \"./retry.js\";\n\n/**\n * Connect to the Restate ingress.\n *\n * With a `url`, exactly that. Without one, the ingress is taken from\n * `RESTATE_INGRESS_KEY`, the ingress key from the Cloud UI (Development →\n * Configure Client).\n *\n * @example\n * ```ts\n * const rs = connect({ url: \"http://localhost:8080\" }); // a local Restate\n * const cloud = connect(); // uses RESTATE_INGRESS_KEY\n * ```\n *\n * @param opts connection options\n * @returns a connection to the Restate ingress\n */\nexport function connect(opts: ConnectionOpts = {}): Ingress {\n return new HttpIngress(resolveConnectionOpts(opts));\n}\n\n/**\n * The runtime shape a client method needs off a definition value: the service\n * name, plus (for interface / `implement()` values) the per-handler serde\n * descriptors. Classic definitions carry no `_handlers`, so serde reuse is a\n * no-op for them.\n */\ntype ClientTarget = {\n name: string;\n _handlers?: Record<string, HandlerDescriptor>;\n _kind?: \"service\" | \"object\" | \"workflow\";\n};\n\nexport class HttpCallError extends Error {\n constructor(\n public readonly status: number,\n public readonly responseText: string,\n public override readonly message: string\n ) {\n super(message);\n }\n}\n\ntype InvocationParameters<I> = {\n component: string;\n handler: string;\n key?: string;\n send?: boolean;\n opts?: Opts<I, unknown> | SendOpts<I>;\n parameter?: I;\n method?: string;\n scope?: string;\n /** Serdes declared by the callee's service interface, if the client was built from one. */\n handlerDesc?: HandlerDescriptor;\n};\n\nfunction optsFromArgs(args: unknown[]): {\n parameter?: unknown;\n opts?: Opts<unknown, unknown> | SendOpts<unknown>;\n} {\n let parameter: unknown;\n let opts: Opts<unknown, unknown> | SendOpts<unknown> | undefined;\n switch (args.length) {\n case 0: {\n break;\n }\n case 1: {\n if (args[0] instanceof Opts) {\n opts = args[0];\n } else if (args[0] instanceof SendOpts) {\n opts = args[0];\n } else {\n parameter = args[0];\n }\n break;\n }\n case 2: {\n parameter = args[0];\n if (args[1] instanceof Opts) {\n opts = args[1];\n } else if (args[1] instanceof SendOpts) {\n opts = args[1];\n } else {\n throw new TypeError(\n \"The second argument must be either Opts or SendOpts\"\n );\n }\n break;\n }\n default: {\n throw new TypeError(\"unexpected number of arguments\");\n }\n }\n return {\n parameter,\n opts,\n };\n}\n\nconst IDEMPOTENCY_KEY_HEADER = \"idempotency-key\";\nconst LIMIT_KEY_HEADER = \"x-restate-limit-key\";\n// Carries the 1-based attempt number on every request so the server can observe\n// how many times the client has (re)issued it.\nconst ATTEMPT_HEADER = \"x-restateclient-retry-attempt\";\n\nconst getFetch = (opts: ConnectionOpts): NonNullable<ConnectionOpts[\"fetch\"]> =>\n opts.fetch ?? globalThis.fetch;\n\nconst fetchWithRetries = async (\n opts: ResolvedConnectionOpts,\n url: string,\n init: RequestInit,\n callOpts: Opts<unknown, unknown> | SendOpts<unknown> | undefined,\n retryPolicy: ResolvedRetryPolicy | undefined\n): Promise<Uint8Array> => {\n const userSignal = callOpts?.opts.signal;\n const timeout = callOpts?.opts.timeout;\n if (userSignal !== undefined && timeout !== undefined) {\n // The caller configured two mutually exclusive ways to abort each attempt.\n throw new Error(\n \"You can't specify both signal and timeout options at the same time\"\n );\n }\n // A fresh timeout signal is minted per attempt below — a single\n // AbortSignal.timeout() would already be aborted on the second attempt.\n const attemptSignal = (): AbortSignal | undefined =>\n userSignal ??\n (timeout !== undefined ? AbortSignal.timeout(timeout) : undefined);\n const shouldRetry = retryPolicy?.shouldRetry ?? defaultShouldRetry;\n\n // Whether waiting `delay` and then starting the next attempt would still fall\n // within the maxDuration budget (measured from the first attempt; a non-finite\n // maxDuration disables the bound). Checked *after* the delay is known so we\n // never sleep out a backoff — or a long Retry-After — only to give up on the\n // attempt it precedes. This is a decision-time gate only: it never aborts an\n // in-flight request. The maxAttempts count is gated separately, before the\n // delay is computed.\n const startTime = Date.now();\n const nextAttemptFitsBudget = (\n policy: ResolvedRetryPolicy,\n delay: number\n ): boolean => Date.now() - startTime + delay < policy.maxDuration;\n\n // Headers are always a plain record in this codebase; carry them forward and\n // stamp the attempt number afresh on each try.\n const baseHeaders = (init.headers ?? {}) as Record<string, string>;\n\n for (let attempt = 0; ; attempt++) {\n let response: Response;\n let errorBody: string;\n try {\n response = await getFetch(opts)(url, {\n ...init,\n headers: { ...baseHeaders, [ATTEMPT_HEADER]: String(attempt + 1) },\n signal: attemptSignal(),\n });\n if (response.ok) {\n // A 2xx response was received. Keep the body read inside this try so a\n // connection failure while streaming the body is retried as ambiguous.\n return new Uint8Array(await response.arrayBuffer());\n }\n // fetch resolves normally for non-2xx statuses. Read the body here both\n // for RetryFailure inspection and the final HttpCallError.\n errorBody = await response.text();\n } catch (e) {\n // fetch rejected, or the response body failed while streaming. Both are\n // ambiguous because the server may already have processed the request.\n if (\n retryPolicy &&\n attempt < retryPolicy.maxAttempts - 1 &&\n !userSignal?.aborted &&\n shouldRetry({ kind: \"network\", error: e }, attempt)\n ) {\n // Retries are enabled, attempts remain, the caller did not abort, and\n // the policy accepted this failure. Retry only if the backoff still\n // leaves us within the duration budget.\n const delay = backoffDelay(retryPolicy, attempt);\n if (nextAttemptFitsBudget(retryPolicy, delay)) {\n await abortableSleep(delay, userSignal);\n continue;\n }\n }\n // Retries are disabled or exhausted, the caller aborted, the policy\n // rejected this failure, or the duration budget is spent.\n throw e;\n }\n if (\n retryPolicy &&\n attempt < retryPolicy.maxAttempts - 1 &&\n !userSignal?.aborted &&\n shouldRetry(\n {\n kind: \"response\",\n status: response.status,\n headers: response.headers,\n body: errorBody || undefined,\n },\n attempt\n )\n ) {\n // A non-2xx response was received, attempts remain, and the policy chose\n // to retry it (by default, transient statuses 408/425/429/5xx, unless the\n // error is attributed to the invocation via x-restate-error-source). The\n // delay is the server's Retry-After when present, else the computed\n // backoff; either way we only retry if it still fits the duration budget.\n const retryAfter = retryPolicy.respectRetryAfter\n ? parseRetryAfter(response.headers)\n : undefined;\n const delay = retryAfter ?? backoffDelay(retryPolicy, attempt);\n if (nextAttemptFitsBudget(retryPolicy, delay)) {\n await abortableSleep(delay, userSignal);\n continue;\n }\n }\n // The response is not retryable, retries are disabled or exhausted, the\n // caller aborted, or the policy rejected this response.\n throw new HttpCallError(\n response.status,\n errorBody,\n `Request failed: ${response.status}\\n${errorBody}`\n );\n }\n};\n\nconst doComponentInvocation = async <I, O>(\n opts: ResolvedConnectionOpts,\n params: InvocationParameters<I>,\n canBeRetried = Boolean(params.opts?.opts.idempotencyKey)\n): Promise<O> => {\n let attachable = false;\n //\n // ingress URL\n //\n let url: string;\n if (params.scope) {\n // Scoped path: /restate/scope/{scope}/{call|send}/{service}/{key?}/{handler}\n const pathType = params.send ? \"send\" : \"call\";\n const parts = [\n opts.url,\n \"restate/scope\",\n encodeURIComponent(params.scope),\n pathType,\n params.component,\n ];\n if (params.key) {\n parts.push(encodeURIComponent(params.key));\n }\n parts.push(params.handler);\n url = parts.join(\"/\");\n if (params.send && params.opts instanceof SendOpts) {\n const delay = params.opts.delay();\n if (delay) url += `?delay=${delay}ms`;\n }\n } else {\n const fragments = [opts.url, params.component];\n if (params.key) {\n fragments.push(encodeURIComponent(params.key));\n }\n fragments.push(params.handler);\n if (params.send ?? false) {\n if (params.opts instanceof SendOpts) {\n fragments.push(computeDelayAsIso(params.opts));\n } else {\n fragments.push(\"send\");\n }\n }\n url = fragments.join(\"/\");\n }\n //\n // request body\n //\n const inputSerde =\n params.opts?.opts.input ??\n params.handlerDesc?._inputSerde ??\n opts.serde ??\n serde.json;\n\n const { body, contentType } = serializeBodyWithContentType(\n params.parameter,\n inputSerde,\n opts.journalValueCodec\n );\n //\n // headers\n //\n const headers = {\n ...(opts.headers ?? {}),\n ...(params.opts?.opts?.headers ?? {}),\n };\n if (contentType) {\n headers[\"Content-Type\"] = contentType;\n }\n //\n // idempotency\n //\n const idempotencyKey = params.opts?.opts.idempotencyKey;\n if (idempotencyKey) {\n headers[IDEMPOTENCY_KEY_HEADER] = idempotencyKey;\n attachable = true;\n }\n //\n // limit key\n //\n const limitKey = params.opts?.opts.limitKey;\n if (limitKey) {\n headers[LIMIT_KEY_HEADER] = limitKey;\n }\n\n //\n // retries\n //\n // Regular invocations default eligibility from the idempotency key, while\n // workflow submissions opt in because the workflow ID identifies the run.\n const retryPolicy = canBeRetried ? resolveRetryPolicy(opts.retry) : undefined;\n\n //\n // make the call\n //\n const responseBuf = await fetchWithRetries(\n opts,\n url,\n {\n method: params.method ?? \"POST\",\n headers,\n body,\n },\n params.opts,\n retryPolicy\n );\n if (!params.send) {\n const decodedBuf = opts.journalValueCodec\n ? await opts.journalValueCodec.decode(responseBuf)\n : responseBuf;\n const outputSerde =\n params.opts?.opts.output ??\n params.handlerDesc?._outputSerde ??\n opts.serde ??\n serde.json;\n return outputSerde.deserialize(decodedBuf) as O;\n }\n const json = serde.json.deserialize(responseBuf) as O;\n return { ...json, attachable };\n};\n\nconst doWorkflowHandleCall = async <O>(\n opts: ResolvedConnectionOpts,\n wfName: string,\n wfKey: string,\n op: \"output\" | \"attach\",\n callOpts?: Opts<unknown, O> | SendOpts<unknown>,\n runOutputSerde?: Serde<unknown>\n): Promise<O> => {\n const outputSerde =\n callOpts?.opts.output ?? runOutputSerde ?? opts.serde ?? serde.json;\n //\n // headers\n //\n const headers = {\n ...(opts.headers ?? {}),\n };\n //\n // make the call\n //\n const url = `${opts.url}/restate/workflow/${wfName}/${encodeURIComponent(\n wfKey\n )}/${op}`;\n // Attach and output only observe the existing workflow, so both are eligible\n // when the connection has a retry policy.\n const retryPolicy = resolveRetryPolicy(opts.retry);\n\n const responseBuf = await fetchWithRetries(\n opts,\n url,\n { method: \"GET\", headers },\n callOpts,\n retryPolicy\n );\n const decodedBuf = opts.journalValueCodec\n ? await opts.journalValueCodec.decode(responseBuf)\n : responseBuf;\n return outputSerde.deserialize(decodedBuf) as O;\n};\n\nclass HttpIngress implements Ingress {\n constructor(private readonly opts: ResolvedConnectionOpts) {}\n\n private proxy(\n component: string,\n key?: string,\n send?: boolean,\n handlers?: Record<string, HandlerDescriptor>\n ) {\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation<unknown, unknown>(this.opts, {\n component,\n handler,\n key,\n parameter,\n opts,\n send,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n }\n\n serviceClient(opts: ClientTarget): any {\n return this.proxy(opts.name, undefined, undefined, opts._handlers);\n }\n\n objectClient(opts: ClientTarget, key: string): any {\n return this.proxy(opts.name, key, undefined, opts._handlers);\n }\n\n workflowClient(opts: ClientTarget, key: string): any {\n const component = opts.name;\n const handlers = opts._handlers;\n const runOutputSerde = handlers?.run?._outputSerde;\n const conn = this.opts;\n\n const workflowSubmit = async (\n ...args: unknown[]\n ): Promise<WorkflowSubmission<unknown>> => {\n const { parameter, opts } = optsFromArgs(args);\n const res: Send = await doComponentInvocation(\n conn,\n {\n component,\n handler: \"run\",\n key,\n send: true,\n parameter,\n opts,\n handlerDesc: handlers?.run,\n },\n true\n );\n\n return {\n invocationId: res.invocationId,\n status: res.status,\n attachable: true,\n };\n };\n\n const workflowAttach = (opts?: Opts<void, unknown>) =>\n doWorkflowHandleCall(\n conn,\n component,\n key,\n \"attach\",\n opts,\n runOutputSerde\n );\n\n const workflowOutput = async (\n opts?: Opts<void, unknown>\n ): Promise<Output<unknown>> => {\n try {\n const result = await doWorkflowHandleCall(\n conn,\n component,\n key,\n \"output\",\n opts,\n runOutputSerde\n );\n\n return {\n ready: true,\n result,\n };\n } catch (e) {\n if (!(e instanceof HttpCallError) || e.status !== 470) {\n throw e;\n }\n return {\n ready: false,\n get result() {\n throw new Error(\"Calling result() on a non ready workflow\");\n },\n };\n }\n };\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n if (handler === \"workflowSubmit\") {\n return workflowSubmit;\n } else if (handler === \"workflowAttach\") {\n return workflowAttach;\n } else if (handler === \"workflowOutput\") {\n return workflowOutput;\n }\n // shared handlers pass trough via the ingress's normal invocation form\n // i.e. POST /<svc>/<key>/<handler>\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation(conn, {\n component,\n handler,\n key,\n parameter,\n opts,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n }\n\n objectSendClient(opts: ClientTarget, key: string): any {\n return this.proxy(opts.name, key, true, opts._handlers);\n }\n\n serviceSendClient(opts: ClientTarget): any {\n return this.proxy(opts.name, undefined, true, opts._handlers);\n }\n\n // Factory that dispatches on the interface's kind — mirrors the generator\n // SDK's `client(ingress, def)` / `sendClient(ingress, def)` ergonomics.\n client(opts: ClientTarget, key?: string): any {\n return opts._kind === \"service\"\n ? this.serviceClient(opts)\n : this.objectClient(opts, key as string);\n }\n\n sendClient(opts: ClientTarget, key?: string): any {\n return opts._kind === \"service\"\n ? this.serviceSendClient(opts)\n : this.objectSendClient(opts, key as string);\n }\n\n scope(scopeKey: string): ScopedIngress {\n const conn = this.opts;\n const scopedProxy = (\n component: string,\n key?: string,\n send?: boolean,\n handlers?: Record<string, HandlerDescriptor>\n ) =>\n new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation<unknown, unknown>(conn, {\n component,\n handler,\n key,\n parameter,\n opts,\n send,\n scope: scopeKey,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n\n return {\n serviceClient: (opts: ClientTarget): any =>\n scopedProxy(opts.name, undefined, undefined, opts._handlers),\n serviceSendClient: (opts: ClientTarget): any =>\n scopedProxy(opts.name, undefined, true, opts._handlers),\n objectClient: (opts: ClientTarget, key: string): any =>\n scopedProxy(opts.name, key, undefined, opts._handlers),\n objectSendClient: (opts: ClientTarget, key: string): any =>\n scopedProxy(opts.name, key, true, opts._handlers),\n client: (opts: ClientTarget, key?: string): any =>\n opts._kind === \"service\"\n ? scopedProxy(opts.name, undefined, undefined, opts._handlers)\n : scopedProxy(opts.name, key, undefined, opts._handlers),\n sendClient: (opts: ClientTarget, key?: string): any =>\n opts._kind === \"service\"\n ? scopedProxy(opts.name, undefined, true, opts._handlers)\n : scopedProxy(opts.name, key, true, opts._handlers),\n workflowClient: (opts: ClientTarget, key: string): any => {\n const component = opts.name;\n const handlers = opts._handlers;\n const runOutputSerde = handlers?.run?._outputSerde;\n\n const workflowSubmit = async (\n ...args: unknown[]\n ): Promise<WorkflowSubmission<unknown>> => {\n const { parameter, opts } = optsFromArgs(args);\n const res: Send = await doComponentInvocation(\n conn,\n {\n component,\n handler: \"run\",\n key,\n send: true,\n parameter,\n opts,\n scope: scopeKey,\n handlerDesc: handlers?.run,\n },\n true\n );\n return {\n invocationId: res.invocationId,\n status: res.status,\n attachable: true,\n };\n };\n\n const workflowAttach = (opts?: Opts<void, unknown>) =>\n doWorkflowHandleCall(\n conn,\n component,\n key,\n \"attach\",\n opts,\n runOutputSerde\n );\n\n const workflowOutput = async (\n opts?: Opts<void, unknown>\n ): Promise<Output<unknown>> => {\n try {\n const result = await doWorkflowHandleCall(\n conn,\n component,\n key,\n \"output\",\n opts,\n runOutputSerde\n );\n return { ready: true, result };\n } catch (e) {\n if (!(e instanceof HttpCallError) || e.status !== 470) {\n throw e;\n }\n return {\n ready: false,\n get result() {\n throw new Error(\"Calling result() on a non ready workflow\");\n },\n };\n }\n };\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n const handler = prop as string;\n if (handler === \"workflowSubmit\") {\n return workflowSubmit;\n } else if (handler === \"workflowAttach\") {\n return workflowAttach;\n } else if (handler === \"workflowOutput\") {\n return workflowOutput;\n }\n return (...args: unknown[]) => {\n const { parameter, opts } = optsFromArgs(args);\n return doComponentInvocation(conn, {\n component,\n handler,\n key,\n parameter,\n opts,\n scope: scopeKey,\n handlerDesc: handlers?.[handler],\n });\n };\n },\n }\n );\n },\n };\n }\n\n async call<I, O>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n scope?: string;\n opts?: Opts<I, O>;\n }): Promise<O> {\n return doComponentInvocation<I, O>(this.opts, {\n component: opts.service,\n handler: opts.handler,\n key: opts.key,\n scope: opts.scope,\n parameter: opts.parameter,\n send: false,\n opts: opts.opts,\n });\n }\n\n async send<I>(opts: {\n service: string;\n handler: string;\n parameter: I;\n key?: string;\n scope?: string;\n opts?: SendOpts<I>;\n }): Promise<Send> {\n return doComponentInvocation<I, Send>(this.opts, {\n component: opts.service,\n handler: opts.handler,\n key: opts.key,\n scope: opts.scope,\n parameter: opts.parameter,\n send: true,\n opts: opts.opts,\n });\n }\n\n async resolveAwakeable<T>(\n id: string,\n payload?: T,\n payloadSerde?: Serde<T>\n ): Promise<void> {\n const url = `${this.opts.url}/restate/a/${id}/resolve`;\n const { body, contentType } = serializeBodyWithContentType(\n payload,\n payloadSerde ?? this.opts.serde ?? serde.json,\n this.opts.journalValueCodec\n );\n const headers = {\n ...(this.opts.headers ?? {}),\n };\n if (contentType) {\n headers[\"Content-Type\"] = contentType;\n }\n const httpResponse = await getFetch(this.opts)(url, {\n method: \"POST\",\n headers,\n body,\n });\n if (!httpResponse.ok) {\n const body = await httpResponse.text();\n throw new HttpCallError(\n httpResponse.status,\n body,\n `Request failed: ${httpResponse.status}\\n${body}`\n );\n }\n }\n\n async rejectAwakeable(id: string, reason: string): Promise<void> {\n const url = `${this.opts.url}/restate/a/${id}/reject`;\n const headers = {\n \"Content-Type\": \"text/plain\",\n ...(this.opts.headers ?? {}),\n };\n const httpResponse = await getFetch(this.opts)(url, {\n method: \"POST\",\n headers,\n body: reason,\n });\n if (!httpResponse.ok) {\n const body = await httpResponse.text();\n throw new HttpCallError(\n httpResponse.status,\n body,\n `Request failed: ${httpResponse.status}\\n${body}`\n );\n }\n }\n\n async result<T>(\n send: Send<T> | WorkflowSubmission<T>,\n resultSerde?: Serde<T>\n ): Promise<T> {\n if (!send.attachable) {\n throw new Error(\n `Unable to fetch the result for ${send.invocationId}.\n A service's result is stored only with an idempotencyKey is supplied when invocating the service.`\n );\n }\n //\n // headers\n //\n const headers = {\n ...(this.opts.headers ?? {}),\n };\n //\n // make the call\n //\n const url = `${this.opts.url}/restate/invocation/${send.invocationId}/attach`;\n // Attaching only observes the existing invocation, so it is safe to retry\n // when the connection has a retry policy.\n const retryPolicy = resolveRetryPolicy(this.opts.retry);\n\n const responseBuf = await fetchWithRetries(\n this.opts,\n url,\n { method: \"GET\", headers },\n undefined,\n retryPolicy\n );\n const decodedBuf = this.opts.journalValueCodec\n ? await this.opts.journalValueCodec.decode(responseBuf)\n : responseBuf;\n return (resultSerde ?? this.opts.serde ?? serde.json).deserialize(\n decodedBuf\n ) as T;\n }\n}\n\nfunction computeDelayAsIso(opts: SendOpts): string {\n const delay = opts.delay();\n if (!delay) {\n return \"send\";\n }\n return `send?delay=${delay}ms`;\n}\n\nfunction serializeBodyWithContentType(\n body: unknown,\n serde: Serde<unknown>,\n journalValueCodec?: JournalValueCodec\n): {\n body?: Uint8Array;\n contentType?: string;\n} {\n let buffer = serde.serialize(body);\n if (journalValueCodec) {\n buffer = journalValueCodec.encode(buffer);\n }\n return {\n body: buffer,\n contentType: serde.contentType,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,QAAQ,OAAuB,EAAE,EAAW;AAC1D,QAAO,IAAI,YAAY,sBAAsB,KAAK,CAAC;;AAerD,IAAa,gBAAb,cAAmC,MAAM;CACvC,YACE,AAAgBA,QAChB,AAAgBC,cAChB,AA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B,SAAS,6BACP,MACA,SACA,mBAIA;CACA,IAAI,SAASC,QAAM,UAAU,KAAK;AAClC,KAAI,kBACF,UAAS,kBAAkB,OAAO,OAAO;AAE3C,QAAO;EACL,MAAM;EACN,aAAaA,QAAM;EACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/restate-sdk-clients",
3
- "version": "1.18.0",
3
+ "version": "1.18.2",
4
4
  "description": "Typescript SDK for Restate",
5
5
  "author": "Restate Developers",
6
6
  "email": "code@restate.dev",
@@ -32,7 +32,7 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@restatedev/restate-sdk-core": "1.18.0"
35
+ "@restatedev/restate-sdk-core": "1.18.2"
36
36
  },
37
37
  "devDependencies": {},
38
38
  "scripts": {