UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

57 lines (56 loc) 2.64 kB
import { JSONSchema6, JSONSchema6Definition, JSONSchema7, JSONSchema7Definition } from "json-schema"; import DynamicObject from "./DynamicObject"; type JsonSchema2020Draft = { $defs: Definition[]; }; export type JsonSchema = (JSONSchema7 | JSONSchema6) & JsonSchema2020Draft; export type HierarchyEntry = { key: string; title?: string; isArrayItem?: boolean; schemaKey?: string; }; export type Hierarchy = HierarchyEntry[]; export type KeyedDefinition = [string, Definition]; export type Definition = JSONSchema7 | JSONSchema6; export type FullDefinition = Definition | boolean; export type Property = [string, Definition]; export type Context = { hierarchy: Hierarchy; required: Map<string, boolean>; references: KeyedDefinition[]; size?: "default" | "small"; }; export type OneOfType = number | "uichoice" | "object" | "array" | "string" | "number"; export type Reference = [string, Definition]; export declare function getValueByHierarchy(object: DynamicObject, hierarchy: Hierarchy): any; export declare const updateObjectByHierarchy: (object: DynamicObject, value: unknown, hierarchy: Hierarchy) => void; export declare function insertIntoObjectByHierarchy(object: DynamicObject, value: unknown, hierarchy: Hierarchy): void; export declare const minimize: (input: object | unknown[]) => unknown[] | DynamicObject; export declare function arrayToLookup<TValue>(arr: TValue[]): Map<TValue, boolean>; export declare function expandContext(context: Context, options?: { entry?: HierarchyEntry; required?: string[]; }): Context; export declare const getFullKey: (hierarchy: Hierarchy, limit?: number) => string; export declare const resolveProperty: (property: Property, context: Context) => Property; export declare const resolveReferences: (definition: FullDefinition, references: Reference[]) => { definition: Definition; schemaKey: any; oneOfs: Definition[]; }; export declare const resolveDefinition: (definition: FullDefinition, references: Reference[], oneOfChoice?: number) => { schemaKey: any; definition: Definition; }; export declare function findBestOneOf(oneOfs: JSONSchema7Definition[] | JSONSchema6Definition[] | undefined, references: Reference[], parent?: Definition): { schemaKey: any; definition: Definition; }; export declare function isSchemaDefinition(definition: FullDefinition): definition is Definition; export declare function resolveReferenceFromPath(referencePath: string, references: Reference[]): { schemaKey: any; definition: Definition; }; export declare function pickBestOneOf(oneOfs: Definition[]): Definition; export {};