@luzmo/embed
Version:
A modern [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for [Luzmo](https://luzmo.com) dashboards in your web application.
65 lines (64 loc) • 2.25 kB
TypeScript
/**
* Adds JSON schemas to cache.
*/
export declare function addJSONSchemas(schemas: any): void;
/**
* Returns a cached JSON schema by URL/schema $id.
*/
export declare function getCachedJSONSchema(schemaUrl: string): any;
/**
* Returns all the cached JSON schemas.
*/
export declare function getCachedJSONSchemas(): Record<string, any>;
/**
* Returns a URL for a Luzmo JSON schema name.
*/
export declare function getJSONSchemaUrl(schemaName: string): string;
/**
* Fetches a Luzmo JSON schema. If a schema is cached it's returned.
*
* Example usage:
* const schema = await fetchJSONSchema('viz-item-type');
*
* In the example above, a schema https://developer.luzmo.com/assets/json-schemas/{version}/viz-item-type.schema.json
* will be fetched and cached.
*/
export declare function fetchJSONSchema(schemaName: string): Promise<any>;
/**
* If you need to dereference Luzmo JSON schemas in your application, you can use @apidevtools/json-schema-ref-parser
* library and provide the following options for the refParser.dereference() method.
*
* Example usage:
*
* import * as refParser from '@apidevtools/json-schema-ref-parser';
* import { fetchJSONSchema, luzmoRefParserOptions } from '@luzmo/embed';
*
* async function showDereferencedSchema() {
* const schema = await fetchJSONSchema('text');
* const dereferencedSchema = await refParser.dereference(schema, luzmoRefParserOptions);
* console.log(dereferencedSchema);
* }
*
* Another example:
*
* import * as refParser from '@apidevtools/json-schema-ref-parser';
* import { addJSONSchemas, luzmoRefParserOptions } from '@luzmo/embed';
* import { TextJSONSchema, TextOptionsJSONSchema } from "@luzmo/dashboard-contents-types";
*
* async function showDereferencedSchema() {
* addJSONSchemas([TextJSONSchema, TextOptionsJSONSchema]);
* const dereferencedSchema = await refParser.dereference(TextJSONSchema, luzmoRefParserOptions);
* console.log(dereferencedSchema);
* }
*/
export declare const luzmoRefParserOptions: {
mutateInputSchema: boolean;
resolve: {
luzmo: {
order: number;
canRead: (file: any) => boolean;
read: (file: any, callback: any) => void;
};
external: boolean;
};
};