@restatedev/restate-sdk-cloudflare-workers 1.15.0-rc.2 → 1.15.0-rc.4

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.
Files changed (61) hide show
  1. package/dist/endpoint/handlers/generic.cjs +2 -5
  2. package/dist/endpoint/handlers/generic.js +2 -5
  3. package/dist/endpoint/handlers/generic.js.map +1 -1
  4. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts +1 -1
  5. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.js +1 -1
  6. package/dist/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm +0 -0
  7. package/dist/io.cjs +1 -1
  8. package/dist/io.js +1 -1
  9. package/dist/io.js.map +1 -1
  10. package/dist/package.cjs +1 -1
  11. package/dist/package.js +1 -1
  12. package/dist/package.js.map +1 -1
  13. package/package.json +3 -3
  14. package/dist/context_impl.d.ts.map +0 -1
  15. package/dist/endpoint/components.d.ts.map +0 -1
  16. package/dist/endpoint/discovery.d.ts +0 -184
  17. package/dist/endpoint/discovery.d.ts.map +0 -1
  18. package/dist/endpoint/discovery.js +0 -7
  19. package/dist/endpoint/discovery.js.map +0 -1
  20. package/dist/endpoint/endpoint.d.ts.map +0 -1
  21. package/dist/endpoint/handlers/core_logging.d.ts +0 -10
  22. package/dist/endpoint/handlers/core_logging.d.ts.map +0 -1
  23. package/dist/endpoint/handlers/discovery.d.ts +0 -5
  24. package/dist/endpoint/handlers/discovery.d.ts.map +0 -1
  25. package/dist/endpoint/handlers/fetch.d.ts +0 -5
  26. package/dist/endpoint/handlers/fetch.d.ts.map +0 -1
  27. package/dist/endpoint/handlers/generic.d.ts +0 -5
  28. package/dist/endpoint/handlers/generic.d.ts.map +0 -1
  29. package/dist/endpoint/handlers/lambda.d.ts +0 -10
  30. package/dist/endpoint/handlers/lambda.d.ts.map +0 -1
  31. package/dist/endpoint/handlers/preview.d.ts +0 -5
  32. package/dist/endpoint/handlers/preview.d.ts.map +0 -1
  33. package/dist/endpoint/handlers/types.d.ts.map +0 -1
  34. package/dist/endpoint/handlers/types.js +0 -2
  35. package/dist/endpoint/handlers/types.js.map +0 -1
  36. package/dist/endpoint/handlers/utils.d.ts +0 -23
  37. package/dist/endpoint/handlers/utils.d.ts.map +0 -1
  38. package/dist/endpoint/node_endpoint.d.ts +0 -28
  39. package/dist/endpoint/node_endpoint.d.ts.map +0 -1
  40. package/dist/endpoint/types.js +0 -2
  41. package/dist/endpoint/types.js.map +0 -1
  42. package/dist/endpoint/withOptions.d.ts +0 -4
  43. package/dist/endpoint/withOptions.d.ts.map +0 -1
  44. package/dist/endpoint.js +0 -12
  45. package/dist/endpoint.js.map +0 -1
  46. package/dist/error_sanitization.d.ts +0 -13
  47. package/dist/error_sanitization.d.ts.map +0 -1
  48. package/dist/hooks.js +0 -2
  49. package/dist/hooks.js.map +0 -1
  50. package/dist/index.d.ts.map +0 -1
  51. package/dist/index.js.map +0 -1
  52. package/dist/io.d.ts.map +0 -1
  53. package/dist/logging/console_logger_transport.d.ts +0 -5
  54. package/dist/logging/console_logger_transport.d.ts.map +0 -1
  55. package/dist/logging/logger.d.ts.map +0 -1
  56. package/dist/user_agent.d.ts +0 -2
  57. package/dist/user_agent.d.ts.map +0 -1
  58. package/dist/utils/external_progress_channel.d.ts +0 -19
  59. package/dist/utils/external_progress_channel.d.ts.map +0 -1
  60. package/dist/utils/rand.d.ts +0 -13
  61. package/dist/utils/rand.d.ts.map +0 -1
