@promptbook/azure-openai
Version:
Promptbook: Run AI apps in plain human language across multiple models and platforms
46 lines (45 loc) • 1.69 kB
TypeScript
import type { string_name } from '../../types/typeAliases';
import type { really_unknown } from '../organization/really_unknown';
/**
* Options for the `checkSerializableAsJson` function
*/
export type CheckSerializableAsJsonOptions = {
/**
* Value to be checked
*/
value: really_unknown;
/**
* Semantic name of the value for debugging purposes
*/
name?: string_name;
/**
* Message alongside the value for debugging purposes
*/
message?: string;
};
/**
* Checks if the value is [🚉] serializable as JSON
* If not, throws an UnexpectedError with a rich error message and tracking
*
* - Almost all primitives are serializable BUT:
* - `undefined` is not serializable
* - `NaN` is not serializable
* - Objects and arrays are serializable if all their properties are serializable
* - Functions are not serializable
* - Circular references are not serializable
* - `Date` objects are not serializable
* - `Map` and `Set` objects are not serializable
* - `RegExp` objects are not serializable
* - `Error` objects are not serializable
* - `Symbol` objects are not serializable
* - And much more...
*
* @throws UnexpectedError if the value is not serializable as JSON
* @public exported from `@promptbook/utils`
*/
export declare function checkSerializableAsJson(options: CheckSerializableAsJsonOptions): void;
/**
* TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
* TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
*/