UNPKG

@appsemble/lang-sdk

Version:

Language SDK for Appsemble

55 lines (54 loc) 1.98 kB
import { type Schema } from 'jsonschema'; import { type JsonArray, type JsonValue } from 'type-fest'; declare module 'jsonschema' { /** * See https://github.com/tdegrunt/jsonschema/pull/335 */ interface Schema { default?: JsonValue; examples?: JsonArray; /** * Descriptions for enum values. * * This is a JSON schema extension that’s supported by Monaco editor, and also used in Appsemble * Studio. */ enumDescriptions?: string[]; /** * If true, Appsemble renders a textarea in the graphical JSON editor. * * This is a custom property used by Appsemble. */ multiline?: boolean; } interface SchemaContext { path: (number | string)[]; } } /** * Generate data based on a JSON schema. * * The generated data doesn’t necessarily conform to the JSON schema. This is useful to prefill * forms that are based on a JSON schema, but where user input is still needed to verify the data. * * @param schema The JSON schema to generate data from. * @returns A JSON value estimated from the schema. */ export declare function generateDataFromSchema(schema?: Schema): JsonValue; /** * Combine a list of schemas into one schema matching all of them. * * The main purpose of this function is to combine a schema using `allOf` into one schema that can * be rendered. Do not use this for actual validation. Use the original `allOf` schema instead. * * @param schemas The schemas to combine. * @returns The combined schema. */ export declare function combineSchemas(...schemas: Schema[]): Schema; /** * Recursively iterate over a JSON schema and call the callback with every sub schema found. * * @param schema The JSON schema to iterate. * @param onSchema The callback to call with the found JSON schema. */ export declare function iterJSONSchema(schema: Schema, onSchema: (schema: Schema) => void): void;