/** * `functions` namespace — serverless function lifecycle. * * `deploy` routes through the unified apply engine (`/apply/v1`, a * `functions.patch.set` release) — the legacy `POST /projects/v1/admin/:id/ * functions` route was removed gateway-side. invoke/logs/list/delete/update * cover `/projects/v1/admin/:id/functions*` and `/functions/v1/:name`, plus * the client-side `logsByRequestId` fan-out (no project-wide logs route * exists) and the `origin` tagging/filter on every log entry, plus * the opt-in runtime rebuild/rebuildAll against `/projects/v1/:id/functions*` * (wallet-authed, capability `function-runtime-rebuild`). */ import type { Client } from "../kernel.js"; import type { DeleteFunctionResult, FunctionDeployOptions, FunctionDeployResult, FunctionInvokeOptions, FunctionInvokeResult, FunctionListResult, FunctionLogOrigin, FunctionLogsByRequestIdOptions, FunctionLogsByRequestIdResult, FunctionLogsOptions, FunctionLogsResult, FunctionRunCreateOptions, FunctionRunHandle, FunctionRunListOptions, FunctionRunListResult, FunctionRunLogsOptions, FunctionRunRedriveOptions, FunctionRunRetryPolicy, FunctionRunWaitOptions, FunctionRebuildBatchResult, FunctionRebuildResult, FunctionUpdateOptions, FunctionUpdateResult } from "./functions.types.js"; /** * Classify one CloudWatch log line as a Lambda runtime control line * (`platform`) or function output (`app`). Pure; safe on any string. */ export declare function classifyFunctionLogLine(message: string): FunctionLogOrigin; export declare class FunctionRunTerminalError extends Error { readonly run: FunctionRunHandle; readonly code?: string; constructor(run: FunctionRunHandle); } export declare class Functions { private readonly client; readonly runs: FunctionRuns; readonly retry: { standard: (opts?: { maxAttempts?: number; minDelaySeconds?: number; maxDelaySeconds?: number; }) => FunctionRunRetryPolicy; }; constructor(client: Client); /** * Deploy a serverless function through the unified apply engine. Builds a * one-function `functions.patch.set` {@link ReleaseSpec} (additive — never * touches coexisting functions) and runs it through the same `/apply/v1` * state machine as `r.project(id).apply`. The legacy * `POST /projects/v1/admin/:id/functions` route was removed gateway-side. * * Deployed functions can `import { db, adminDb, email, ai } from * "@run402/functions"` — the in-function helper library is auto-bundled by * the platform. * * `opts.deps` lists additional npm packages to install and bundle (capability * `apply-v1-function-deps`). Bare names resolve to the latest published * version at deploy time; pinned or range specs (`"lodash@4.17.21"`, * `"date-fns@^3.0.0"`) are honored verbatim. `@run402/functions` and native * binary modules are rejected by the gateway. The actually-installed concrete * versions land on the function record (read via {@link Functions.list}) — * the apply/deploy result does not carry them, so * {@link FunctionDeployResult.deps_resolved} and `runtime_version` are `null`. * * Authorizes through the standard apply credential — a SIWX wallet, or the * operator-approval `project.deploy` gate for a wallet-less human — NOT the * project service key. Non-fatal deploy issues (bundle size warnings, esbuild * advisories) surface in {@link FunctionDeployResult.warnings}. * * @throws {ProjectNotFound} when the project is absent from the local keystore. * @throws {Run402DeployError} on any apply state-machine failure. * @throws {PaymentRequired} when the project lease has expired. */ deploy(projectId: string, opts: FunctionDeployOptions): Promise; /** * Invoke a deployed function via HTTP. Uses the project's service key as * the API key. The returned `body` is parsed JSON when the response was * JSON, otherwise the raw text. */ invoke(projectId: string, name: string, opts?: FunctionInvokeOptions): Promise; /** * Get recent logs for a function. Default tail 50; `since` accepts an ISO * 8601 timestamp or epoch milliseconds for incremental polling. Pass * `requestId` to retrieve logs correlated to a routed request failure. */ logs(projectId: string, name: string, opts?: FunctionLogsOptions): Promise; /** * Project-wide request-id search. The gateway has no cross-function logs * route, so this fans `logs()` out across every function in the project * (or just `functionName`) and merges the matches oldest-first. A function * whose read failed lands in `errors[]` by name; the others still answer. * Accepts `req_…` (the `x-run402-request-id` response header), `fnrun_…`, * and `fnatt_…` ids. */ logsByRequestId(projectId: string, requestId: string, opts?: FunctionLogsByRequestIdOptions): Promise; /** List deployed functions for a project. */ list(projectId: string): Promise; /** Delete a deployed function. */ delete(projectId: string, name: string): Promise; /** * Update a function's schedule / timeout / memory without re-deploying. * Pass `schedule: null` to remove an existing schedule; `undefined` * leaves it unchanged. */ update(projectId: string, name: string, opts: FunctionUpdateOptions): Promise; /** * Refresh a single runtime-stale function onto the gateway's current entry * wrapper + bundled runtime, WITHOUT changing its source (capability * `function-runtime-rebuild`, gateway v1.69+). * * A gateway-side fix to the function entry wrapper (e.g. the SSR `auth.*` * fixes) only reaches a deployed function when it is re-bundled — a plain * redeploy with unchanged source skips it (apply's release diff keys on the * source `code_hash`, not the wrapper). This re-bundles from the function's * STORED source with dependencies pinned to the recorded `deps_resolved` * exact versions, so the only change is the wrapper/runtime: `code_hash` is * unchanged and no new release is created. Strictly opt-in — the platform * never auto-rebuilds. * * Wallet-authed (the caller must own the project) and allowed during billing * grace (`past_due` / `frozen` / `dormant`); it adds no capacity. No service * key is required — the gateway derives it from the wallet-owned project. * * @throws {ApiError} HTTP 404 when the function does not exist; HTTP 403 when * the wallet does not own the project; HTTP 409 with code * `CANNOT_REBUILD_UNLOCKED_DEPS` for functions deployed before dependency * locking (`deps_resolved` is NULL) — redeploy from source to refresh. */ rebuild(projectId: string, name: string): Promise; /** * Refresh ALL of a project's functions onto the gateway's current entry * wrapper + bundled runtime (capability `function-runtime-rebuild`). Same * deterministic, deps-locked, release-agnostic semantics as * {@link Functions.rebuild} applied per function. * * Per-function failures are isolated and never abort the batch: a function * that fails to rebuild (bundle/upload error, or the * `CANNOT_REBUILD_UNLOCKED_DEPS` refusal) keeps its previously-deployed * artifact and is reported as `{ rebuilt: false, error, code? }` in * `results`. Wallet-authed (project ownership) and allowed during billing * grace. */ rebuildAll(projectId: string): Promise; } export declare class FunctionRuns { private readonly client; constructor(client: Client); create(projectId: string, functionName: string, opts: FunctionRunCreateOptions): Promise; list(projectId: string, functionName: string, opts?: FunctionRunListOptions): Promise; get(projectId: string, runId: string): Promise; logs(projectId: string, runId: string, opts?: FunctionRunLogsOptions): Promise; cancel(projectId: string, runId: string): Promise; redrive(projectId: string, runId: string, opts?: FunctionRunRedriveOptions): Promise; wait(projectId: string, runId: string, opts?: FunctionRunWaitOptions): Promise; } //# sourceMappingURL=functions.d.ts.map