/** * `projects` namespace — project lifecycle, introspection, and admin. * * Covers: * - remote: provision, delete, list, getUsage, getSchema, getQuote * - local: info, keys, use (require provider support for persistence methods) * * Operator-only project actions live on the {@link Admin} namespace: * - `admin.archiveProject` / `admin.reactivateProject` — moderate-archive * - `admin.setLeasePerpetual` — organization-level escape hatch (replaces the * v1.56 `projects.pin` removed in v1.57) */ import type { Client } from "../kernel.js"; import type { ProjectKeys } from "../credentials.js"; import type { ExposeManifest } from "./deploy.types.js"; import type { ExposeManifestValidationInput, ExposeManifestValidationResult, ListProjectsOptions, ListProjectsResult, ProjectDetail, ProjectInfo, ProjectRestOptions, ProjectRestResponse, ProvisionOptions, ProvisionResult, QuoteResult, RenameProjectResult, SetRepoNameResult, SchemaReport, ListTenantPaymentsOptions, TenantPaymentListResult, UsageReport, ValidateExposeOptions } from "./projects.types.js"; export declare class Projects { private readonly client; readonly schema: (id: string) => Promise; readonly usage: (id: string) => Promise; readonly quote: () => Promise; readonly promoteUser: (id: string, email: string) => Promise; readonly demoteUser: (id: string, email: string) => Promise; constructor(client: Client); /** * Provision a new Postgres project. Requires allowance auth; payment * flows through the configured fetch wrapper (x402 in Node, session * budget in sandbox). Returned keys are persisted to the local store * when the credential provider supports it. * * @throws {PaymentRequired} when the wallet has insufficient balance and * the fetch wrapper cannot sign the 402 retry. */ provision(opts?: ProvisionOptions): Promise; /** * Immediately and irreversibly delete a project. Triggers the full * destructive cascade (drop tenant schema, delete Lambda functions, * release subdomains, tombstone mailbox, wipe secrets). Local keystore * is cleaned via the credential provider when supported. * * @throws {ProjectCredentialNotFound} if local project credentials are absent. */ delete(id: string): Promise; /** * List projects in the named, domain-aware inventory (gateway * `project-findability`). Each row carries `name`, `site_url`, * `custom_domains`, `org_id` (the owning org), `status`, and * `created_at`. * * Membership-scoped by default (`GET /projects/v1`): returns every project * owned by an org the caller's principal is an active member of. This is the * cold-start lone-agent path — `list()` with no options, authenticated with * SIWX wallet auth from the credential provider. * * - `{ org }` narrows to one owning org (authorize-before-reveal: a non-member * or guessed id is a 403, a non-UUID id a 400). * - `{ all: true }` reads the operator email-union inventory across every * wallet controlling the operator's verified email * (`GET /agent/v1/operator/projects`). Pass `{ all: true, token }` with an * operator-session token for the cross-wallet union; without `token`, `all` * uses SIWX wallet auth and returns only that wallet's slice. The response * echoes the resolved `scope` (`"email"` or `"wallet"`) and is unpaged. * - `{ limit, cursor }` paginate the membership-scoped read (server default * 50, max 200). * * @throws {Run402Error} with `context: "listing projects"` on the usual * auth/network failures (e.g. `Unauthorized` when no allowance is * configured and the gateway rejects the missing SIWX header). */ list(opts?: ListProjectsOptions): Promise; /** * Rename a project (gateway `project-findability`, `PATCH /projects/v1/:id`). * Surfaces the project's `name` so a human can fix an auto-generated label. * * Authorization is org-membership based (`admin`+ on the owning org, or a * `project:write` grant) and authorize-before-reveal — an unauthorized caller * (including a guessed id) gets the same `Unauthorized` as a real-but- * unauthorized project, never a not-found oracle. The server validates the * name (non-empty, ≤ 200 chars, no control characters). * * Uses the caller's SIWX wallet auth (or a control-plane session) from the * credential provider — not a project service key — so it works without the * project being in the local keystore. * * @throws {Unauthorized} when the caller is not authorized for the project. * @throws {ApiError} (HTTP 400) when the new name is invalid. */ rename(projectId: string, name: string): Promise; /** * Claim or rename this project's per-org-unique, address-form name * (`POST /projects/v1/:id/repo-name`) — the * `` half of `run402::/`. Distinct from * {@link rename} (the free-text display name, unchanged): the address-form * name is charset-restricted (`[a-z0-9-]`, ≤63 chars) and per-org-unique. * No fee, unlike the org-slug namespace. Same authority as `rename` * (`project.rename`). */ setRepoName(projectId: string, name: string): Promise; /** * List redacted tenant x402 payment records for priced function web routes * (`GET /projects/v1/:project_id/tenant-payments`). Requires * project.tenant_payments.read server-side: org developer+ or read-scoped * project grant/delegate. */ listTenantPayments(projectId: string, opts?: ListTenantPaymentsOptions): Promise; /** * Get usage metrics for a project — API calls, storage, tier limits, * lease expiry. */ getUsage(id: string): Promise; /** * Introspect the project's database schema — tables, columns, types, * constraints, and RLS policies. */ getSchema(id: string): Promise; /** Run SQL against the project's database using the service key. Returns * the gateway envelope verbatim: `{ status, schema, rows, row_count, fields }`. */ sql(id: string, sql: string, params?: unknown[]): Promise; /** Query or mutate a project table through PostgREST. */ rest(id: string, table: string, options?: ProjectRestOptions): Promise; /** Query or mutate a project table through PostgREST and preserve HTTP status. */ restResponse(id: string, table: string, options?: ProjectRestOptions): Promise>; /** Apply the project's declarative expose manifest. */ applyExpose(id: string, manifest: ExposeManifest): Promise; /** * Validate an authorization/expose manifest without applying it. * * When `opts.project` / `opts.project_id` is supplied, the gateway validates * against that project's live schema using its service key. Otherwise it * performs projectless wallet-auth validation. `migrationSql` is validation * context only and is never executed. */ validateExpose(manifest: ExposeManifestValidationInput, opts?: ValidateExposeOptions): Promise; /** Fetch the project's current expose manifest. */ getExpose(id: string): Promise; /** * Get tier pricing — prices, lease durations, storage limits, API-call * limits. Public, no auth, no payment. */ getQuote(): Promise; /** * Authoritative single-project read — `GET /projects/v1/:id` (gateway * `project.read`). Returns the server-side {@link ProjectDetail} (identity, * owning org, tier, lifecycle, site_url + custom domains, active-release * pointer, mailbox addresses, usage vs. tier limits). Carries no secrets. * * Uses the default credential (wallet SIWX or control-plane session) and does * NOT require the project to be in the local keystore — read a project you own * via org membership without provisioning it locally. Authorize-before-reveal: * a forbidden or absent project both surface as `Unauthorized`, never a 404. * For the local anon/service keys use {@link Projects.keys} instead. */ get(id: string): Promise; /** * Inspect a project from local state. Combines the project id with the * stored keys. Does not make an API call. * * @throws {ProjectCredentialNotFound} if local project credentials are absent. */ info(id: string): Promise; /** * Return the stored anon/service keys for a project from local state. * Does not make an API call. * * @throws {ProjectCredentialNotFound} if local project credentials are absent. */ keys(id: string): Promise; /** * Set the active/default project in local state. Requires the credential * provider to support `setActiveProject`. * * Returns `void`. To both persist the active project AND get a project-scoped * client in one call, use {@link Run402.useProject} instead: * * const p = await r.useProject("prj_xxx"); * await p.apply.apply({ site: { ... } }); * * @throws {Run402Error} if the authoritative project read is not allowed. * @throws {LocalError} if the provider does not support active-project state. */ use(id: string): Promise; /** * Return the active/default project id in local state, or null when none * is set or the provider does not track active-project state. * * To resolve the active project AND build a scoped sub-client in one call, * use {@link Run402.project} (no arg): * * const p = await r.project(); // throws if no active project is set * await p.functions.list(); */ active(): Promise; } //# sourceMappingURL=projects.d.ts.map