@@ -263,11 +263,8 @@ function notifyError(e, ctx, asTerminalError) {
263
263
  async function flushAndClose(coreVm, vmLogger, inputReaderGetter, outputWriter) {
264
264
  let inputClosed = false;
265
265
  try {
266
- let nextOutput = coreVm.take_output();
267
- while (nextOutput !== null && nextOutput !== void 0) {
268
- await outputWriter.write(nextOutput);
269
- nextOutput = coreVm.take_output();
270
- }
266
+ const nextOutput = coreVm.take_output();
267
+ if (nextOutput?.length > 0) await outputWriter.write(nextOutput);
271
268
  const inputReader = await inputReaderGetter;
272
269
  while (!inputClosed) try {
273
270
  inputClosed = (await inputReader.next()).done ?? false;
@@ -261,11 +261,8 @@ function notifyError(e, ctx, asTerminalError) {
261
261
  async function flushAndClose(coreVm, vmLogger, inputReaderGetter, outputWriter) {
262
262
  let inputClosed = false;
263
263
  try {
264
- let nextOutput = coreVm.take_output();
265
- while (nextOutput !== null && nextOutput !== void 0) {
266
- await outputWriter.write(nextOutput);
267
- nextOutput = coreVm.take_output();
268
- }
264
+ const nextOutput = coreVm.take_output();
265
+ if (nextOutput?.length > 0) await outputWriter.write(nextOutput);
269
266
  const inputReader = await inputReaderGetter;
270
267
  while (!inputClosed) try {
271
268
  inputClosed = (await inputReader.next()).done ?? false;
@@ -1 +1 @@
1
- {"version":3,"file":"generic.js","names":["endpoint: Endpoint","protocolMode: ProtocolMode","additionalDiscoveryFields: Partial<EndpointManifest>","vm.WasmIdentityVerifier","vm.WasmHeader","service: Component","handler: ComponentHandler","attemptHeaders: Headers","extraArgs: unknown[]","additionalContext: AdditionalContext","journalValueCodecInit:\n | Promise<JournalValueCodec>\n | undefined","loggerTransport: LoggerTransport","vm.WasmVM","journalValueCodec: JournalValueCodec","ctx: ContextImpl","invocationRequest: Request","hooks: Hooks[]","hookContext: { request: Request }","encodedOutput: Uint8Array | undefined","originalError: unknown"],"sources":["../../../src/endpoint/handlers/generic.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH\n *\n * This file is part of the Restate SDK for Node.js/TypeScript,\n * which is released under the MIT license.\n *\n * You can find a copy of the license in file LICENSE in the root\n * directory of this repository or package, or at\n * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE\n */\n\nimport {\n ensureError,\n logError,\n PauseError,\n RestateError,\n RetryableError,\n TerminalError,\n} from \"../../types/errors.js\";\nimport type {\n Endpoint as EndpointManifest,\n ProtocolMode,\n} from \"../discovery.js\";\nimport {\n Component,\n ComponentHandler,\n InvokePathComponents,\n} from \"../components.js\";\nimport { parseUrlComponents } from \"../components.js\";\nimport { X_RESTATE_SERVER } from \"../../user_agent.js\";\nimport { CommandError, ContextImpl } from \"../../context_impl.js\";\nimport { restoreError, sanitizeError } from \"../../error_sanitization.js\";\nimport type { InvocationId, Request } from \"../../context.js\";\nimport * as vm from \"./vm/sdk_shared_core_wasm_bindings.js\";\nimport { HandlerKind } from \"../../types/rpc.js\";\nimport { createLogger, type Logger } from \"../../logging/logger.js\";\nimport { DEFAULT_CONSOLE_LOGGER_LOG_LEVEL } from \"../../logging/console_logger_transport.js\";\nimport {\n LoggerContext,\n LoggerTransport,\n LogSource,\n RestateLogLevel,\n} from \"../../logging/logger_transport.js\";\nimport {\n type JournalValueCodec,\n millisOrDurationToMillis,\n} from \"@restatedev/restate-sdk-core\";\nimport type { Endpoint } from \"../endpoint.js\";\nimport {\n type RestateHandler,\n type Headers,\n type RestateRequest,\n type AdditionalContext,\n type RestateResponse,\n ResponseHeaders,\n InputReader,\n OutputWriter,\n} from \"./types.js\";\nimport { handleDiscovery } from \"./discovery.js\";\nimport { handlePreview } from \"./preview.js\";\nimport {\n errorResponse,\n invocationIdFromHeaders,\n simpleResponse,\n tryCreateContextualLogger,\n} from \"./utils.js\";\nimport { destroyLogger, registerLogger } from \"./core_logging.js\";\nimport type { Hooks } from \"../../hooks.js\";\n\n// Hidden symbol key used by first-party hooks to read the live\n// replay/processing phase without widening the public HooksProvider API.\nconst HOOK_CONTEXT_IS_PROCESSING_SYMBOL = Symbol.for(\n \"@restatedev/restate-sdk/hooks.isProcessing\"\n);\n\nexport function createRestateHandler(\n endpoint: Endpoint,\n protocolMode: ProtocolMode,\n additionalDiscoveryFields: Partial<EndpointManifest>\n): RestateHandler {\n return new RestateHandlerImpl(\n endpoint,\n protocolMode,\n additionalDiscoveryFields\n );\n}\n\n/**\n * This is the RestateHandler implementation\n */\nclass RestateHandlerImpl implements RestateHandler {\n private readonly identityVerifier?: vm.WasmIdentityVerifier;\n\n constructor(\n readonly endpoint: Endpoint,\n private readonly protocolMode: ProtocolMode,\n private readonly additionalDiscoveryFields: Partial<EndpointManifest>\n ) {\n // Setup identity verifier\n if (\n this.endpoint.keySet === undefined ||\n this.endpoint.keySet.length === 0\n ) {\n this.endpoint.rlog.warn(\n `Accepting requests without validating request signatures; handler access must be restricted`\n );\n } else {\n this.endpoint.rlog.info(\n `Validating requests using signing keys [${this.endpoint.keySet}]`\n );\n this.identityVerifier = new vm.WasmIdentityVerifier(this.endpoint.keySet);\n }\n\n // Set the logging level in the shared core too!\n vm.set_log_level(\n restateLogLevelToWasmLogLevel(DEFAULT_CONSOLE_LOGGER_LOG_LEVEL)\n );\n }\n\n // handle does not throw.\n public handle(\n request: RestateRequest,\n context?: AdditionalContext\n ): RestateResponse {\n try {\n return this._handle(request, context);\n } catch (e) {\n const error = ensureError(e);\n (\n tryCreateContextualLogger(\n this.endpoint.loggerTransport,\n request.url,\n request.headers\n ) ?? this.endpoint.rlog\n ).error(\n \"Error while handling request: \" + (error.stack ?? error.message)\n );\n return errorResponse(\n error instanceof RestateError ? error.code : 500,\n error.message\n );\n }\n }\n\n private _handle(\n request: RestateRequest,\n context?: AdditionalContext\n ): RestateResponse {\n // this is the recommended way to get the relative path from a url that may be relative or absolute\n const path = new URL(request.url, \"https://example.com\").pathname;\n const parsed = parseUrlComponents(path);\n\n if (parsed.type === \"unknown\") {\n const msg =\n \"Invalid path. Allowed are /health, /discover, /invoke/SvcName/handlerName, \" +\n \"/serdes/SvcName/decode/<serdeName>, or \" +\n \"/serdes/SvcName/encode/<serdeName>, but was: \" +\n path;\n this.endpoint.rlog.trace(msg);\n return errorResponse(404, msg);\n }\n if (parsed.type === \"health\") {\n return simpleResponse(\n 200,\n {\n \"content-type\": \"application/text\",\n \"x-restate-server\": X_RESTATE_SERVER,\n },\n new TextEncoder().encode(\"OK\")\n );\n }\n\n // Discovery, preview, and handling invocations require identity verification\n const error = this.validateConnectionSignature(path, request.headers);\n if (error !== null) {\n return error;\n }\n if (parsed.type === \"discover\") {\n return handleDiscovery(\n this.endpoint,\n this.protocolMode,\n this.additionalDiscoveryFields,\n request.headers[\"accept\"]\n );\n }\n if (parsed.type === \"preview\") {\n return handlePreview(this.endpoint, parsed);\n }\n\n return this.handleInvoke(\n parsed,\n request.headers,\n request.extraArgs,\n context ?? {}\n );\n }\n\n private validateConnectionSignature(\n path: string,\n headers: Headers\n ): RestateResponse | null {\n if (!this.identityVerifier) {\n // not validating\n return null;\n }\n\n const vmHeaders = Object.entries(headers)\n .filter(([, v]) => v !== undefined)\n .map(\n ([k, v]) =>\n new vm.WasmHeader(k, v instanceof Array ? v[0]! : (v as string))\n );\n\n try {\n this.identityVerifier.verify_identity(path, vmHeaders);\n return null;\n } catch (e) {\n this.endpoint.rlog.error(\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Rejecting request as its JWT did not validate: ${e}`\n );\n return errorResponse(401, \"Unauthorized\");\n }\n }\n\n private handleInvoke(\n invokePathComponent: InvokePathComponents,\n headers: Headers,\n extraArgs: unknown[],\n additionalContext: AdditionalContext\n ): RestateResponse {\n // Check if we support this protocol version\n const serviceProtocolVersionString = headers[\"content-type\"];\n if (typeof serviceProtocolVersionString !== \"string\") {\n const errorMessage = \"Missing content-type header\";\n this.endpoint.rlog.warn(errorMessage);\n return errorResponse(415, errorMessage);\n }\n\n const service = this.endpoint.components.get(\n invokePathComponent.componentName\n );\n if (!service) {\n const msg = `No service found for URL: ${JSON.stringify(invokePathComponent)}`;\n this.endpoint.rlog.error(msg);\n return errorResponse(404, msg);\n }\n\n const handler = service.handlerMatching(invokePathComponent);\n if (!handler) {\n const msg = `No handler found for URL: ${JSON.stringify(invokePathComponent)}`;\n this.endpoint.rlog.error(msg);\n return errorResponse(404, msg);\n }\n\n return new RestateInvokeResponse(\n service,\n handler,\n headers,\n extraArgs,\n additionalContext,\n this.endpoint.journalValueCodec,\n this.endpoint.loggerTransport\n );\n }\n}\n\nclass RestateInvokeResponse implements RestateResponse {\n private readonly headers: ResponseHeaders;\n private readonly statusCode: number;\n\n private readonly loggerId: number;\n private vmLogger: Logger;\n private readonly coreVm: vm.WasmVM;\n\n constructor(\n private readonly service: Component,\n private readonly handler: ComponentHandler,\n private readonly attemptHeaders: Headers,\n private readonly extraArgs: unknown[],\n private readonly additionalContext: AdditionalContext,\n private readonly journalValueCodecInit:\n | Promise<JournalValueCodec>\n | undefined,\n private readonly loggerTransport: LoggerTransport\n ) {\n this.loggerId = Math.floor(Math.random() * 4_294_967_295 /* u32::MAX */);\n const isJournalCodecDefined = this.journalValueCodecInit !== undefined;\n\n // Instantiate core vm and prepare response headers\n const vmHeaders = Object.entries(this.attemptHeaders)\n .filter(([, v]) => v !== undefined)\n .map(\n ([k, v]) =>\n new vm.WasmHeader(k, v instanceof Array ? v[0]! : (v as string))\n );\n this.coreVm = new vm.WasmVM(\n vmHeaders,\n restateLogLevelToWasmLogLevel(DEFAULT_CONSOLE_LOGGER_LOG_LEVEL),\n this.loggerId,\n isJournalCodecDefined,\n handler.executionOptions.explicitCancellation ?? false\n );\n const responseHead = this.coreVm.get_response_head();\n this.statusCode = responseHead.status_code;\n this.headers = responseHead.headers.reduce(\n (headers, { key, value }) => ({\n [key]: value,\n ...headers,\n }),\n {\n \"x-restate-server\": X_RESTATE_SERVER,\n }\n );\n this.vmLogger = createLogger(\n this.loggerTransport,\n LogSource.JOURNAL,\n new LoggerContext(\n invocationIdFromHeaders(this.attemptHeaders),\n this.service.name(),\n this.handler.name(),\n undefined,\n undefined,\n this.additionalContext\n )\n );\n }\n\n async process({\n inputReader,\n outputWriter,\n writeHead,\n abortSignal,\n }: {\n inputReader: InputReader;\n outputWriter: OutputWriter;\n writeHead: (statusCode: number, headers: ResponseHeaders) => void;\n abortSignal: AbortSignal;\n }): Promise<void> {\n // Commit the response head immediately — the VM-determined head is known\n // at construction time and never changes during processing.\n writeHead(this.statusCode, this.headers);\n\n abortSignal.addEventListener(\n \"abort\",\n () => {\n // In any case, on abort remove the invocation logger to avoid memory leaks\n destroyLogger(this.loggerId);\n\n // When the HTTP connection closes (e.g. abort timeout), poison the VM.\n // We only read new input from the server when a Restate command is\n // waiting for a response. If no command has been issued, the server's\n // abort signal is never read. Poisoning the VM ensures the handler\n // fails on the next VM call (e.g. ctx.run, ctx.sleep).\n setImmediate(() => {\n const msg = \"Connection closed\";\n this.coreVm.notify_error(msg, msg);\n });\n },\n { once: true }\n );\n // Use a default logger that still respects the endpoint custom logger\n // We will override this later with a logger that has a LoggerContext\n // See vm_log below for more details\n registerLogger(this.loggerId, this.vmLogger);\n\n const journalValueCodec: JournalValueCodec = this.journalValueCodecInit\n ? await this.journalValueCodecInit\n : {\n encode: (entry) => entry,\n decode: (entry) => Promise.resolve(entry),\n };\n\n // This promise is used to signal the end of the computation,\n // which can be either the user returns a value,\n // or an exception gets caught, or the state machine fails/suspends.\n //\n // The last case is handled internally within the ContextImpl.\n const invocationEndPromise = Promise.withResolvers<void>();\n let ctx: ContextImpl;\n\n // Initial phase before running user code\n // -> Buffer in shared core the journal entries\n // -> Initiate loggers\n // -> Initialize the ContextImpl\n try {\n // Buffer journal inside shared core\n await bufferJournalReplayInCoreVm(this.coreVm, inputReader);\n\n // Get input from coreVm to build the request object\n const input = this.coreVm.sys_input();\n const invocationRequest: Request = {\n target: {\n service: this.service.name(),\n handler: this.handler.name(),\n key: input.key || undefined,\n toString() {\n return this.key !== undefined\n ? `${this.service}/${this.key}/${this.handler}`\n : `${this.service}/${this.handler}`;\n },\n },\n id: input.invocation_id as InvocationId,\n headers: input.headers.reduce((headers, { key, value }) => {\n headers.set(key, value);\n return headers;\n }, new Map()),\n attemptHeaders: Object.entries(this.attemptHeaders).reduce(\n (headers, [key, value]) => {\n if (value !== undefined) {\n headers.set(key, value instanceof Array ? value[0] : value);\n }\n return headers;\n },\n new Map()\n ),\n body: input.input,\n extraArgs: this.extraArgs,\n attemptCompletedSignal: abortSignal,\n };\n\n // Prepare logger\n const loggerContext = new LoggerContext(\n input.invocation_id,\n this.handler.component().name(),\n this.handler.name(),\n this.handler.kind() === HandlerKind.SERVICE ? undefined : input.key,\n invocationRequest,\n this.additionalContext\n );\n const ctxLogger = createLogger(\n this.loggerTransport,\n LogSource.USER,\n loggerContext,\n () => !this.coreVm.is_processing()\n );\n // Override the vmLogger created before with more info!\n this.vmLogger = createLogger(\n this.loggerTransport,\n LogSource.JOURNAL,\n loggerContext\n // Filtering is done within the shared core\n );\n\n // See vm_log below for more details\n registerLogger(this.loggerId, this.vmLogger);\n if (!this.coreVm.is_processing()) {\n this.vmLogger.info(\"Replaying invocation.\");\n } else {\n this.vmLogger.info(\"Starting invocation.\");\n }\n\n // Prepare context\n ctx = new ContextImpl(\n this.coreVm,\n input,\n ctxLogger,\n this.handler.kind(),\n this.vmLogger,\n invocationRequest,\n invocationEndPromise,\n inputReader,\n outputWriter,\n journalValueCodec,\n this.handler.executionOptions\n );\n } catch (e) {\n // That's \"preflight\" failure cases, where stuff fails before running user code\n // In this scenario, we close the coreVm, then flush and close\n const error = ensureError(e);\n this.coreVm.notify_error(error.message, error.message);\n try {\n await flushAndClose(\n this.coreVm,\n this.vmLogger,\n Promise.resolve(inputReader),\n outputWriter\n );\n } finally {\n // Safety net: the abort listener should clean this up when the attempt\n // ends, but process() owns the logger registration, so avoid leaking if\n // an adapter ever fails to abort the attempt-completed signal.\n destroyLogger(this.loggerId);\n }\n return;\n }\n\n // Run user code. Errors that reach the handler or interceptor code\n // (handler throws, interceptor throws, entry completes with terminal\n // failure) propagate naturally. Errors where the handler is stuck on\n // an await that will never settle (e.g. suspension, retryable run\n // error) are broken out by raceWithAttemptEnd, which races against\n // invocationEndPromise — rejected by ContextImpl when the attempt ends.\n try {\n await startUserHandler(\n ctx,\n this.service,\n this.handler,\n journalValueCodec\n );\n } catch (e) {\n notifyError(e, ctx, this.handler.executionOptions.asTerminalError);\n } finally {\n try {\n await flushAndClose(\n this.coreVm,\n this.vmLogger,\n ctx.inputPump.stop(),\n outputWriter\n );\n } finally {\n // Safety net: the abort listener should clean this up when the attempt\n // ends, but process() owns the logger registration, so avoid leaking if\n // an adapter ever fails to abort the attempt-completed signal.\n destroyLogger(this.loggerId);\n }\n }\n }\n}\n\nasync function bufferJournalReplayInCoreVm(\n coreVm: vm.WasmVM,\n inputReader: InputReader\n) {\n while (!coreVm.is_ready_to_execute()) {\n const nextValue = await inputReader.next();\n if (nextValue.done) {\n coreVm.notify_input_closed();\n break;\n }\n if (nextValue.value !== undefined) {\n coreVm.notify_input(nextValue.value);\n }\n }\n}\n\nasync function startUserHandler(\n ctx: ContextImpl,\n service: Component,\n handler: ComponentHandler,\n journalValueCodec: JournalValueCodec\n) {\n // Instantiate hooks from providers.\n // If a provider throws, the same rules as handler failures apply:\n // TerminalError → terminate invocation, other errors → retry.\n const hooks: Hooks[] = [];\n for (const provider of handler.executionOptions.hooks ?? []) {\n const hookContext: { request: Request } = {\n request: ctx.request(),\n };\n Object.defineProperty(hookContext, HOOK_CONTEXT_IS_PROCESSING_SYMBOL, {\n value: () => ctx.isProcessing(),\n enumerable: false,\n });\n hooks.push(provider(hookContext));\n }\n\n // Compose interceptor.handler into a single interceptor (first = outermost)\n const handlerInterceptor = composeInterceptors(\n hooks.map((h) => h.interceptor?.handler).filter(isDefined)\n );\n\n ctx.setRunInterceptor(\n composeInterceptors(hooks.map((h) => h.interceptor?.run).filter(isDefined))\n );\n\n let encodedOutput: Uint8Array | undefined;\n await raceWithAttemptEnd(\n ctx,\n handlerInterceptor\n )(async () => {\n const decodedInput = await journalValueCodec\n .decode(ctx.request().body)\n .catch((e) =>\n // Re-throw as terminal error, to fail on input errors\n Promise.reject(\n new TerminalError(\n `Failed to decode input using journal value codec: ${\n ensureError(e).message\n }`,\n {\n errorCode: 400,\n }\n )\n )\n );\n\n // Then run user code\n const output = await handler.invoke(ctx, decodedInput);\n\n // Encode user code output\n encodedOutput = journalValueCodec.encode(output);\n });\n\n // Interceptor chain completed without error — commit the result.\n // sys_end() is called here (after interceptors) so that interceptor\n // errors after next() correctly prevent the invocation from succeeding.\n ctx.coreVm.sys_write_output_success(encodedOutput!);\n ctx.coreVm.sys_end();\n ctx.vmLogger.info(\"Invocation completed successfully.\");\n}\n\n/**\n * Classifies the error and notifies the VM. Called from the process() catch\n * block — the single place that decides how to report errors to the VM.\n */\nfunction notifyError(\n e: unknown,\n ctx: ContextImpl,\n asTerminalError?: (error: unknown) => TerminalError | undefined\n) {\n // Command-specific errors from ContextImpl carry metadata the VM needs\n // for command correlation. Check before ensureError to preserve the type.\n if (e instanceof CommandError) {\n const cause = ensureError(e.cause);\n logError(ctx.vmLogger, cause);\n if (e.hasCommandIndex) {\n // Completion failure — command exists in the journal\n ctx.coreVm.notify_error_for_specific_command(\n cause.message,\n cause.stack,\n e.commandType,\n e.commandIndex!,\n null\n );\n } else {\n // Preparation failure — command not yet issued\n ctx.coreVm.notify_error_for_next_command(\n cause.message,\n cause.stack,\n e.commandType\n );\n }\n return;\n }\n\n // Handler/interceptor errors\n const error = ensureError(e, asTerminalError);\n logError(ctx.vmLogger, error);\n\n try {\n if (error instanceof TerminalError) {\n // Terminal: write the failure as the invocation output\n ctx.coreVm.sys_write_output_failure({\n code: error.code,\n message: error.message,\n metadata: Object.entries(error.metadata ?? {}).map(([key, value]) => ({\n key,\n value,\n })),\n });\n ctx.coreVm.sys_end();\n } else if (error instanceof RetryableError) {\n // Retryable with explicit delay\n ctx.coreVm.notify_error_with_delay_override(\n error.message,\n error.stack,\n error.retryAfter !== undefined\n ? BigInt(millisOrDurationToMillis(error.retryAfter))\n : undefined\n );\n } else {\n if (error instanceof PauseError) {\n ctx.vmLogger.warn(\n \"Throwing PauseError from the handler context will be ignored, \" +\n \"as it leads to pause loops. You should use PauseError only inside `ctx.run`\"\n );\n }\n\n // Transient error — VM decides retry policy\n ctx.coreVm.notify_error(error.message, error.stack);\n }\n } catch (vmError) {\n // Safety net: if sys_write_output_failure or other VM calls fail,\n // fall back to notify_error.\n const inner = ensureError(vmError);\n ctx.coreVm.notify_error(inner.message, inner.stack);\n }\n}\n\nasync function flushAndClose(\n coreVm: vm.WasmVM,\n vmLogger: Logger,\n inputReaderGetter: Promise<InputReader>,\n outputWriter: OutputWriter\n): Promise<void> {\n let inputClosed = false;\n try {\n // Consume output till the end, write it out, then close the stream\n let nextOutput = coreVm.take_output() as Uint8Array | null | undefined;\n while (nextOutput !== null && nextOutput !== undefined) {\n await outputWriter.write(nextOutput);\n nextOutput = coreVm.take_output() as Uint8Array | null | undefined;\n }\n\n // --- After this point, we should have flushed the shared core internal buffer\n\n // Wait for the input reader.\n // In case we executed the user code, this is wired up to the InputPump.stop()\n // to make sure there is only one reader for inputReader.\n const inputReader = await inputReaderGetter;\n\n // Let's make sure we properly close the request stream before closing the response stream\n while (!inputClosed) {\n try {\n const res = await inputReader.next();\n inputClosed = res.done ?? false;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n inputClosed = true;\n }\n }\n\n // Close the response stream\n await outputWriter.close();\n } catch (e) {\n // In case of failure, we can do little here except just logging stuff out,\n // because outputWriter is not usable here.\n const error = ensureError(e);\n const abortErrorOnWrite = isAbortErrorOnWrite(error);\n\n if (inputClosed && abortErrorOnWrite) {\n // Because we closed the input already,\n // these errors are benign and are caused by\n // synchronization issues wrt closing the response stream in the runtime\n // This will be fixed in the runtime with https://github.com/restatedev/restate/issues/4456\n return;\n }\n\n if (abortErrorOnWrite) {\n vmLogger.error(\n \"Got abort error from connection: \" +\n error.message +\n \"\\n\" +\n \"This might indicate that:\\n\" +\n \"* The restate-server aborted the connection after hitting the 'abort-timeout'\\n\" +\n \"* The connection with the restate-server was lost\\n\" +\n \"\\n\" +\n \"Please check the invocation in the Restate UI for more details.\"\n );\n } else {\n vmLogger.error(\n \"Error while handling request: \" + (error.stack ?? error.message)\n );\n }\n }\n}\n\nfunction isAbortErrorOnWrite(error: Error) {\n return (\n error.name === \"AbortError\" ||\n error.message === \"Invalid state: WritableStream is closed\" ||\n /**\n * Node stream closed error thrown on writes\n */\n (error as { code?: string }).code === \"ERR_HTTP2_INVALID_STREAM\"\n );\n}\n\n// -- Hook composition utils --------------------------------------------------\n\ntype InterceptorFn<Args extends unknown[]> = (\n ...args: [...Args, () => Promise<void>]\n) => Promise<void>;\n\nfunction composeInterceptors<Args extends unknown[]>(\n interceptors: InterceptorFn<Args>[]\n): InterceptorFn<Args> {\n return interceptors.reduceRight<InterceptorFn<Args>>(\n (innerInterceptor, interceptor) =>\n (...args) => {\n const context = args.slice(0, -1) as unknown as Args;\n const callback = args.at(-1) as () => Promise<void>;\n return interceptor(...context, () =>\n innerInterceptor(...context, callback)\n );\n },\n (...args) => (args.at(-1) as () => Promise<void>)()\n );\n}\n\n/**\n * Wraps an interceptor so that both `next()` and the interceptor body race\n * against `invocationEndPromise`. When the attempt ends (suspension, retryable\n * error, etc.), the promise rejects and the interceptor chain unwinds through\n * catch/finally blocks — preventing interceptors from hanging on a `next()`\n * that will never settle.\n *\n * SDK-internal metadata (CommandError, retryAfter) is stripped before the\n * interceptor sees the error and restored after the chain exits.\n */\nfunction raceWithAttemptEnd<Args extends unknown[]>(\n ctx: ContextImpl,\n interceptor: InterceptorFn<Args>\n): InterceptorFn<Args> {\n return (...args) => {\n let originalError: unknown;\n\n // Strip SDK metadata before interceptors see the error.\n // Store the original in the closure for restoration after the chain.\n const signal = ctx.invocationEndPromise.promise.catch((e) => {\n originalError = e;\n throw sanitizeError(e);\n }) as Promise<never>;\n\n const originalNext = args.at(-1) as () => Promise<void>;\n const racingNext = () => Promise.race([originalNext(), signal]);\n const newArgs = [...args.slice(0, -1), racingNext] as unknown as [\n ...Args,\n () => Promise<void>,\n ];\n\n return Promise.race([interceptor(...newArgs), signal]).catch((e) => {\n // Restore SDK metadata after the interceptor chain exits.\n if (originalError !== undefined) {\n throw restoreError(e, originalError);\n }\n throw e;\n });\n };\n}\n\nfunction isDefined<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\n// -- Logging utils -----------------------------------------------------------\n\nfunction restateLogLevelToWasmLogLevel(level: RestateLogLevel): vm.LogLevel {\n switch (level) {\n case RestateLogLevel.TRACE:\n return vm.LogLevel.TRACE;\n case RestateLogLevel.DEBUG:\n return vm.LogLevel.DEBUG;\n case RestateLogLevel.INFO:\n return vm.LogLevel.INFO;\n case RestateLogLevel.WARN:\n return vm.LogLevel.WARN;\n case RestateLogLevel.ERROR:\n return vm.LogLevel.ERROR;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuEA,MAAM,oCAAoC,OAAO,IAC/C,6CACD;AAED,SAAgB,qBACd,UACA,cACA,2BACgB;AAChB,QAAO,IAAI,mBACT,UACA,cACA,0BACD;;;;;AAMH,IAAM,qBAAN,MAAmD;CACjD,AAAiB;CAEjB,YACE,AAASA,UACT,AAAiBC,cACjB,AAAiBC,2BACjB;EAHS;EACQ;EACA;AAGjB,MACE,KAAK,SAAS,WAAW,UACzB,KAAK,SAAS,OAAO,WAAW,EAEhC,MAAK,SAAS,KAAK,KACjB,8FACD;OACI;AACL,QAAK,SAAS,KAAK,KACjB,2CAA2C,KAAK,SAAS,OAAO,GACjE;AACD,QAAK,mBAAmB,IAAIC,qBAAwB,KAAK,SAAS,OAAO;;AAI3E,gBACE,8BAA8B,iCAAiC,CAChE;;CAIH,AAAO,OACL,SACA,SACiB;AACjB,MAAI;AACF,UAAO,KAAK,QAAQ,SAAS,QAAQ;WAC9B,GAAG;GACV,MAAM,QAAQ,YAAY,EAAE;AAC5B,IACE,0BACE,KAAK,SAAS,iBACd,QAAQ,KACR,QAAQ,QACT,IAAI,KAAK,SAAS,MACnB,MACA,oCAAoC,MAAM,SAAS,MAAM,SAC1D;AACD,UAAO,cACL,iBAAiB,eAAe,MAAM,OAAO,KAC7C,MAAM,QACP;;;CAIL,AAAQ,QACN,SACA,SACiB;EAEjB,MAAM,OAAO,IAAI,IAAI,QAAQ,KAAK,sBAAsB,CAAC;EACzD,MAAM,SAAS,mBAAmB,KAAK;AAEvC,MAAI,OAAO,SAAS,WAAW;GAC7B,MAAM,MACJ,oKAGA;AACF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AkB,iBAChB,GAAG,SAAS;EACX,MAAM,UAAU,KAAK,MAAM,GAAG,GAAG;EACjC,MAAM,WAAW,KAAK,GAAG,GAAG;AAC5B,SAAO,YAAY,GAAG,eACpB,iBAAiB,GAAG,SAAS,SAAS,CACvC;KAEJ,GAAG,SAAU,KAAK,GAAG,GAAG,EAA0B,CACpD;;;;;;;;;;;;AAaH,SAAS,mBACP,KACA,aACqB;AACrB,SAAQ,GAAG,SAAS;EAClB,IAAIC;EAIJ,MAAM,SAAS,IAAI,qBAAqB,QAAQ,OAAO,MAAM;AAC3D,mBAAgB;AAChB,SAAM,cAAc,EAAE;IACtB;EAEF,MAAM,eAAe,KAAK,GAAG,GAAG;EAChC,MAAM,mBAAmB,QAAQ,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC;EAC/D,MAAM,UAAU,CAAC,GAAG,KAAK,MAAM,GAAG,GAAG,EAAE,WAAW;AAKlD,SAAO,QAAQ,KAAK,CAAC,YAAY,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,MAAM;AAElE,OAAI,kBAAkB,OACpB,OAAM,aAAa,GAAG,cAAc;AAEtC,SAAM;IACN;;;AAIN,SAAS,UAAa,OAAyC;AAC7D,QAAO,SAAS;;AAKlB,SAAS,8BAA8B,OAAqC;AAC1E,SAAQ,OAAR;EACE,KAAK,gBAAgB,MACnB,iBAAmB;EACrB,KAAK,gBAAgB,MACnB,iBAAmB;EACrB,KAAK,gBAAgB,KACnB,iBAAmB;EACrB,KAAK,gBAAgB,KACnB,iBAAmB;EACrB,KAAK,gBAAgB,MACnB,iBAAmB"}
1
+ {"version":3,"file":"generic.js","names":["endpoint: Endpoint","protocolMode: ProtocolMode","additionalDiscoveryFields: Partial<EndpointManifest>","vm.WasmIdentityVerifier","vm.WasmHeader","service: Component","handler: ComponentHandler","attemptHeaders: Headers","extraArgs: unknown[]","additionalContext: AdditionalContext","journalValueCodecInit:\n | Promise<JournalValueCodec>\n | undefined","loggerTransport: LoggerTransport","vm.WasmVM","journalValueCodec: JournalValueCodec","ctx: ContextImpl","invocationRequest: Request","hooks: Hooks[]","hookContext: { request: Request }","encodedOutput: Uint8Array | undefined","originalError: unknown"],"sources":["../../../src/endpoint/handlers/generic.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH\n *\n * This file is part of the Restate SDK for Node.js/TypeScript,\n * which is released under the MIT license.\n *\n * You can find a copy of the license in file LICENSE in the root\n * directory of this repository or package, or at\n * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE\n */\n\nimport {\n ensureError,\n logError,\n PauseError,\n RestateError,\n RetryableError,\n TerminalError,\n} from \"../../types/errors.js\";\nimport type {\n Endpoint as EndpointManifest,\n ProtocolMode,\n} from \"../discovery.js\";\nimport {\n Component,\n ComponentHandler,\n InvokePathComponents,\n} from \"../components.js\";\nimport { parseUrlComponents } from \"../components.js\";\nimport { X_RESTATE_SERVER } from \"../../user_agent.js\";\nimport { CommandError, ContextImpl } from \"../../context_impl.js\";\nimport { restoreError, sanitizeError } from \"../../error_sanitization.js\";\nimport type { InvocationId, Request } from \"../../context.js\";\nimport * as vm from \"./vm/sdk_shared_core_wasm_bindings.js\";\nimport { HandlerKind } from \"../../types/rpc.js\";\nimport { createLogger, type Logger } from \"../../logging/logger.js\";\nimport { DEFAULT_CONSOLE_LOGGER_LOG_LEVEL } from \"../../logging/console_logger_transport.js\";\nimport {\n LoggerContext,\n LoggerTransport,\n LogSource,\n RestateLogLevel,\n} from \"../../logging/logger_transport.js\";\nimport {\n type JournalValueCodec,\n millisOrDurationToMillis,\n} from \"@restatedev/restate-sdk-core\";\nimport type { Endpoint } from \"../endpoint.js\";\nimport {\n type RestateHandler,\n type Headers,\n type RestateRequest,\n type AdditionalContext,\n type RestateResponse,\n ResponseHeaders,\n InputReader,\n OutputWriter,\n} from \"./types.js\";\nimport { handleDiscovery } from \"./discovery.js\";\nimport { handlePreview } from \"./preview.js\";\nimport {\n errorResponse,\n invocationIdFromHeaders,\n simpleResponse,\n tryCreateContextualLogger,\n} from \"./utils.js\";\nimport { destroyLogger, registerLogger } from \"./core_logging.js\";\nimport type { Hooks } from \"../../hooks.js\";\n\n// Hidden symbol key used by first-party hooks to read the live\n// replay/processing phase without widening the public HooksProvider API.\nconst HOOK_CONTEXT_IS_PROCESSING_SYMBOL = Symbol.for(\n \"@restatedev/restate-sdk/hooks.isProcessing\"\n);\n\nexport function createRestateHandler(\n endpoint: Endpoint,\n protocolMode: ProtocolMode,\n additionalDiscoveryFields: Partial<EndpointManifest>\n): RestateHandler {\n return new RestateHandlerImpl(\n endpoint,\n protocolMode,\n additionalDiscoveryFields\n );\n}\n\n/**\n * This is the RestateHandler implementation\n */\nclass RestateHandlerImpl implements RestateHandler {\n private readonly identityVerifier?: vm.WasmIdentityVerifier;\n\n constructor(\n readonly endpoint: Endpoint,\n private readonly protocolMode: ProtocolMode,\n private readonly additionalDiscoveryFields: Partial<EndpointManifest>\n ) {\n // Setup identity verifier\n if (\n this.endpoint.keySet === undefined ||\n this.endpoint.keySet.length === 0\n ) {\n this.endpoint.rlog.warn(\n `Accepting requests without validating request signatures; handler access must be restricted`\n );\n } else {\n this.endpoint.rlog.info(\n `Validating requests using signing keys [${this.endpoint.keySet}]`\n );\n this.identityVerifier = new vm.WasmIdentityVerifier(this.endpoint.keySet);\n }\n\n // Set the logging level in the shared core too!\n vm.set_log_level(\n restateLogLevelToWasmLogLevel(DEFAULT_CONSOLE_LOGGER_LOG_LEVEL)\n );\n }\n\n // handle does not throw.\n public handle(\n request: RestateRequest,\n context?: AdditionalContext\n ): RestateResponse {\n try {\n return this._handle(request, context);\n } catch (e) {\n const error = ensureError(e);\n (\n tryCreateContextualLogger(\n this.endpoint.loggerTransport,\n request.url,\n request.headers\n ) ?? this.endpoint.rlog\n ).error(\n \"Error while handling request: \" + (error.stack ?? error.message)\n );\n return errorResponse(\n error instanceof RestateError ? error.code : 500,\n error.message\n );\n }\n }\n\n private _handle(\n request: RestateRequest,\n context?: AdditionalContext\n ): RestateResponse {\n // this is the recommended way to get the relative path from a url that may be relative or absolute\n const path = new URL(request.url, \"https://example.com\").pathname;\n const parsed = parseUrlComponents(path);\n\n if (parsed.type === \"unknown\") {\n const msg =\n \"Invalid path. Allowed are /health, /discover, /invoke/SvcName/handlerName, \" +\n \"/serdes/SvcName/decode/<serdeName>, or \" +\n \"/serdes/SvcName/encode/<serdeName>, but was: \" +\n path;\n this.endpoint.rlog.trace(msg);\n return errorResponse(404, msg);\n }\n if (parsed.type === \"health\") {\n return simpleResponse(\n 200,\n {\n \"content-type\": \"application/text\",\n \"x-restate-server\": X_RESTATE_SERVER,\n },\n new TextEncoder().encode(\"OK\")\n );\n }\n\n // Discovery, preview, and handling invocations require identity verification\n const error = this.validateConnectionSignature(path, request.headers);\n if (error !== null) {\n return error;\n }\n if (parsed.type === \"discover\") {\n return handleDiscovery(\n this.endpoint,\n this.protocolMode,\n this.additionalDiscoveryFields,\n request.headers[\"accept\"]\n );\n }\n if (parsed.type === \"preview\") {\n return handlePreview(this.endpoint, parsed);\n }\n\n return this.handleInvoke(\n parsed,\n request.headers,\n request.extraArgs,\n context ?? {}\n );\n }\n\n private validateConnectionSignature(\n path: string,\n headers: Headers\n ): RestateResponse | null {\n if (!this.identityVerifier) {\n // not validating\n return null;\n }\n\n const vmHeaders = Object.entries(headers)\n .filter(([, v]) => v !== undefined)\n .map(\n ([k, v]) =>\n new vm.WasmHeader(k, v instanceof Array ? v[0]! : (v as string))\n );\n\n try {\n this.identityVerifier.verify_identity(path, vmHeaders);\n return null;\n } catch (e) {\n this.endpoint.rlog.error(\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Rejecting request as its JWT did not validate: ${e}`\n );\n return errorResponse(401, \"Unauthorized\");\n }\n }\n\n private handleInvoke(\n invokePathComponent: InvokePathComponents,\n headers: Headers,\n extraArgs: unknown[],\n additionalContext: AdditionalContext\n ): RestateResponse {\n // Check if we support this protocol version\n const serviceProtocolVersionString = headers[\"content-type\"];\n if (typeof serviceProtocolVersionString !== \"string\") {\n const errorMessage = \"Missing content-type header\";\n this.endpoint.rlog.warn(errorMessage);\n return errorResponse(415, errorMessage);\n }\n\n const service = this.endpoint.components.get(\n invokePathComponent.componentName\n );\n if (!service) {\n const msg = `No service found for URL: ${JSON.stringify(invokePathComponent)}`;\n this.endpoint.rlog.error(msg);\n return errorResponse(404, msg);\n }\n\n const handler = service.handlerMatching(invokePathComponent);\n if (!handler) {\n const msg = `No handler found for URL: ${JSON.stringify(invokePathComponent)}`;\n this.endpoint.rlog.error(msg);\n return errorResponse(404, msg);\n }\n\n return new RestateInvokeResponse(\n service,\n handler,\n headers,\n extraArgs,\n additionalContext,\n this.endpoint.journalValueCodec,\n this.endpoint.loggerTransport\n );\n }\n}\n\nclass RestateInvokeResponse implements RestateResponse {\n private readonly headers: ResponseHeaders;\n private readonly statusCode: number;\n\n private readonly loggerId: number;\n private vmLogger: Logger;\n private readonly coreVm: vm.WasmVM;\n\n constructor(\n private readonly service: Component,\n private readonly handler: ComponentHandler,\n private readonly attemptHeaders: Headers,\n private readonly extraArgs: unknown[],\n private readonly additionalContext: AdditionalContext,\n private readonly journalValueCodecInit:\n | Promise<JournalValueCodec>\n | undefined,\n private readonly loggerTransport: LoggerTransport\n ) {\n this.loggerId = Math.floor(Math.random() * 4_294_967_295 /* u32::MAX */);\n const isJournalCodecDefined = this.journalValueCodecInit !== undefined;\n\n // Instantiate core vm and prepare response headers\n const vmHeaders = Object.entries(this.attemptHeaders)\n .filter(([, v]) => v !== undefined)\n .map(\n ([k, v]) =>\n new vm.WasmHeader(k, v instanceof Array ? v[0]! : (v as string))\n );\n this.coreVm = new vm.WasmVM(\n vmHeaders,\n restateLogLevelToWasmLogLevel(DEFAULT_CONSOLE_LOGGER_LOG_LEVEL),\n this.loggerId,\n isJournalCodecDefined,\n handler.executionOptions.explicitCancellation ?? false\n );\n const responseHead = this.coreVm.get_response_head();\n this.statusCode = responseHead.status_code;\n this.headers = responseHead.headers.reduce(\n (headers, { key, value }) => ({\n [key]: value,\n ...headers,\n }),\n {\n \"x-restate-server\": X_RESTATE_SERVER,\n }\n );\n this.vmLogger = createLogger(\n this.loggerTransport,\n LogSource.JOURNAL,\n new LoggerContext(\n invocationIdFromHeaders(this.attemptHeaders),\n this.service.name(),\n this.handler.name(),\n undefined,\n undefined,\n this.additionalContext\n )\n );\n }\n\n async process({\n inputReader,\n outputWriter,\n writeHead,\n abortSignal,\n }: {\n inputReader: InputReader;\n outputWriter: OutputWriter;\n writeHead: (statusCode: number, headers: ResponseHeaders) => void;\n abortSignal: AbortSignal;\n }): Promise<void> {\n // Commit the response head immediately — the VM-determined head is known\n // at construction time and never changes during processing.\n writeHead(this.statusCode, this.headers);\n\n abortSignal.addEventListener(\n \"abort\",\n () => {\n // In any case, on abort remove the invocation logger to avoid memory leaks\n destroyLogger(this.loggerId);\n\n // When the HTTP connection closes (e.g. abort timeout), poison the VM.\n // We only read new input from the server when a Restate command is\n // waiting for a response. If no command has been issued, the server's\n // abort signal is never read. Poisoning the VM ensures the handler\n // fails on the next VM call (e.g. ctx.run, ctx.sleep).\n setImmediate(() => {\n const msg = \"Connection closed\";\n this.coreVm.notify_error(msg, msg);\n });\n },\n { once: true }\n );\n // Use a default logger that still respects the endpoint custom logger\n // We will override this later with a logger that has a LoggerContext\n // See vm_log below for more details\n registerLogger(this.loggerId, this.vmLogger);\n\n const journalValueCodec: JournalValueCodec = this.journalValueCodecInit\n ? await this.journalValueCodecInit\n : {\n encode: (entry) => entry,\n decode: (entry) => Promise.resolve(entry),\n };\n\n // This promise is used to signal the end of the computation,\n // which can be either the user returns a value,\n // or an exception gets caught, or the state machine fails/suspends.\n //\n // The last case is handled internally within the ContextImpl.\n const invocationEndPromise = Promise.withResolvers<void>();\n let ctx: ContextImpl;\n\n // Initial phase before running user code\n // -> Buffer in shared core the journal entries\n // -> Initiate loggers\n // -> Initialize the ContextImpl\n try {\n // Buffer journal inside shared core\n await bufferJournalReplayInCoreVm(this.coreVm, inputReader);\n\n // Get input from coreVm to build the request object\n const input = this.coreVm.sys_input();\n const invocationRequest: Request = {\n target: {\n service: this.service.name(),\n handler: this.handler.name(),\n key: input.key || undefined,\n toString() {\n return this.key !== undefined\n ? `${this.service}/${this.key}/${this.handler}`\n : `${this.service}/${this.handler}`;\n },\n },\n id: input.invocation_id as InvocationId,\n headers: input.headers.reduce((headers, { key, value }) => {\n headers.set(key, value);\n return headers;\n }, new Map()),\n attemptHeaders: Object.entries(this.attemptHeaders).reduce(\n (headers, [key, value]) => {\n if (value !== undefined) {\n headers.set(key, value instanceof Array ? value[0] : value);\n }\n return headers;\n },\n new Map()\n ),\n body: input.input,\n extraArgs: this.extraArgs,\n attemptCompletedSignal: abortSignal,\n };\n\n // Prepare logger\n const loggerContext = new LoggerContext(\n input.invocation_id,\n this.handler.component().name(),\n this.handler.name(),\n this.handler.kind() === HandlerKind.SERVICE ? undefined : input.key,\n invocationRequest,\n this.additionalContext\n );\n const ctxLogger = createLogger(\n this.loggerTransport,\n LogSource.USER,\n loggerContext,\n () => !this.coreVm.is_processing()\n );\n // Override the vmLogger created before with more info!\n this.vmLogger = createLogger(\n this.loggerTransport,\n LogSource.JOURNAL,\n loggerContext\n // Filtering is done within the shared core\n );\n\n // See vm_log below for more details\n registerLogger(this.loggerId, this.vmLogger);\n if (!this.coreVm.is_processing()) {\n this.vmLogger.info(\"Replaying invocation.\");\n } else {\n this.vmLogger.info(\"Starting invocation.\");\n }\n\n // Prepare context\n ctx = new ContextImpl(\n this.coreVm,\n input,\n ctxLogger,\n this.handler.kind(),\n this.vmLogger,\n invocationRequest,\n invocationEndPromise,\n inputReader,\n outputWriter,\n journalValueCodec,\n this.handler.executionOptions\n );\n } catch (e) {\n // That's \"preflight\" failure cases, where stuff fails before running user code\n // In this scenario, we close the coreVm, then flush and close\n const error = ensureError(e);\n this.coreVm.notify_error(error.message, error.message);\n try {\n await flushAndClose(\n this.coreVm,\n this.vmLogger,\n Promise.resolve(inputReader),\n outputWriter\n );\n } finally {\n // Safety net: the abort listener should clean this up when the attempt\n // ends, but process() owns the logger registration, so avoid leaking if\n // an adapter ever fails to abort the attempt-completed signal.\n destroyLogger(this.loggerId);\n }\n return;\n }\n\n // Run user code. Errors that reach the handler or interceptor code\n // (handler throws, interceptor throws, entry completes with terminal\n // failure) propagate naturally. Errors where the handler is stuck on\n // an await that will never settle (e.g. suspension, retryable run\n // error) are broken out by raceWithAttemptEnd, which races against\n // invocationEndPromise — rejected by ContextImpl when the attempt ends.\n try {\n await startUserHandler(\n ctx,\n this.service,\n this.handler,\n journalValueCodec\n );\n } catch (e) {\n notifyError(e, ctx, this.handler.executionOptions.asTerminalError);\n } finally {\n try {\n await flushAndClose(\n this.coreVm,\n this.vmLogger,\n ctx.inputPump.stop(),\n outputWriter\n );\n } finally {\n // Safety net: the abort listener should clean this up when the attempt\n // ends, but process() owns the logger registration, so avoid leaking if\n // an adapter ever fails to abort the attempt-completed signal.\n destroyLogger(this.loggerId);\n }\n }\n }\n}\n\nasync function bufferJournalReplayInCoreVm(\n coreVm: vm.WasmVM,\n inputReader: InputReader\n) {\n while (!coreVm.is_ready_to_execute()) {\n const nextValue = await inputReader.next();\n if (nextValue.done) {\n coreVm.notify_input_closed();\n break;\n }\n if (nextValue.value !== undefined) {\n coreVm.notify_input(nextValue.value);\n }\n }\n}\n\nasync function startUserHandler(\n ctx: ContextImpl,\n service: Component,\n handler: ComponentHandler,\n journalValueCodec: JournalValueCodec\n) {\n // Instantiate hooks from providers.\n // If a provider throws, the same rules as handler failures apply:\n // TerminalError → terminate invocation, other errors → retry.\n const hooks: Hooks[] = [];\n for (const provider of handler.executionOptions.hooks ?? []) {\n const hookContext: { request: Request } = {\n request: ctx.request(),\n };\n Object.defineProperty(hookContext, HOOK_CONTEXT_IS_PROCESSING_SYMBOL, {\n value: () => ctx.isProcessing(),\n enumerable: false,\n });\n hooks.push(provider(hookContext));\n }\n\n // Compose interceptor.handler into a single interceptor (first = outermost)\n const handlerInterceptor = composeInterceptors(\n hooks.map((h) => h.interceptor?.handler).filter(isDefined)\n );\n\n ctx.setRunInterceptor(\n composeInterceptors(hooks.map((h) => h.interceptor?.run).filter(isDefined))\n );\n\n let encodedOutput: Uint8Array | undefined;\n await raceWithAttemptEnd(\n ctx,\n handlerInterceptor\n )(async () => {\n const decodedInput = await journalValueCodec\n .decode(ctx.request().body)\n .catch((e) =>\n // Re-throw as terminal error, to fail on input errors\n Promise.reject(\n new TerminalError(\n `Failed to decode input using journal value codec: ${\n ensureError(e).message\n }`,\n {\n errorCode: 400,\n }\n )\n )\n );\n\n // Then run user code\n const output = await handler.invoke(ctx, decodedInput);\n\n // Encode user code output\n encodedOutput = journalValueCodec.encode(output);\n });\n\n // Interceptor chain completed without error — commit the result.\n // sys_end() is called here (after interceptors) so that interceptor\n // errors after next() correctly prevent the invocation from succeeding.\n ctx.coreVm.sys_write_output_success(encodedOutput!);\n ctx.coreVm.sys_end();\n ctx.vmLogger.info(\"Invocation completed successfully.\");\n}\n\n/**\n * Classifies the error and notifies the VM. Called from the process() catch\n * block — the single place that decides how to report errors to the VM.\n */\nfunction notifyError(\n e: unknown,\n ctx: ContextImpl,\n asTerminalError?: (error: unknown) => TerminalError | undefined\n) {\n // Command-specific errors from ContextImpl carry metadata the VM needs\n // for command correlation. Check before ensureError to preserve the type.\n if (e instanceof CommandError) {\n const cause = ensureError(e.cause);\n logError(ctx.vmLogger, cause);\n if (e.hasCommandIndex) {\n // Completion failure — command exists in the journal\n ctx.coreVm.notify_error_for_specific_command(\n cause.message,\n cause.stack,\n e.commandType,\n e.commandIndex!,\n null\n );\n } else {\n // Preparation failure — command not yet issued\n ctx.coreVm.notify_error_for_next_command(\n cause.message,\n cause.stack,\n e.commandType\n );\n }\n return;\n }\n\n // Handler/interceptor errors\n const error = ensureError(e, asTerminalError);\n logError(ctx.vmLogger, error);\n\n try {\n if (error instanceof TerminalError) {\n // Terminal: write the failure as the invocation output\n ctx.coreVm.sys_write_output_failure({\n code: error.code,\n message: error.message,\n metadata: Object.entries(error.metadata ?? {}).map(([key, value]) => ({\n key,\n value,\n })),\n });\n ctx.coreVm.sys_end();\n } else if (error instanceof RetryableError) {\n // Retryable with explicit delay\n ctx.coreVm.notify_error_with_delay_override(\n error.message,\n error.stack,\n error.retryAfter !== undefined\n ? BigInt(millisOrDurationToMillis(error.retryAfter))\n : undefined\n );\n } else {\n if (error instanceof PauseError) {\n ctx.vmLogger.warn(\n \"Throwing PauseError from the handler context will be ignored, \" +\n \"as it leads to pause loops. You should use PauseError only inside `ctx.run`\"\n );\n }\n\n // Transient error — VM decides retry policy\n ctx.coreVm.notify_error(error.message, error.stack);\n }\n } catch (vmError) {\n // Safety net: if sys_write_output_failure or other VM calls fail,\n // fall back to notify_error.\n const inner = ensureError(vmError);\n ctx.coreVm.notify_error(inner.message, inner.stack);\n }\n}\n\nasync function flushAndClose(\n coreVm: vm.WasmVM,\n vmLogger: Logger,\n inputReaderGetter: Promise<InputReader>,\n outputWriter: OutputWriter\n): Promise<void> {\n let inputClosed = false;\n try {\n // Consume vm output buffer, write it out, then close the stream\n const nextOutput = coreVm.take_output();\n if (nextOutput?.length > 0) {\n await outputWriter.write(nextOutput);\n }\n\n // --- After this point, we should have flushed the shared core internal buffer\n\n // Wait for the input reader.\n // In case we executed the user code, this is wired up to the InputPump.stop()\n // to make sure there is only one reader for inputReader.\n const inputReader = await inputReaderGetter;\n\n // Let's make sure we properly close the request stream before closing the response stream\n while (!inputClosed) {\n try {\n const res = await inputReader.next();\n inputClosed = res.done ?? false;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n inputClosed = true;\n }\n }\n\n // Close the response stream\n await outputWriter.close();\n } catch (e) {\n // In case of failure, we can do little here except just logging stuff out,\n // because outputWriter is not usable here.\n const error = ensureError(e);\n const abortErrorOnWrite = isAbortErrorOnWrite(error);\n\n if (inputClosed && abortErrorOnWrite) {\n // Because we closed the input already,\n // these errors are benign and are caused by\n // synchronization issues wrt closing the response stream in the runtime\n // This will be fixed in the runtime with https://github.com/restatedev/restate/issues/4456\n return;\n }\n\n if (abortErrorOnWrite) {\n vmLogger.error(\n \"Got abort error from connection: \" +\n error.message +\n \"\\n\" +\n \"This might indicate that:\\n\" +\n \"* The restate-server aborted the connection after hitting the 'abort-timeout'\\n\" +\n \"* The connection with the restate-server was lost\\n\" +\n \"\\n\" +\n \"Please check the invocation in the Restate UI for more details.\"\n );\n } else {\n vmLogger.error(\n \"Error while handling request: \" + (error.stack ?? error.message)\n );\n }\n }\n}\n\nfunction isAbortErrorOnWrite(error: Error) {\n return (\n error.name === \"AbortError\" ||\n error.message === \"Invalid state: WritableStream is closed\" ||\n /**\n * Node stream closed error thrown on writes\n */\n (error as { code?: string }).code === \"ERR_HTTP2_INVALID_STREAM\"\n );\n}\n\n// -- Hook composition utils --------------------------------------------------\n\ntype InterceptorFn<Args extends unknown[]> = (\n ...args: [...Args, () => Promise<void>]\n) => Promise<void>;\n\nfunction composeInterceptors<Args extends unknown[]>(\n interceptors: InterceptorFn<Args>[]\n): InterceptorFn<Args> {\n return interceptors.reduceRight<InterceptorFn<Args>>(\n (innerInterceptor, interceptor) =>\n (...args) => {\n const context = args.slice(0, -1) as unknown as Args;\n const callback = args.at(-1) as () => Promise<void>;\n return interceptor(...context, () =>\n innerInterceptor(...context, callback)\n );\n },\n (...args) => (args.at(-1) as () => Promise<void>)()\n );\n}\n\n/**\n * Wraps an interceptor so that both `next()` and the interceptor body race\n * against `invocationEndPromise`. When the attempt ends (suspension, retryable\n * error, etc.), the promise rejects and the interceptor chain unwinds through\n * catch/finally blocks — preventing interceptors from hanging on a `next()`\n * that will never settle.\n *\n * SDK-internal metadata (CommandError, retryAfter) is stripped before the\n * interceptor sees the error and restored after the chain exits.\n */\nfunction raceWithAttemptEnd<Args extends unknown[]>(\n ctx: ContextImpl,\n interceptor: InterceptorFn<Args>\n): InterceptorFn<Args> {\n return (...args) => {\n let originalError: unknown;\n\n // Strip SDK metadata before interceptors see the error.\n // Store the original in the closure for restoration after the chain.\n const signal = ctx.invocationEndPromise.promise.catch((e) => {\n originalError = e;\n throw sanitizeError(e);\n }) as Promise<never>;\n\n const originalNext = args.at(-1) as () => Promise<void>;\n const racingNext = () => Promise.race([originalNext(), signal]);\n const newArgs = [...args.slice(0, -1), racingNext] as unknown as [\n ...Args,\n () => Promise<void>,\n ];\n\n return Promise.race([interceptor(...newArgs), signal]).catch((e) => {\n // Restore SDK metadata after the interceptor chain exits.\n if (originalError !== undefined) {\n throw restoreError(e, originalError);\n }\n throw e;\n });\n };\n}\n\nfunction isDefined<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\n// -- Logging utils -----------------------------------------------------------\n\nfunction restateLogLevelToWasmLogLevel(level: RestateLogLevel): vm.LogLevel {\n switch (level) {\n case RestateLogLevel.TRACE:\n return vm.LogLevel.TRACE;\n case RestateLogLevel.DEBUG:\n return vm.LogLevel.DEBUG;\n case RestateLogLevel.INFO:\n return vm.LogLevel.INFO;\n case RestateLogLevel.WARN:\n return vm.LogLevel.WARN;\n case RestateLogLevel.ERROR:\n return vm.LogLevel.ERROR;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuEA,MAAM,oCAAoC,OAAO,IAC/C,6CACD;AAED,SAAgB,qBACd,UACA,cACA,2BACgB;AAChB,QAAO,IAAI,mBACT,UACA,cACA,0BACD;;;;;AAMH,IAAM,qBAAN,MAAmD;CACjD,AAAiB;CAEjB,YACE,AAASA,UACT,AAAiBC,cACjB,AAAiBC,2BACjB;EAHS;EACQ;EACA;AAGjB,MACE,KAAK,SAAS,WAAW,UACzB,KAAK,SAAS,OAAO,WAAW,EAEhC,MAAK,SAAS,KAAK,KACjB,8FACD;OACI;AACL,QAAK,SAAS,KAAK,KACjB,2CAA2C,KAAK,SAAS,OAAO,GACjE;AACD,QAAK,mBAAmB,IAAIC,qBAAwB,KAAK,SAAS,OAAO;;AAI3E,gBACE,8BAA8B,iCAAiC,CAChE;;CAIH,AAAO,OACL,SACA,SACiB;AAC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;EACE,KAAK,gBAAgB,MACnB,iBAAmB;EACrB,KAAK,gBAAgB,MACnB,iBAAmB;EACrB,KAAK,gBAAgB,KACnB,iBAAmB;EACrB,KAAK,gBAAgB,KACnB,iBAAmB;EACrB,KAAK,gBAAgB,MACnB,iBAAmB"}
@@ -157,7 +157,7 @@ export class WasmVM {
157
157
  sys_write_output_failure(value: WasmFailure): void;
158
158
  sys_write_output_success(buffer: Uint8Array): void;
159
159
  take_notification(handle: number): WasmAsyncResultValue;
160
- take_output(): any;
160
+ take_output(): Uint8Array;
161
161
  }
162
162
 
163
163
  export function cancel_handle(): number;
@@ -839,7 +839,7 @@ export class WasmVM {
839
839
  return takeFromExternrefTable0(ret[0]);
840
840
  }
841
841
  /**
842
- * @returns {any}
842
+ * @returns {Uint8Array}
843
843
  */
844
844
  take_output() {
845
845
  const ret = wasm.wasmvm_take_output(this.__wbg_ptr);
package/dist/io.cjs CHANGED
@@ -57,7 +57,7 @@ var OutputPump = class {
57
57
  }
58
58
  async awaitNextProgress() {
59
59
  const nextOutput = this.coreVm.take_output();
60
- if (nextOutput instanceof Uint8Array) await this.outputWriter.write(nextOutput);
60
+ if (nextOutput?.length > 0) await this.outputWriter.write(nextOutput);
61
61
  }
62
62
  };
63
63
 
package/dist/io.js CHANGED
@@ -56,7 +56,7 @@ var OutputPump = class {
56
56
  }
57
57
  async awaitNextProgress() {
58
58
  const nextOutput = this.coreVm.take_output();
59
- if (nextOutput instanceof Uint8Array) await this.outputWriter.write(nextOutput);
59
+ if (nextOutput?.length > 0) await this.outputWriter.write(nextOutput);
60
60
  }
61
61
  };
62
62
 
package/dist/io.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"io.js","names":["coreVm: vm.WasmVM","inputReader: InputReader","channel: ExternalProgressChannel","errorCallback: (e: any) => void","outputWriter: OutputWriter"],"sources":["../src/io.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2025 - 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/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type * as vm from \"./endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js\";\nimport { InputReader, OutputWriter } from \"./endpoint/handlers/types.js\";\nimport { ExternalProgressChannel } from \"./utils/external_progress_channel.js\";\n\n/**\n * Adapter between input stream and vm.\n *\n * It starts a detached promise that fills the vm with input.\n * Each read (value or input-closed) emits a signal on the shared {@link ExternalProgressChannel}.\n */\nexport class InputPump {\n private stopped = false;\n private readonly runDone: Promise<InputReader>;\n\n constructor(\n private readonly coreVm: vm.WasmVM,\n private readonly inputReader: InputReader,\n private readonly channel: ExternalProgressChannel,\n private readonly errorCallback: (e: any) => void\n ) {\n this.runDone = this.run()\n .catch(() => {})\n .then(() => this.inputReader);\n }\n\n /**\n * Stop the pump.\n * Once finished, returns back the ownership of the input reader for further usage.\n */\n stop(): Promise<InputReader> {\n this.stopped = true;\n return this.runDone;\n }\n\n private async run(): Promise<void> {\n while (!this.stopped) {\n let nextValue;\n try {\n nextValue = await this.inputReader.next();\n } catch (e) {\n if (this.stopped) return;\n this.errorCallback(e);\n return;\n }\n if (this.stopped) return;\n if (nextValue.done) {\n this.coreVm.notify_input_closed();\n this.channel.signal();\n return;\n }\n if (nextValue.value !== undefined) {\n this.coreVm.notify_input(nextValue.value);\n this.channel.signal();\n }\n }\n }\n}\n\n/**\n * Adapter between output stream and vm. It moves forward when [awaitNextProgress] is invoked.\n */\nexport class OutputPump {\n constructor(\n private readonly coreVm: vm.WasmVM,\n private readonly outputWriter: OutputWriter\n ) {}\n\n async awaitNextProgress() {\n const nextOutput = this.coreVm.take_output() as\n | Uint8Array\n | null\n | undefined;\n if (nextOutput instanceof Uint8Array) {\n await this.outputWriter.write(nextOutput);\n }\n }\n}\n"],"mappings":";;;;;;;AAuBA,IAAa,YAAb,MAAuB;CACrB,AAAQ,UAAU;CAClB,AAAiB;CAEjB,YACE,AAAiBA,QACjB,AAAiBC,aACjB,AAAiBC,SACjB,AAAiBC,eACjB;EAJiB;EACA;EACA;EACA;AAEjB,OAAK,UAAU,KAAK,KAAK,CACtB,YAAY,GAAG,CACf,WAAW,KAAK,YAAY;;;;;;CAOjC,OAA6B;AAC3B,OAAK,UAAU;AACf,SAAO,KAAK;;CAGd,MAAc,MAAqB;AACjC,SAAO,CAAC,KAAK,SAAS;GACpB,IAAI;AACJ,OAAI;AACF,gBAAY,MAAM,KAAK,YAAY,MAAM;YAClC,GAAG;AACV,QAAI,KAAK,QAAS;AAClB,SAAK,cAAc,EAAE;AACrB;;AAEF,OAAI,KAAK,QAAS;AAClB,OAAI,UAAU,MAAM;AAClB,SAAK,OAAO,qBAAqB;AACjC,SAAK,QAAQ,QAAQ;AACrB;;AAEF,OAAI,UAAU,UAAU,QAAW;AACjC,SAAK,OAAO,aAAa,UAAU,MAAM;AACzC,SAAK,QAAQ,QAAQ;;;;;;;;AAS7B,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBH,QACjB,AAAiBI,cACjB;EAFiB;EACA;;CAGnB,MAAM,oBAAoB;EACxB,MAAM,aAAa,KAAK,OAAO,aAAa;AAI5C,MAAI,sBAAsB,WACxB,OAAM,KAAK,aAAa,MAAM,WAAW"}
1
+ {"version":3,"file":"io.js","names":["coreVm: vm.WasmVM","inputReader: InputReader","channel: ExternalProgressChannel","errorCallback: (e: any) => void","outputWriter: OutputWriter"],"sources":["../src/io.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2025 - 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/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type * as vm from \"./endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js\";\nimport { InputReader, OutputWriter } from \"./endpoint/handlers/types.js\";\nimport { ExternalProgressChannel } from \"./utils/external_progress_channel.js\";\n\n/**\n * Adapter between input stream and vm.\n *\n * It starts a detached promise that fills the vm with input.\n * Each read (value or input-closed) emits a signal on the shared {@link ExternalProgressChannel}.\n */\nexport class InputPump {\n private stopped = false;\n private readonly runDone: Promise<InputReader>;\n\n constructor(\n private readonly coreVm: vm.WasmVM,\n private readonly inputReader: InputReader,\n private readonly channel: ExternalProgressChannel,\n private readonly errorCallback: (e: any) => void\n ) {\n this.runDone = this.run()\n .catch(() => {})\n .then(() => this.inputReader);\n }\n\n /**\n * Stop the pump.\n * Once finished, returns back the ownership of the input reader for further usage.\n */\n stop(): Promise<InputReader> {\n this.stopped = true;\n return this.runDone;\n }\n\n private async run(): Promise<void> {\n while (!this.stopped) {\n let nextValue;\n try {\n nextValue = await this.inputReader.next();\n } catch (e) {\n if (this.stopped) return;\n this.errorCallback(e);\n return;\n }\n if (this.stopped) return;\n if (nextValue.done) {\n this.coreVm.notify_input_closed();\n this.channel.signal();\n return;\n }\n if (nextValue.value !== undefined) {\n this.coreVm.notify_input(nextValue.value);\n this.channel.signal();\n }\n }\n }\n}\n\n/**\n * Adapter between output stream and vm. It moves forward when [awaitNextProgress] is invoked.\n */\nexport class OutputPump {\n constructor(\n private readonly coreVm: vm.WasmVM,\n private readonly outputWriter: OutputWriter\n ) {}\n\n async awaitNextProgress() {\n const nextOutput = this.coreVm.take_output();\n if (nextOutput?.length > 0) {\n await this.outputWriter.write(nextOutput);\n }\n }\n}\n"],"mappings":";;;;;;;AAuBA,IAAa,YAAb,MAAuB;CACrB,AAAQ,UAAU;CAClB,AAAiB;CAEjB,YACE,AAAiBA,QACjB,AAAiBC,aACjB,AAAiBC,SACjB,AAAiBC,eACjB;EAJiB;EACA;EACA;EACA;AAEjB,OAAK,UAAU,KAAK,KAAK,CACtB,YAAY,GAAG,CACf,WAAW,KAAK,YAAY;;;;;;CAOjC,OAA6B;AAC3B,OAAK,UAAU;AACf,SAAO,KAAK;;CAGd,MAAc,MAAqB;AACjC,SAAO,CAAC,KAAK,SAAS;GACpB,IAAI;AACJ,OAAI;AACF,gBAAY,MAAM,KAAK,YAAY,MAAM;YAClC,GAAG;AACV,QAAI,KAAK,QAAS;AAClB,SAAK,cAAc,EAAE;AACrB;;AAEF,OAAI,KAAK,QAAS;AAClB,OAAI,UAAU,MAAM;AAClB,SAAK,OAAO,qBAAqB;AACjC,SAAK,QAAQ,QAAQ;AACrB;;AAEF,OAAI,UAAU,UAAU,QAAW;AACjC,SAAK,OAAO,aAAa,UAAU,MAAM;AACzC,SAAK,QAAQ,QAAQ;;;;;;;;AAS7B,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBH,QACjB,AAAiBI,cACjB;EAFiB;EACA;;CAGnB,MAAM,oBAAoB;EACxB,MAAM,aAAa,KAAK,OAAO,aAAa;AAC5C,MAAI,YAAY,SAAS,EACvB,OAAM,KAAK,aAAa,MAAM,WAAW"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "1.15.0-rc.2";
3
+ var version = "1.15.0-rc.4";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.15.0-rc.2";
2
+ var version = "1.15.0-rc.4";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@restatedev/restate-sdk\",\n \"version\": \"1.15.0-rc.2\",\n \"description\": \"Typescript SDK for Restate\",\n \"author\": \"Restate Developers\",\n \"email\": \"code@restate.dev\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/restatedev/sdk-typescript#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/restatedev/sdk-typescript.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/restatedev/sdk-typescript/issues\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./fetch\": {\n \"import\": \"./dist/fetch.js\",\n \"require\": \"./dist/fetch.cjs\"\n },\n \"./lambda\": {\n \"import\": \"./dist/lambda.js\",\n \"require\": \"./dist/lambda.cjs\"\n },\n \"./node\": {\n \"import\": \"./dist/node.js\",\n \"require\": \"./dist/node.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"test\": \"turbo run _test --filter={.}...\",\n \"_test\": \"vitest run\",\n \"build\": \"turbo run _build --filter={.}...\",\n \"_build\": \"tsc --noEmit && tsdown\",\n \"dev\": \"tsc --noEmit --watch\",\n \"clean\": \"rm -rf dist *.tsbuildinfo .turbo\",\n \"check:types\": \"turbo run _check:types --filter={.}...\",\n \"_check:types\": \"tsc --noEmit --project tsconfig.build.json\",\n \"lint\": \"eslint .\",\n \"check:exports\": \"turbo run _check:exports --filter={.}...\",\n \"_check:exports\": \"attw --pack .\",\n \"check:api\": \"turbo run _check:api --filter={.}...\",\n \"_check:api\": \"api-extractor run --local && api-extractor run --local --config api-extractor.fetch.json && api-extractor run --local --config api-extractor.lambda.json && api-extractor run --local --config api-extractor.node.json\",\n \"prepublishOnly\": \"pnpm -w verify\"\n },\n \"dependencies\": {\n \"@restatedev/restate-sdk-core\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/aws-lambda\": \"^8.10.115\"\n },\n \"typesVersions\": {\n \"*\": {\n \"fetch\": [\n \"./dist/fetch.d.ts\"\n ],\n \"lambda\": [\n \"./dist/lambda.d.ts\"\n ],\n \"node\": [\n \"./dist/node.d.ts\"\n ]\n }\n }\n}\n"],"mappings":";cAEa"}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@restatedev/restate-sdk\",\n \"version\": \"1.15.0-rc.4\",\n \"description\": \"Typescript SDK for Restate\",\n \"author\": \"Restate Developers\",\n \"email\": \"code@restate.dev\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/restatedev/sdk-typescript#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/restatedev/sdk-typescript.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/restatedev/sdk-typescript/issues\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./fetch\": {\n \"import\": \"./dist/fetch.js\",\n \"require\": \"./dist/fetch.cjs\"\n },\n \"./lambda\": {\n \"import\": \"./dist/lambda.js\",\n \"require\": \"./dist/lambda.cjs\"\n },\n \"./node\": {\n \"import\": \"./dist/node.js\",\n \"require\": \"./dist/node.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"test\": \"turbo run _test --filter={.}...\",\n \"_test\": \"vitest run\",\n \"build\": \"turbo run _build --filter={.}...\",\n \"_build\": \"tsc --noEmit && tsdown\",\n \"dev\": \"tsc --noEmit --watch\",\n \"clean\": \"rm -rf dist *.tsbuildinfo .turbo\",\n \"check:types\": \"turbo run _check:types --filter={.}...\",\n \"_check:types\": \"tsc --noEmit --project tsconfig.build.json\",\n \"lint\": \"eslint .\",\n \"check:exports\": \"turbo run _check:exports --filter={.}...\",\n \"_check:exports\": \"attw --pack .\",\n \"check:api\": \"turbo run _check:api --filter={.}...\",\n \"_check:api\": \"api-extractor run --local && api-extractor run --local --config api-extractor.fetch.json && api-extractor run --local --config api-extractor.lambda.json && api-extractor run --local --config api-extractor.node.json\",\n \"prepublishOnly\": \"pnpm -w verify\"\n },\n \"dependencies\": {\n \"@restatedev/restate-sdk-core\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/aws-lambda\": \"^8.10.115\"\n },\n \"typesVersions\": {\n \"*\": {\n \"fetch\": [\n \"./dist/fetch.d.ts\"\n ],\n \"lambda\": [\n \"./dist/lambda.d.ts\"\n ],\n \"node\": [\n \"./dist/node.d.ts\"\n ]\n }\n }\n}\n"],"mappings":";cAEa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/restate-sdk-cloudflare-workers",
3
- "version": "1.15.0-rc.2",
3
+ "version": "1.15.0-rc.4",
4
4
  "description": "Typescript SDK for Restate",
5
5
  "author": "Restate Developers",
6
6
  "email": "code@restate.dev",
@@ -35,11 +35,11 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@restatedev/restate-sdk-core": "1.15.0-rc.2"
38
+ "@restatedev/restate-sdk-core": "1.15.0-rc.4"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/aws-lambda": "^8.10.115",
42
- "@restatedev/restate-sdk": "1.15.0-rc.2"
42
+ "@restatedev/restate-sdk": "1.15.0-rc.4"
43
43
  },
44
44
  "typesVersions": {
45
45
  "*": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"context_impl.d.ts","sourceRoot":"","sources":["../src/context_impl.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,IAAI,EACJ,OAAO,EACP,cAAc,EACd,SAAS,EACT,UAAU,EAEV,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,EAAE,MA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;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,SAAS,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAQF,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,CA8BnE"}
@@ -1,184 +0,0 @@
1
- /**
2
- * This file was automatically generated by json-schema-to-typescript.
3
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
- * and run json-schema-to-typescript to regenerate this file.
5
- */
6
- export type ProtocolMode = "BIDI_STREAM" | "REQUEST_RESPONSE";
7
- export type ServiceType = "VIRTUAL_OBJECT" | "SERVICE" | "WORKFLOW";
8
- /**
9
- * If unspecified, defaults to EXCLUSIVE for Virtual Object or WORKFLOW for Workflows. This should be unset for Services.
10
- */
11
- export type HandlerType = "WORKFLOW" | "EXCLUSIVE" | "SHARED";
12
- /**
13
- * Retry policy behavior on max attempts.
14
- */
15
- export type RetryPolicyOnMaxAttempts = "PAUSE" | "KILL";
16
- /**
17
- * Retry policy behavior on max attempts.
18
- */
19
- export type RetryPolicyOnMaxAttempts1 = "PAUSE" | "KILL";
20
- /**
21
- * Restate endpoint manifest v3
22
- */
23
- export interface Endpoint {
24
- protocolMode?: ProtocolMode;
25
- /**
26
- * Minimum supported protocol version
27
- */
28
- minProtocolVersion: number;
29
- /**
30
- * Maximum supported protocol version
31
- */
32
- maxProtocolVersion: number;
33
- /**
34
- * Compression used when the endpoint is a Lambda. This is unsupported if the endpoint is a regular HTTP endpoint.
35
- */
36
- lambdaCompression?: "zstd";
37
- services: Service[];
38
- }
39
- export interface Service {
40
- name: string;
41
- /**
42
- * Documentation for this service definition. No format is enforced, but generally Markdown is assumed.
43
- */
44
- documentation?: string;
45
- ty: ServiceType;
46
- handlers: Handler[];
47
- /**
48
- * Inactivity timeout duration, expressed in milliseconds.
49
- */
50
- inactivityTimeout?: number;
51
- /**
52
- * Abort timeout duration, expressed in milliseconds.
53
- */
54
- abortTimeout?: number;
55
- /**
56
- * Journal retention duration, expressed in milliseconds.
57
- */
58
- journalRetention?: number;
59
- /**
60
- * Idempotency retention duration, expressed in milliseconds. When ServiceType == WORKFLOW, this option will be applied only to the shared handlers. See workflowCompletionRetention for more details.
61
- */
62
- idempotencyRetention?: number;
63
- /**
64
- * If true, lazy state is enabled.
65
- */
66
- enableLazyState?: boolean;
67
- /**
68
- * If true, the service cannot be invoked from the HTTP nor Kafka ingress.
69
- */
70
- ingressPrivate?: boolean;
71
- /**
72
- * Retry policy initial interval, expressed in milliseconds.
73
- */
74
- retryPolicyInitialInterval?: number;
75
- /**
76
- * Retry policy max interval, expressed in milliseconds.
77
- */
78
- retryPolicyMaxInterval?: number;
79
- /**
80
- * Retry policy max attempts.
81
- */
82
- retryPolicyMaxAttempts?: number;
83
- /**
84
- * Retry policy exponentiation factor.
85
- */
86
- retryPolicyExponentiationFactor?: number;
87
- retryPolicyOnMaxAttempts?: RetryPolicyOnMaxAttempts1;
88
- /**
89
- * Custom metadata of this service definition. This metadata is shown on the Admin API when querying the service definition.
90
- */
91
- metadata?: {
92
- [k: string]: string;
93
- };
94
- }
95
- export interface Handler {
96
- name: string;
97
- /**
98
- * Documentation for this handler definition. No format is enforced, but generally Markdown is assumed.
99
- */
100
- documentation?: string;
101
- ty?: HandlerType;
102
- input?: InputPayload;
103
- output?: OutputPayload;
104
- /**
105
- * Inactivity timeout duration, expressed in milliseconds.
106
- */
107
- inactivityTimeout?: number;
108
- /**
109
- * Abort timeout duration, expressed in milliseconds.
110
- */
111
- abortTimeout?: number;
112
- /**
113
- * Journal retention duration, expressed in milliseconds.
114
- */
115
- journalRetention?: number;
116
- /**
117
- * Idempotency retention duration, expressed in milliseconds. This is NOT VALID when HandlerType == WORKFLOW
118
- */
119
- idempotencyRetention?: number;
120
- /**
121
- * Workflow completion retention duration, expressed in milliseconds. This is valid ONLY when HandlerType == WORKFLOW
122
- */
123
- workflowCompletionRetention?: number;
124
- /**
125
- * If true, lazy state is enabled.
126
- */
127
- enableLazyState?: boolean;
128
- /**
129
- * If true, the service cannot be invoked from the HTTP nor Kafka ingress.
130
- */
131
- ingressPrivate?: boolean;
132
- /**
133
- * Retry policy initial interval, expressed in milliseconds.
134
- */
135
- retryPolicyInitialInterval?: number;
136
- /**
137
- * Retry policy max interval, expressed in milliseconds.
138
- */
139
- retryPolicyMaxInterval?: number;
140
- /**
141
- * Retry policy max attempts.
142
- */
143
- retryPolicyMaxAttempts?: number;
144
- /**
145
- * Retry policy exponentiation factor.
146
- */
147
- retryPolicyExponentiationFactor?: number;
148
- retryPolicyOnMaxAttempts?: RetryPolicyOnMaxAttempts;
149
- /**
150
- * Custom metadata of this handler definition. This metadata is shown on the Admin API when querying the service/handler definition.
151
- */
152
- metadata?: {
153
- [k: string]: string;
154
- };
155
- }
156
- /**
157
- * Description of an input payload. This will be used by Restate to validate incoming requests.
158
- */
159
- export interface InputPayload {
160
- /**
161
- * If true, a body MUST be sent with a content-type, even if the body length is zero.
162
- */
163
- required?: boolean;
164
- /**
165
- * Content type of the input. It can accept wildcards, in the same format as the 'Accept' header. When this field is unset, it implies emptiness, meaning no content-type/body is expected.
166
- */
167
- contentType?: string;
168
- jsonSchema?: unknown;
169
- }
170
- /**
171
- * Description of an output payload.
172
- */
173
- export interface OutputPayload {
174
- /**
175
- * Content type set on output. This will be used by Restate to set the output content type at the ingress.
176
- */
177
- contentType?: string;
178
- /**
179
- * If true, the specified content-type is set even if the output is empty.
180
- */
181
- setContentTypeIfEmpty?: boolean;
182
- jsonSchema?: unknown;
183
- }
184
- //# sourceMappingURL=discovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/endpoint/discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,GAAG,UAAU,CAAC;AACpE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAC9D;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,MAAM,CAAC;AACxD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AACD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,WAAW,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,eAAe,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;IACH,QAAQ,CAAC,EAAE;QACT,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACrB,CAAC;CACH;AACD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -1,7 +0,0 @@
1
- /**
2
- * This file was automatically generated by json-schema-to-typescript.
3
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
- * and run json-schema-to-typescript to regenerate this file.
5
- */
6
- export {};
7
- //# sourceMappingURL=discovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/endpoint/discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint/endpoint.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AA8B5D,MAAM,MAAM,QAAQ,GAAG;IACrB,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAE5D;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChD,CAAC;AAEF,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAKrB;IACd,OAAO,CAAC,eAAe,CAA2C;IAClE,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,qBAAqB,CAA6B;IAC1D,OAAO,CAAC,yBAAyB,CAAC,CAAmC;IAE9D,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC7B,UAAU,EACN,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7B,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC;IAUvB,eAAe,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIjC,wBAAwB,CAAC,OAAO,EAAE,qBAAqB;IAIvD,SAAS,CAAC,SAAS,EAAE,eAAe;IAIpC,4BAA4B,CACjC,aAAa,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC;IAK1C,KAAK,IAAI,QAAQ;CAqEzB"}
@@ -1,10 +0,0 @@
1
- import { Logger } from "../../logging/logger.js";
2
- import * as vm from "./vm/sdk_shared_core_wasm_bindings.js";
3
- /**
4
- * The shared core propagates logs to the SDK invoking this method.
5
- * When possible, it provides an invocationId, which is used to access the registered invocationLoggers, that should contain the logger per invocation id.
6
- */
7
- export declare function vm_log(level: vm.LogLevel, strBytes: Uint8Array, loggerId?: number): void;
8
- export declare function registerLogger(loggerId: number, logger: Logger): void;
9
- export declare function destroyLogger(loggerId: number): void;
10
- //# sourceMappingURL=core_logging.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core_logging.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/core_logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,uCAAuC,CAAC;AAU5D;;;GAGG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,EAAE,CAAC,QAAQ,EAClB,QAAQ,EAAE,UAAU,EACpB,QAAQ,CAAC,EAAE,MAAM,QA6BlB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAE9D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,QAE7C"}
@@ -1,5 +0,0 @@
1
- import type { RestateResponse } from "./types.js";
2
- import type { Endpoint } from "../endpoint.js";
3
- import type { Endpoint as EndpointManifest, ProtocolMode } from "../discovery.js";
4
- export declare function handleDiscovery(endpoint: Endpoint, protocolMode: ProtocolMode, additionalDiscoveryFields: Partial<EndpointManifest>, acceptVersionsString: string | string[] | undefined): RestateResponse;
5
- //# sourceMappingURL=discovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,QAAQ,IAAI,gBAAgB,EAC5B,YAAY,EACb,MAAM,iBAAiB,CAAC;AAQzB,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,yBAAyB,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACpD,oBAAoB,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAClD,eAAe,CA0HjB"}
@@ -1,5 +0,0 @@
1
- import type { RestateHandler } from "./types.js";
2
- export declare function fetcher(handler: RestateHandler): {
3
- fetch: (event: Request, ...extraArgs: unknown[]) => Promise<Response>;
4
- };
5
- //# sourceMappingURL=fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/fetch.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc;mBAE5B,OAAO,gBAAgB,OAAO,EAAE,KAAG,OAAO,CAAC,QAAQ,CAAC;EAiEtE"}
@@ -1,5 +0,0 @@
1
- import type { Endpoint as EndpointManifest, ProtocolMode } from "../discovery.js";
2
- import type { Endpoint } from "../endpoint.js";
3
- import { type RestateHandler } from "./types.js";
4
- export declare function createRestateHandler(endpoint: Endpoint, protocolMode: ProtocolMode, additionalDiscoveryFields: Partial<EndpointManifest>): RestateHandler;
5
- //# sourceMappingURL=generic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/generic.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,QAAQ,IAAI,gBAAgB,EAC5B,YAAY,EACb,MAAM,iBAAiB,CAAC;AAyBzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,KAAK,cAAc,EAQpB,MAAM,YAAY,CAAC;AAkBpB,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,yBAAyB,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACnD,cAAc,CAMhB"}
@@ -1,10 +0,0 @@
1
- import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context } from "aws-lambda";
2
- import { RestateHandler } from "./types.js";
3
- export declare class LambdaHandler {
4
- private readonly handler;
5
- private readonly compressionSupported;
6
- constructor(handler: RestateHandler, compressionSupported: boolean);
7
- handleRequest(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: Context): Promise<APIGatewayProxyResult | APIGatewayProxyStructuredResultV2>;
8
- }
9
- export declare function isCompressionSupported(): boolean;
10
- //# sourceMappingURL=lambda.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambda.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/lambda.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EACjC,OAAO,EACR,MAAM,YAAY,CAAC;AAKpB,OAAO,EAA6B,cAAc,EAAE,MAAM,YAAY,CAAC;AASvE,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBADpB,OAAO,EAAE,cAAc,EACvB,oBAAoB,EAAE,OAAO;IAG1C,aAAa,CACjB,KAAK,EAAE,oBAAoB,GAAG,sBAAsB,EACpD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,GAAG,iCAAiC,CAAC;CAuJtE;AAED,wBAAgB,sBAAsB,YAErC"}
@@ -1,5 +0,0 @@
1
- import type { Endpoint } from "../endpoint.js";
2
- import type { PreviewPathComponents } from "../components.js";
3
- import type { RestateResponse } from "./types.js";
4
- export declare function handlePreview(endpoint: Endpoint, previewPathComponent: PreviewPathComponents): RestateResponse;
5
- //# sourceMappingURL=preview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/preview.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB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,eAAe;IAC9B;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK,EAAE;QACb,WAAW,EAAE,WAAW,CAAC;QACzB,YAAY,EAAE,YAAY,CAAC;QAC3B,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;QAClE,WAAW,EAAE,WAAW,CAAC;KAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAE7B,QAAQ,EAAE,QAAQ,CAAC;IAEnB,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC;CAC/E"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/endpoint/handlers/types.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- import { LoggerTransport } from "../../logging/logger_transport.js";
2
- import type { Headers, InputReader, ResponseHeaders, RestateResponse } from "./types.js";
3
- import { Logger } from "../../logging/logger.js";
4
- export declare function tryCreateContextualLogger(loggerTransport: LoggerTransport, url: string, headers: Headers, additionalContext?: {
5
- [name: string]: string;
6
- }): Logger | undefined;
7
- export declare function invocationIdFromHeaders(headers: Headers): string;
8
- export declare function errorResponse(code: number, message: string): RestateResponse;
9
- export declare function simpleResponse(statusCode: number, headers: ResponseHeaders, body: Uint8Array): RestateResponse;
10
- export declare function emptyInputReader(): InputReader;
11
- /**
12
- * Bundles a `writeHead` callback with a Promise that resolves once the head
13
- * is committed. Used by adapters (fetch, lambda) that need to observe the
14
- * head commit from outside the `process()` call.
15
- */
16
- export declare function captureHead(): {
17
- writeHead: (statusCode: number, headers: ResponseHeaders) => void;
18
- head: Promise<{
19
- statusCode: number;
20
- headers: ResponseHeaders;
21
- }>;
22
- };
23
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/endpoint/handlers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAgB,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAI/D,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,EAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,iBAAiB,CAAC,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC7C,MAAM,GAAG,SAAS,CAuBpB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,UASvD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAS5E;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,UAAU,GACf,eAAe,CAgBjB;AAED,wBAAgB,gBAAgB,IAAI,WAAW,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI;IAC7B,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAClE,IAAI,EAAE,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;CACjE,CAWA"}
@@ -1,28 +0,0 @@
1
- import type { RestateEndpoint } from "../index.js";
2
- import type { JournalValueCodec, ServiceDefinition, VirtualObjectDefinition, WorkflowDefinition } from "@restatedev/restate-sdk-core";
3
- import { IncomingMessage, ServerResponse } from "node:http";
4
- import { Http2ServerRequest, Http2ServerResponse } from "node:http2";
5
- import type { LoggerTransport } from "../logging/logger_transport.js";
6
- import type { DefaultServiceOptions } from "../endpoint.js";
7
- export declare class NodeEndpoint implements RestateEndpoint {
8
- private builder;
9
- bind<P extends string, M>(definition: ServiceDefinition<P, M> | VirtualObjectDefinition<P, M> | WorkflowDefinition<P, M>): RestateEndpoint;
10
- withIdentityV1(...keys: string[]): RestateEndpoint;
11
- defaultServiceOptions(options: DefaultServiceOptions): RestateEndpoint;
12
- setLogger(logger: LoggerTransport): RestateEndpoint;
13
- journalValueCodecProvider(codecProvider: () => Promise<JournalValueCodec>): RestateEndpoint;
14
- http2Handler(options?: {
15
- bidirectional?: boolean;
16
- }): (request: Http2ServerRequest, response: Http2ServerResponse) => void;
17
- http1Handler(options?: {
18
- bidirectional?: boolean;
19
- }): (request: IncomingMessage, response: ServerResponse) => void;
20
- handler(options?: {
21
- bidirectional?: boolean;
22
- }): {
23
- (request: IncomingMessage, response: ServerResponse): void;
24
- (request: Http2ServerRequest, response: Http2ServerResponse): void;
25
- };
26
- listen(port?: number): Promise<number>;
27
- }
28
- //# sourceMappingURL=node_endpoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node_endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint/node_endpoint.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAK5D,qBAAa,YAAa,YAAW,eAAe;IAClD,OAAO,CAAC,OAAO,CAA0C;IAEl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@@
1
- import type { RestateEndpointBase } from "../endpoint.js";
2
- import type { EndpointOptions } from "./types.js";
3
- export declare function withOptions<E extends RestateEndpointBase<E>>(endpoint: E, { identityKeys, defaultServiceOptions, logger, services, journalValueCodecProvider, }: EndpointOptions): E;
4
- //# sourceMappingURL=withOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withOptions.d.ts","sourceRoot":"","sources":["../../src/endpoint/withOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,WAAW,CAAC,CAAC,SAAS,mBAAmB,CAAC,CAAC,CAAC,EAC1D,QAAQ,EAAE,CAAC,EACX,EACE,YAAY,EACZ,qBAAqB,EACrB,MAAM,EACN,QAAQ,EACR,yBAAyB,GAC1B,EAAE,eAAe,GACjB,CAAC,CAsBH"}
package/dist/endpoint.js DELETED
@@ -1,12 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH
3
- *
4
- * This file is part of the Restate SDK for Node.js/TypeScript,
5
- * which is released under the MIT license.
6
- *
7
- * You can find a copy of the license in file LICENSE in the root
8
- * directory of this repository or package, or at
9
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
10
- */
11
- export {};
12
- //# sourceMappingURL=endpoint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../src/endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Strips SDK-internal metadata from an error before it enters the interceptor
3
- * chain. Interceptors see a plain Error — no CommandError.
4
- */
5
- export declare function sanitizeError(e: unknown): Error;
6
- /**
7
- * Restores SDK-internal metadata after the interceptor chain exits, using the
8
- * original error's metadata and the interceptor's error as the new cause.
9
- * If the original had no SDK metadata, the interceptor's error passes through
10
- * unchanged.
11
- */
12
- export declare function restoreError(interceptorError: unknown, original: unknown): unknown;
13
- //# sourceMappingURL=error_sanitization.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error_sanitization.d.ts","sourceRoot":"","sources":["../src/error_sanitization.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAG/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,gBAAgB,EAAE,OAAO,EACzB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAWT"}
package/dist/hooks.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,cAAc,WAAW,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,WAAW,CAAC"}
package/dist/io.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,EAAE,MAAM,yDAAyD,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E;;;;;GAKG;AACH,qBAAa,SAAS;IAKlB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;gBAG5B,MAAM,EAAE,EAAE,CAAC,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,uBAAuB,EAChC,aAAa,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI;IAOlD;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;YAKd,GAAG;CAsBlB;AAED;;GAEG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,MAAM,EAAE,EAAE,CAAC,MAAM,EACjB,YAAY,EAAE,YAAY;IAGvC,iBAAiB;CASxB"}
@@ -1,5 +0,0 @@
1
- import type { LoggerTransport } from "./logger_transport.js";
2
- import { RestateLogLevel } from "./logger_transport.js";
3
- export declare const defaultLoggerTransport: LoggerTransport;
4
- export declare const DEFAULT_CONSOLE_LOGGER_LOG_LEVEL: RestateLogLevel;
5
- //# sourceMappingURL=console_logger_transport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"console_logger_transport.d.ts","sourceRoot":"","sources":["../../src/logging/console_logger_transport.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,eAAO,MAAM,sBAAsB,EAAE,eA0BpC,CAAC;AAKF,eAAO,MAAM,gCAAgC,iBAAwB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,SAAS,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;IACrC,WAAW,CACT,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,GAAG,EACb,GAAG,cAAc,EAAE,GAAG,EAAE,GACvB,IAAI,CAAC;CACT;AAED,wBAAgB,YAAY,CAC1B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,aAAa,EACvB,WAAW,GAAE,MAAM,OAAqB,GACvC,MAAM,CA2FR"}
@@ -1,2 +0,0 @@
1
- export declare const X_RESTATE_SERVER: string;
2
- //# sourceMappingURL=user_agent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user_agent.d.ts","sourceRoot":"","sources":["../src/user_agent.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,gBAAgB,QAA0C,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Multi-producer single-consumer unit-signal channel used to wake the
3
- * {@link PromisesExecutor} when any external progress source (input read or
4
- * run-closure completion) has made progress.
5
- *
6
- * Producers call {@link signal} to emit a progress event.
7
- * The single consumer calls {@link awaitNext} to await the next signal.
8
- *
9
- * Signals emitted with no consumer waiting are buffered, so no progress signal
10
- * is ever lost. At most one {@link awaitNext} may be pending at a time; a
11
- * concurrent second call rejects.
12
- */
13
- export declare class ExternalProgressChannel {
14
- private pending;
15
- private waiter;
16
- signal(): void;
17
- awaitNext(): Promise<void>;
18
- }
19
- //# sourceMappingURL=external_progress_channel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"external_progress_channel.d.ts","sourceRoot":"","sources":["../../src/utils/external_progress_channel.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,MAAM,CAA2B;IAEzC,MAAM,IAAI,IAAI;IAUd,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAY3B"}
@@ -1,13 +0,0 @@
1
- import type { Rand } from "../context.js";
2
- export declare class RandImpl implements Rand {
3
- private readonly checkState;
4
- private randstate256;
5
- constructor(id: bigint | [bigint, bigint, bigint, bigint], checkState?: (state: string) => void);
6
- static U64_MASK: bigint;
7
- u64(): bigint;
8
- static rotl(x: bigint, k: bigint): bigint;
9
- static U53_MASK: bigint;
10
- random(): number;
11
- uuidv4(): string;
12
- }
13
- //# sourceMappingURL=rand.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rand.d.ts","sourceRoot":"","sources":["../../src/utils/rand.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C,qBAAa,QAAS,YAAW,IAAI;IAKjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,YAAY,CAAmC;gBAGrD,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAC5B,UAAU,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAsB;IAqBxE,MAAM,CAAC,QAAQ,SAAoB;IAInC,GAAG,IAAI,MAAM;IAuBb,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIzC,MAAM,CAAC,QAAQ,SAAoB;IAE5B,MAAM,IAAI,MAAM;IAShB,MAAM,IAAI,MAAM;CAWxB"}