@pgxsinkit/pgwasm
Version:
115 lines • 4.85 kB
TypeScript
import type { BuildIdentity, FilesystemKind } from "./build/seam";
import type { QueryOptions } from "./interface";
import type { DatabaseError } from "./protocol/wire/messages";
/** The base of every error pgwasm itself raises (SQL errors are {@link DatabaseError}). */
export declare class PgwasmError extends Error {
name: string;
}
/** A `dataDir` pgwasm does not accept: an unknown scheme, a bare path, or `dataDir` with `fs`. */
export declare class UnsupportedDataDirError extends PgwasmError {
name: string;
readonly dataDir: string;
constructor(dataDir: string, reason: string);
}
/** An `opfs-ahp://` dataDir: that filesystem is gone (ADR-0062 decision 6). */
export declare class OpfsAhpRemovedError extends UnsupportedDataDirError {
name: string;
/** Where the OPFS store lives now. */
readonly replacement = "@pgxsinkit/pgwasm/opfs";
constructor(dataDir: string);
}
/** The build does not mount the requested kind of storage. */
export declare class UnsupportedFilesystemError extends PgwasmError {
name: string;
readonly kind: FilesystemKind;
readonly build: string;
constructor(kind: FilesystemKind, build: BuildIdentity, supported: readonly FilesystemKind[]);
}
/** The build needs a cross-origin-isolated context, and this one is not. */
export declare class CrossOriginIsolationRequiredError extends PgwasmError {
name: string;
constructor(build: BuildIdentity);
}
/** A server extension compiled for another build. */
export declare class ExtensionBuildMismatchError extends PgwasmError {
name: string;
constructor(extension: string, extensionBuild: string, build: BuildIdentity);
}
/** The build a data directory (or a Store backup) records. `"unmarked"` predates build markers. */
export type RecordedBuild = {
readonly build: string;
readonly dataFormat: number;
} | "unmarked";
/**
* A data directory or Store backup made by another Postgres build. A store's build is fixed when it is
* created (ADR-0063 build permanence); nothing was written.
*/
export declare class BuildMismatchError extends PgwasmError {
name: string;
readonly expected: {
readonly build: string;
readonly dataFormat: number;
};
readonly found: RecordedBuild;
readonly source: "data-directory" | "backup";
constructor(build: BuildIdentity, found: RecordedBuild, source: "data-directory" | "backup");
}
/** A data directory or backup of the same build in a data format this release does not read. */
export declare class DataFormatMismatchError extends PgwasmError {
name: string;
readonly expected: number;
readonly found: number;
readonly source: "data-directory" | "backup";
constructor(build: BuildIdentity, found: number, source: "data-directory" | "backup");
}
/** A build marker that cannot be read: corrupt, or written by a newer pgwasm. Nothing was written. */
export declare class BuildMarkerUnreadableError extends PgwasmError {
name: string;
readonly raw: string;
constructor(raw: string, reason: string);
}
/** `loadDataDir` was given for a data directory that already holds a database. */
export declare class DataDirExistsError extends PgwasmError {
name: string;
constructor();
}
/** A Store backup that cannot be restored: not a tarball, or a member outside the data directory. */
export declare class BackupFormatError extends PgwasmError {
name: string;
}
/** The storage is held by another open database (an IndexedDB store open in another context). */
export declare class StorageInUseError extends PgwasmError {
name: string;
constructor(message: string);
}
/** The database is closing or closed. */
export declare class PgwasmClosedError extends PgwasmError {
name: string;
constructor(state: "closing" | "closed");
}
/**
* The Postgres build failed underneath a statement (an exception that is not an SQL error: a storage
* failure thrown into the engine, a PANIC's abort). The instance is failed: every later statement
* throws this same error, and `close()` releases resources and rejects with it.
*/
export declare class PgwasmFailedError extends PgwasmError {
name: string;
}
/** A feature the build does not have (see its capabilities). */
export declare class UnsupportedFeatureError extends PgwasmError {
name: string;
}
/** An SQL error from a query, with the query that raised it. */
export interface QueryError extends DatabaseError {
query: string | undefined;
params: readonly unknown[] | undefined;
queryOptions: QueryOptions | undefined;
}
/** Attach the query to the SQL error it raised. */
export declare function makeQueryError(data: {
error: DatabaseError;
query: string;
params: readonly unknown[] | undefined;
options: QueryOptions | undefined;
}): QueryError;
//# sourceMappingURL=errors.d.ts.map