@promptbook/remote-client
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
28 lines (27 loc) • 1.01 kB
TypeScript
import type { JsonArray, JsonObject } from 'type-fest';
import type { OrderJsonOptions } from '../normalization/orderJson';
import type { CheckSerializableAsJsonOptions } from './checkSerializableAsJson';
/**
* Options for the `$exportJson` function
*/
export type ExportJsonOptions<TObject> = CheckSerializableAsJsonOptions & Partial<Pick<OrderJsonOptions<TObject & (JsonObject | JsonArray)>, 'order'>> & {
/**
* Value to be checked, ordered and deeply frozen
*/
value: TObject;
};
/**
* Utility to export a JSON object from a function
*
* 1) Checks if the value is serializable as JSON
* 2) Makes a deep clone of the object
* 2) Orders the object properties
* 2) Deeply freezes the cloned object
*
* Note: This function does not mutates the given object
*
* @returns The same type of object as the input but read-only and re-ordered
*
* @public exported from `@promptbook/utils`
*/
export declare function exportJson<TObject>(options: ExportJsonOptions<TObject>): TObject;