@proofkit/fmodata
Version:
FileMaker OData API client
132 lines (131 loc) • 6.04 kB
TypeScript
import { StandardSchemaV1 } from '@standard-schema/spec';
/**
* Base class for all fmodata errors
*/
export declare abstract class FMODataError extends Error {
abstract readonly kind: string;
readonly timestamp: Date;
constructor(message: string, options?: ErrorOptions);
}
export declare class HTTPError extends FMODataError {
readonly kind: "HTTPError";
readonly url: string;
readonly status: number;
readonly statusText: string;
readonly response?: any;
constructor(url: string, status: number, statusText: string, response?: any);
is4xx(): boolean;
is5xx(): boolean;
isNotFound(): boolean;
isUnauthorized(): boolean;
isForbidden(): boolean;
}
export declare class ODataError extends FMODataError {
readonly kind: "ODataError";
readonly url: string;
readonly code?: string;
readonly details?: any;
constructor(url: string, message: string, code?: string, details?: any);
}
export declare class SchemaLockedError extends FMODataError {
readonly kind: "SchemaLockedError";
readonly url: string;
readonly code: string;
readonly details?: any;
constructor(url: string, message: string, details?: any);
}
export declare class ValidationError extends FMODataError {
readonly kind: "ValidationError";
readonly field?: string;
readonly issues: readonly StandardSchemaV1.Issue[];
readonly value?: unknown;
constructor(message: string, issues: readonly StandardSchemaV1.Issue[], options?: {
field?: string;
value?: unknown;
cause?: Error["cause"];
});
}
export declare class ResponseStructureError extends FMODataError {
readonly kind: "ResponseStructureError";
readonly expected: string;
readonly received: any;
constructor(expected: string, received: any);
}
export declare class RecordCountMismatchError extends FMODataError {
readonly kind: "RecordCountMismatchError";
readonly expected: number | "one" | "at-most-one";
readonly received: number;
constructor(expected: number | "one" | "at-most-one", received: number);
}
export declare class InvalidLocationHeaderError extends FMODataError {
readonly kind: "InvalidLocationHeaderError";
readonly locationHeader?: string;
constructor(message: string, locationHeader?: string);
}
export declare class ResponseParseError extends FMODataError {
readonly kind: "ResponseParseError";
readonly url: string;
readonly rawText?: string;
constructor(url: string, message: string, options?: {
rawText?: string;
cause?: Error;
});
}
export declare class BatchTruncatedError extends FMODataError {
readonly kind: "BatchTruncatedError";
readonly operationIndex: number;
readonly failedAtIndex: number;
constructor(operationIndex: number, failedAtIndex: number);
}
export declare class MissingLayerServiceError extends FMODataError {
readonly kind: "MissingLayerServiceError";
readonly service: string;
constructor(service: string, options?: {
cause?: Error;
});
}
export declare class MetadataNotFoundError extends FMODataError {
readonly kind: "MetadataNotFoundError";
readonly databaseName: string;
constructor(databaseName: string);
}
export declare class BuilderInvariantError extends FMODataError {
readonly kind: "BuilderInvariantError";
readonly builder: string;
constructor(builder: string, message: string, options?: {
cause?: Error;
});
}
export declare class SchemaValidationFailedError extends FMODataError {
readonly kind: "SchemaValidationFailedError";
readonly operation: string;
readonly issues?: readonly StandardSchemaV1.Issue[];
constructor(operation: string, message: string, options?: {
issues?: readonly StandardSchemaV1.Issue[];
cause?: Error;
});
}
export declare function isHTTPError(error: unknown): error is HTTPError;
export declare function isValidationError(error: unknown): error is ValidationError;
export declare function isODataError(error: unknown): error is ODataError;
export declare function isSchemaLockedError(error: unknown): error is SchemaLockedError;
export declare function isResponseStructureError(error: unknown): error is ResponseStructureError;
export declare function isRecordCountMismatchError(error: unknown): error is RecordCountMismatchError;
export declare function isResponseParseError(error: unknown): error is ResponseParseError;
export declare function isBatchTruncatedError(error: unknown): error is BatchTruncatedError;
export declare function isMissingLayerServiceError(error: unknown): error is MissingLayerServiceError;
export declare function isMetadataNotFoundError(error: unknown): error is MetadataNotFoundError;
export declare function isBuilderInvariantError(error: unknown): error is BuilderInvariantError;
export declare function isSchemaValidationFailedError(error: unknown): error is SchemaValidationFailedError;
export declare function isFMODataError(error: unknown): error is FMODataError;
/**
* Determines whether an error is transient and safe to retry.
* Transient errors include:
* - SchemaLockedError (FM code 303 — file locked temporarily)
* - NetworkError (connection issues)
* - TimeoutError (request timed out)
* - HTTP 5xx errors (server-side failures)
*/
export declare function isTransientError(error: unknown): boolean;
export type { AbortError, CircuitOpenError, NetworkError, RetryLimitError, TimeoutError, } from '@fetchkit/ffetch';
export type FMODataErrorType = import('@fetchkit/ffetch').TimeoutError | import('@fetchkit/ffetch').AbortError | import('@fetchkit/ffetch').NetworkError | import('@fetchkit/ffetch').RetryLimitError | import('@fetchkit/ffetch').CircuitOpenError | HTTPError | ODataError | SchemaLockedError | ValidationError | ResponseStructureError | RecordCountMismatchError | InvalidLocationHeaderError | ResponseParseError | BatchTruncatedError | MissingLayerServiceError | MetadataNotFoundError | BuilderInvariantError | SchemaValidationFailedError;