mastra
Version:
cli for mastra
62 lines • 2.49 kB
TypeScript
export type DatabaseKind = 'turso' | 'neon' | 'mongodb';
export type DatabaseStatus = 'provisioning' | 'ready' | 'failed' | 'deleting' | 'deleted';
export interface ProjectDatabase {
id: string;
platformProjectId: string;
organizationId: string;
/** Null = project-scoped (shared by all environments). */
environmentId: string | null;
kind: DatabaseKind;
name: string;
status: DatabaseStatus;
region: string | null;
providerResourceId: string | null;
error: string | null;
createdAt: string;
updatedAt: string;
deletedAt: string | null;
}
export interface DatabaseConnectionEnvVar {
name: string;
value: string;
secret: boolean;
}
export interface DatabaseConnection {
envVars: DatabaseConnectionEnvVar[];
snippets: {
language: string;
title: string;
code: string;
}[];
docsUrl: string;
}
/**
* Env var names each provider injects at deploy time (names only — values are
* managed by the platform). Mirrors `deriveEnvVars` in the platform's
* project-databases service.
*/
export declare const DB_ENV_VAR_NAMES: Record<DatabaseKind, string[]>;
export declare function fetchDatabases(token: string, orgId: string, projectId: string): Promise<ProjectDatabase[]>;
export declare function attachDatabase(token: string, orgId: string, projectId: string, input: {
kind: DatabaseKind;
name: string;
regionId?: string;
environmentId?: string;
}): Promise<ProjectDatabase>;
export declare function fetchDatabase(token: string, orgId: string, projectId: string, dbId: string): Promise<ProjectDatabase>;
export declare function deleteDatabase(token: string, orgId: string, projectId: string, dbId: string): Promise<void>;
export declare function fetchDatabaseConnection(token: string, orgId: string, projectId: string, dbId: string): Promise<DatabaseConnection>;
/**
* Poll a database row until it leaves `provisioning`.
*
* - Resolves with the row once `status === 'ready'`.
* - Throws when provisioning fails (`status === 'failed'`), surfacing the
* provider error — never swallowed.
* - Throws on timeout with a pointer to `mastra env db show` for later inspection.
*/
export declare function pollDatabaseUntilReady(token: string, orgId: string, projectId: string, dbId: string, opts?: {
maxWaitMs?: number;
intervalMs?: number;
onStatus?: (status: DatabaseStatus) => void;
}): Promise<ProjectDatabase>;
//# sourceMappingURL=platform-api.d.ts.map