import { APIResource } from "../../core/resource.js"; import * as GitLinkAPI from "./git-link.js"; import { GitLink, GitLinkDeployNowResponse, GitLinkLinkParams, GitLinkLinkResponse, GitLinkRetrieveResponse, GitLinkUpdateParams, GitLinkUpdateResponse } from "./git-link.js"; import * as SecretsAPI from "./secrets.js"; import { SecretListResponse, SecretSetParams, SecretSetResponse, SecretUnsetParams, Secrets } from "./secrets.js"; import * as TriggersAPI from "./triggers.js"; import { TriggerCreateParams, TriggerCreateResponse, TriggerListResponse, TriggerUpdateParams, TriggerUpdateResponse, Triggers } from "./triggers.js"; import { APIPromise } from "../../core/api-promise.js"; import { RequestOptions } from "../../internal/request-options.js"; export declare class Functions extends APIResource { secrets: SecretsAPI.Secrets; triggers: TriggersAPI.Triggers; gitLink: GitLinkAPI.GitLink; /** * Create a new Zavu Function. The function starts in `draft` status. A dedicated * API key is auto-provisioned and injected as the `ZAVU_API_KEY` secret so the * function can call back into the Zavu API without manual setup. * * Provide `sourceCode` to seed the draft. Call * `POST /v1/functions/{functionId}/deploy` afterwards to publish. * * @example * ```ts * const _function = await client.functions.create({ * name: 'Order Bot', * slug: 'order-bot', * dependencies: { openai: '^4.20.0' }, * description: * 'Replies to order status questions on WhatsApp.', * sourceCode: * "import { defineFunction } from '@zavudev/functions';\n\nexport default defineFunction(async (event, ctx) => {\n ctx.log('received', event.type);\n});\n", * }); * ``` */ create(body: FunctionCreateParams, options?: RequestOptions): APIPromise; /** * Get function * * @example * ```ts * const _function = await client.functions.retrieve( * 'functionId', * ); * ``` */ retrieve(functionID: string, options?: RequestOptions): APIPromise; /** * Update an existing function. `sourceCode` / `dependencies` edit the draft * without triggering a build — they go live on the next * `POST /v1/functions/{functionId}/deploy`. `httpEnabled` is applied to the * deployed function immediately, so turning the public endpoint on or off does not * require a redeploy. * * @example * ```ts * const _function = await client.functions.update( * 'functionId', * ); * ``` */ update(functionID: string, body: FunctionUpdateParams, options?: RequestOptions): APIPromise; /** * Permanently delete a function and cascade: triggers, secrets, deployment * history, managed agents+tools, and revoke the auto-provisioned API key. The AWS * Lambda + log group are torn down asynchronously. * * @example * ```ts * const _function = await client.functions.delete( * 'functionId', * ); * ``` */ delete(functionID: string, options?: RequestOptions): APIPromise; /** * Publish the function. If `sourceCode` or `dependencies` are provided in the * body, they replace the current draft before deployment. Returns immediately with * a deployment ID — poll `GET /v1/functions/deployments/{deploymentId}` until * status is `active` or `failed`. * * @example * ```ts * const response = await client.functions.deploy( * 'functionId', * ); * ``` */ deploy(functionID: string, body?: FunctionDeployParams | null | undefined, options?: RequestOptions): APIPromise; /** * Fetch a deployment to poll its status during a deploy. * * @example * ```ts * const response = await client.functions.getDeployment( * 'deploymentId', * ); * ``` */ getDeployment(deploymentID: string, options?: RequestOptions): APIPromise; /** * List a function's deployment history, newest first. Source code is omitted; * fetch a single deployment via GET /v1/functions/deployments/{deploymentId} for * full details. * * @example * ```ts * const response = await client.functions.listDeployments( * 'functionId', * ); * ``` */ listDeployments(functionID: string, query?: FunctionListDeploymentsParams | null | undefined, options?: RequestOptions): APIPromise; /** * List the event types a function trigger can subscribe to. Includes the special * type `cron`, which fires on a schedule (see POST * /v1/functions/{functionId}/triggers) rather than on a messaging event. * * @example * ```ts * const response = await client.functions.listEventTypes(); * ``` */ listEventTypes(options?: RequestOptions): APIPromise; /** * Re-deploy a previous version by copying its source, dependencies, and runtime * pin onto the function's draft, then deploying. Returns immediately with a * deployment ID — poll GET /v1/functions/deployments/{deploymentId} until status * is active or failed. Secrets are not rolled back. * * @example * ```ts * const response = await client.functions.rollbackDeployment( * 'functionId', * { deploymentId: 'fnd_abc123' }, * ); * ``` */ rollbackDeployment(functionID: string, body: FunctionRollbackDeploymentParams, options?: RequestOptions): APIPromise; /** * Fetch invocation logs for a function. Logs are paginated via `nextToken`. Pass * `startTime` / `endTime` (Unix epoch milliseconds) to bound the window, or * `filterPattern` to filter messages. * * @example * ```ts * const response = await client.functions.tailLogs( * 'functionId', * ); * ``` */ tailLogs(functionID: string, query?: FunctionTailLogsParams | null | undefined, options?: RequestOptions): APIPromise; } export interface FunctionCreateResponse { /** * A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to * messaging events or HTTP requests. */ function: FunctionCreateResponse.Function; } export declare namespace FunctionCreateResponse { /** * A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to * messaging events or HTTP requests. */ interface Function { id: string; createdAt: string; /** * npm dependencies installed in the function bundle. Keys are package names, * values are semver ranges. */ dependencies: { [key: string]: string; }; /** * Whether the function can be invoked over HTTPS via its public URL. */ httpEnabled: boolean; /** * Memory allocation in MB. */ memoryMb: number; name: string; /** * Runtime the function is deployed on. */ runtime: 'nodejs24'; /** * URL-safe identifier, unique per project. */ slug: string; /** * Lifecycle status of a Zavu Function. */ status: 'draft' | 'bundling' | 'deploying' | 'active' | 'failed' | 'disabled'; /** * Per-invocation timeout in seconds. */ timeoutSec: number; updatedAt: string; /** * ID of the deployment currently serving traffic. */ activeDeploymentId?: string | null; description?: string | null; /** * HTTPS endpoint, present only while httpEnabled is true. Null otherwise, * including for a function that was previously exposed — the stored URL stops * serving the moment HTTP is turned off, so it is never returned. */ publicUrl?: string | null; } } export interface FunctionRetrieveResponse { /** * A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to * messaging events or HTTP requests. */ function: FunctionRetrieveResponse.Function; } export declare namespace FunctionRetrieveResponse { /** * A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to * messaging events or HTTP requests. */ interface Function { id: string; createdAt: string; /** * npm dependencies installed in the function bundle. Keys are package names, * values are semver ranges. */ dependencies: { [key: string]: string; }; /** * Whether the function can be invoked over HTTPS via its public URL. */ httpEnabled: boolean; /** * Memory allocation in MB. */ memoryMb: number; name: string; /** * Runtime the function is deployed on. */ runtime: 'nodejs24'; /** * URL-safe identifier, unique per project. */ slug: string; /** * Lifecycle status of a Zavu Function. */ status: 'draft' | 'bundling' | 'deploying' | 'active' | 'failed' | 'disabled'; /** * Per-invocation timeout in seconds. */ timeoutSec: number; updatedAt: string; /** * ID of the deployment currently serving traffic. */ activeDeploymentId?: string | null; description?: string | null; /** * HTTPS endpoint, present only while httpEnabled is true. Null otherwise, * including for a function that was previously exposed — the stored URL stops * serving the moment HTTP is turned off, so it is never returned. */ publicUrl?: string | null; } } export interface FunctionUpdateResponse { /** * A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to * messaging events or HTTP requests. */ function: FunctionUpdateResponse.Function; } export declare namespace FunctionUpdateResponse { /** * A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to * messaging events or HTTP requests. */ interface Function { id: string; createdAt: string; /** * npm dependencies installed in the function bundle. Keys are package names, * values are semver ranges. */ dependencies: { [key: string]: string; }; /** * Whether the function can be invoked over HTTPS via its public URL. */ httpEnabled: boolean; /** * Memory allocation in MB. */ memoryMb: number; name: string; /** * Runtime the function is deployed on. */ runtime: 'nodejs24'; /** * URL-safe identifier, unique per project. */ slug: string; /** * Lifecycle status of a Zavu Function. */ status: 'draft' | 'bundling' | 'deploying' | 'active' | 'failed' | 'disabled'; /** * Per-invocation timeout in seconds. */ timeoutSec: number; updatedAt: string; /** * ID of the deployment currently serving traffic. */ activeDeploymentId?: string | null; description?: string | null; /** * HTTPS endpoint, present only while httpEnabled is true. Null otherwise, * including for a function that was previously exposed — the stored URL stops * serving the moment HTTP is turned off, so it is never returned. */ publicUrl?: string | null; } } export interface FunctionDeleteResponse { deleted: boolean; name?: string; slug?: string; } export interface FunctionDeployResponse { deployment: FunctionDeployResponse.Deployment; } export declare namespace FunctionDeployResponse { interface Deployment { id: string; createdAt: string; functionId: string; /** * Stage of a function deployment. */ status: 'pending' | 'bundling' | 'uploading' | 'publishing' | 'active' | 'failed' | 'superseded'; /** * Monotonically increasing deployment version, starting at 1. */ version: number; /** * What the build printed: dependency installation, the bundler's output, and the * compiler's message when it failed. Returned when fetching a single deployment, * omitted from the list. Read this first when a deploy fails — `errorMessage` is * often the outer wrapper's summary, and the line that names the broken import or * the syntax error is here. */ buildLogs?: string | null; /** * Size of the built bundle in bytes. Null until the build finishes. */ bundleBytes?: number | null; deployedAt?: string | null; /** * Failure reason when status is 'failed'. */ errorMessage?: string | null; /** * Total size of the deployed source tree in bytes. */ sourceCodeBytes?: number | null; } } export interface FunctionGetDeploymentResponse { deployment: FunctionGetDeploymentResponse.Deployment; } export declare namespace FunctionGetDeploymentResponse { interface Deployment { id: string; createdAt: string; functionId: string; /** * Stage of a function deployment. */ status: 'pending' | 'bundling' | 'uploading' | 'publishing' | 'active' | 'failed' | 'superseded'; /** * Monotonically increasing deployment version, starting at 1. */ version: number; /** * What the build printed: dependency installation, the bundler's output, and the * compiler's message when it failed. Returned when fetching a single deployment, * omitted from the list. Read this first when a deploy fails — `errorMessage` is * often the outer wrapper's summary, and the line that names the broken import or * the syntax error is here. */ buildLogs?: string | null; /** * Size of the built bundle in bytes. Null until the build finishes. */ bundleBytes?: number | null; deployedAt?: string | null; /** * Failure reason when status is 'failed'. */ errorMessage?: string | null; /** * Total size of the deployed source tree in bytes. */ sourceCodeBytes?: number | null; } } export interface FunctionListDeploymentsResponse { deployments: Array; } export declare namespace FunctionListDeploymentsResponse { interface Deployment { id?: string; bundleSizeBytes?: number | null; createdAt?: string; deployedAt?: string | null; errorMessage?: string | null; isActive?: boolean; /** * Stage of a function deployment. */ status?: 'pending' | 'bundling' | 'uploading' | 'publishing' | 'active' | 'failed' | 'superseded'; version?: number; } } export interface FunctionListEventTypesResponse { events: Array; } export interface FunctionRollbackDeploymentResponse { deployment: FunctionRollbackDeploymentResponse.Deployment; /** * The draft that was replaced, so a UI can offer to restore it. */ previousDraft?: unknown | null; rolledBackToVersion?: number; } export declare namespace FunctionRollbackDeploymentResponse { interface Deployment { id: string; createdAt: string; functionId: string; /** * Stage of a function deployment. */ status: 'pending' | 'bundling' | 'uploading' | 'publishing' | 'active' | 'failed' | 'superseded'; /** * Monotonically increasing deployment version, starting at 1. */ version: number; /** * What the build printed: dependency installation, the bundler's output, and the * compiler's message when it failed. Returned when fetching a single deployment, * omitted from the list. Read this first when a deploy fails — `errorMessage` is * often the outer wrapper's summary, and the line that names the broken import or * the syntax error is here. */ buildLogs?: string | null; /** * Size of the built bundle in bytes. Null until the build finishes. */ bundleBytes?: number | null; deployedAt?: string | null; /** * Failure reason when status is 'failed'. */ errorMessage?: string | null; /** * Total size of the deployed source tree in bytes. */ sourceCodeBytes?: number | null; } } export interface FunctionTailLogsResponse { events: Array; /** * Pass to the next request to fetch the following page of logs. */ nextToken?: string | null; } export declare namespace FunctionTailLogsResponse { interface Event { message: string; timestamp: string; } } export interface FunctionCreateParams { name: string; /** * URL-safe identifier (lowercase, digits, hyphens). Must be unique per project. */ slug: string; /** * npm dependencies. Keys are package names, values are semver ranges. */ dependencies?: { [key: string]: string; }; description?: string; /** * Which file in `files` is the entry point. Defaults to `index.ts`. */ entrypoint?: string; /** * The project's source files, keyed by path relative to the project root (e.g. * `index.ts`, `lib/orders.ts`). Imports between them are resolved when the * function is built, so a function can be split across as many files as it needs. * * Paths must be relative and use forward slashes; `..`, `node_modules/` and * `package.json` are rejected. npm packages are not uploaded here — declare them * under `dependencies` and Zavu installs them. Limits: 200 files and 900,000 bytes * for the whole tree. */ files?: { [key: string]: string; }; /** * Whether to expose a public HTTPS URL for this function. */ httpEnabled?: boolean; memoryMb?: 128 | 256 | 512 | 1024; /** * Runtime the function is deployed on. */ runtime?: 'nodejs24'; /** * Shortcut for a single-file function: exactly equivalent to sending `files` with * one entry named after `entrypoint` (`index.ts` by default). Fully supported — * use whichever fits. If both are sent, `files` wins. */ sourceCode?: string; /** * Per-invocation timeout in seconds. Event and cron invocations are asynchronous, * so a long timeout only bounds cost; a tool called during a live conversation * holds up the reply, and a function exposed over HTTP is additionally bounded by * the platform's HTTP response limit. */ timeoutSec?: number; } export interface FunctionUpdateParams { /** * New dependency map (replaces existing dependencies). */ dependencies?: { [key: string]: string; }; /** * Which file in `files` is the entry point. Defaults to `index.ts`. */ entrypoint?: string; /** * The project's source files, keyed by path relative to the project root (e.g. * `index.ts`, `lib/orders.ts`). Imports between them are resolved when the * function is built, so a function can be split across as many files as it needs. * * Paths must be relative and use forward slashes; `..`, `node_modules/` and * `package.json` are rejected. npm packages are not uploaded here — declare them * under `dependencies` and Zavu installs them. Limits: 200 files and 900,000 bytes * for the whole tree. */ files?: { [key: string]: string; }; /** * Expose the function on its public HTTPS URL, or take it down. Applies to the * already-deployed function without redeploying; the URL is returned as * `publicUrl`. */ httpEnabled?: boolean; /** * Shortcut for a single-file function: exactly equivalent to sending `files` with * one entry named after `entrypoint` (`index.ts` by default). Fully supported — * use whichever fits. If both are sent, `files` wins. */ sourceCode?: string; } export interface FunctionDeployParams { /** * New dependency map (replaces existing dependencies). */ dependencies?: { [key: string]: string; }; /** * Which file in `files` is the entry point. Defaults to `index.ts`. */ entrypoint?: string; /** * The project's source files, keyed by path relative to the project root (e.g. * `index.ts`, `lib/orders.ts`). Imports between them are resolved when the * function is built, so a function can be split across as many files as it needs. * * Paths must be relative and use forward slashes; `..`, `node_modules/` and * `package.json` are rejected. npm packages are not uploaded here — declare them * under `dependencies` and Zavu installs them. Limits: 200 files and 900,000 bytes * for the whole tree. */ files?: { [key: string]: string; }; /** * Shortcut for a single-file function: exactly equivalent to sending `files` with * one entry named after `entrypoint` (`index.ts` by default). Fully supported — * use whichever fits. If both are sent, `files` wins. */ sourceCode?: string; } export interface FunctionListDeploymentsParams { limit?: number; } export interface FunctionRollbackDeploymentParams { /** * ID of the deployment to roll back to. */ deploymentId: string; } export interface FunctionTailLogsParams { /** * End of the log window in Unix epoch milliseconds. */ endTime?: number; filterPattern?: string; limit?: number; nextToken?: string; /** * Start of the log window in Unix epoch milliseconds. */ startTime?: number; } export declare namespace Functions { export { type FunctionCreateResponse as FunctionCreateResponse, type FunctionRetrieveResponse as FunctionRetrieveResponse, type FunctionUpdateResponse as FunctionUpdateResponse, type FunctionDeleteResponse as FunctionDeleteResponse, type FunctionDeployResponse as FunctionDeployResponse, type FunctionGetDeploymentResponse as FunctionGetDeploymentResponse, type FunctionListDeploymentsResponse as FunctionListDeploymentsResponse, type FunctionListEventTypesResponse as FunctionListEventTypesResponse, type FunctionRollbackDeploymentResponse as FunctionRollbackDeploymentResponse, type FunctionTailLogsResponse as FunctionTailLogsResponse, type FunctionCreateParams as FunctionCreateParams, type FunctionUpdateParams as FunctionUpdateParams, type FunctionDeployParams as FunctionDeployParams, type FunctionListDeploymentsParams as FunctionListDeploymentsParams, type FunctionRollbackDeploymentParams as FunctionRollbackDeploymentParams, type FunctionTailLogsParams as FunctionTailLogsParams, }; export { Secrets as Secrets, type SecretListResponse as SecretListResponse, type SecretSetResponse as SecretSetResponse, type SecretSetParams as SecretSetParams, type SecretUnsetParams as SecretUnsetParams, }; export { Triggers as Triggers, type TriggerCreateResponse as TriggerCreateResponse, type TriggerUpdateResponse as TriggerUpdateResponse, type TriggerListResponse as TriggerListResponse, type TriggerCreateParams as TriggerCreateParams, type TriggerUpdateParams as TriggerUpdateParams, }; export { GitLink as GitLink, type GitLinkRetrieveResponse as GitLinkRetrieveResponse, type GitLinkUpdateResponse as GitLinkUpdateResponse, type GitLinkDeployNowResponse as GitLinkDeployNowResponse, type GitLinkLinkResponse as GitLinkLinkResponse, type GitLinkUpdateParams as GitLinkUpdateParams, type GitLinkLinkParams as GitLinkLinkParams, }; } //# sourceMappingURL=functions.d.ts.map