@promptbook/openai
Version:
Promptbook: Turn your company's scattered knowledge into AI ready books
66 lines (65 loc) • 2.55 kB
TypeScript
/**
* HTTP header used by Promptbook clients to advertise their release version.
*
* @public exported from `@promptbook/utils`
*/
export declare const CLIENT_VERSION_HEADER = "x-promptbook-client-version";
/**
* The latest client (engine) version that the server expects.
*
* @public exported from `@promptbook/utils`
*/
export declare const CLIENT_LATEST_VERSION: string;
/**
* Determines if the provided version string exactly matches the latest release.
*
* @param version - Version string obtained from a request header.
* @returns True when the version equals `CLIENT_LATEST_VERSION`.
*
* @public exported from `@promptbook/utils`
*/
export declare function isClientVersionCompatible(version: unknown): version is string;
/**
* Formats the message that should be shown when a client is out of date.
*
* @param clientVersion - The version reported by the client (optional).
* @returns User-facing text explaining how to fix the mismatch.
*
* @public exported from `@promptbook/utils`
*/
export declare function formatClientVersionMismatchMessage(clientVersion?: string | null): string;
/**
* Error thrown when the client version does not match the server requirements.
*
* @param requiredVersion - Version enforced by the server.
* @param reportedVersion - Version reported by the client (optional).
* @param message - Optional human-readable message describing the mismatch.
*
* @public exported from `@promptbook/utils`
*/
export declare class ClientVersionMismatchError extends Error {
readonly requiredVersion: string;
readonly reportedVersion: string | null;
constructor(requiredVersion: string, reportedVersion: string | null, message?: string);
}
/**
* Creates a headers object that includes the client version header.
*
* @param headers - Optional base headers to clone.
* @returns New headers object augmented with `CLIENT_VERSION_HEADER`.
*
* @public exported from `@promptbook/utils`
*/
export declare function attachClientVersionHeader<T extends Record<string, string> = Record<string, string>>(headers?: T): T & Record<typeof CLIENT_VERSION_HEADER, string>;
/**
* Normalizes the client version reported inside a `HeadersInit` object.
*
* @param headers - Headers collection to read from.
* @returns The trimmed client version or `null` when it is missing.
*
* @public exported from `@promptbook/utils`
*/
export declare function getClientVersionFromHeaders(headers?: HeadersInit): string | null;
/**
* Note: [💞] Ignore a discrepancy between file name and entity name
*/