import { JSONSchema7 } from 'json-schema'; /** Primitive types and the "object" type */ type BasicTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "null" | "Object"; /** Object types that are commonly thought of as basic language constructs themselves (also, "unknown" where not implemented yet) */ type CommonTypes = "Function" | "Array" | "unknown"; interface PrimType { /** Type as given in JavaScript, including common objects */ type: BasicTypes | CommonTypes; /** Typed data given from TypeScript formatted as JSON Schema */ typed?: JSONSchema7; } interface PrimComment { comment: string; } interface PrimMethod { name: string; path: string; signatures: PrimMethodSignature[]; props?: { [prop: string]: PrimType; }; } interface PrimParam extends PrimType, PrimComment { name: string; } interface PrimReturn extends PrimType, PrimComment { } interface PrimThrow extends PrimComment { } interface PrimMethodSignature extends PrimComment { params: PrimParam[]; returns: PrimReturn; throws: PrimThrow; flags: { [flag: string]: boolean; }; } interface PrimModule extends PrimComment { name: string; path: string; flags: { [flag: string]: boolean; }; } type PrimRootStructureKeys = keyof Omit; interface PrimModuleStructure { docs: [key: PrimRootStructureKeys, index: number]; props?: { [moduleOrMethodName: string]: PrimModuleStructure; }; } interface PrimRpcDocs extends PrimModuleStructure { methods: PrimMethod[]; modules: PrimModule[]; } /** * Create documentation for a module used with Prim, as JSON. Used as input * for Prim Docs UI to create a documentation page. A simpler version of TypeDoc * intended only for documenting RPC calls. * * @param given - Output of TypeDoc documentation for module used with Prim * @returns Prim-specific documentation for RPC calls */ declare function createDocsForModule(given: unknown): PrimRpcDocs; /** * Simple convenience function to get documentation for reference inside of Prim RPC Docs structure (`.props`) * * @param docs RPc documentation * @param given Property found in documentation structure * @returns Documentation for requested module or method */ declare function findDocsReference(docs: Partial, given?: PrimModuleStructure | PrimModuleStructure["docs"]): PrimMethod | PrimModule; /** * Given a module of Prim RPC documentation, find related modules/methods in the module * * @param rootDocs - RPC documentation (root includes methods and modules properties) * @param lookFor - Whether to look for "modules" or "methods" * @param submodule - A structure inside of RPC docs (when not provided, default to documentation root) * @param includeNested - By default, only direct properties will be found. Toggle this to include nested properties * @returns A list of modules/methods for given level of documentation */ declare function iterateDocs(rootDocs: PrimModuleStructure, lookFor: T, submodule?: Partial, includeNested?: boolean): U[]; /** * Given a method's documentation, find the actual method in the documented module. * * @param docs Prim RPC docs for module * @param module Module that documentation references * @param methodDocs The method's documentation within Prim RPC docs * @returns The method requested in your module */ declare function getFunctionForDocumentation unknown = (...args: unknown[]) => unknown>(docs: PrimRpcDocs, module: unknown, methodDocs: PrimMethod | PrimModuleStructure | PrimModuleStructure["docs"]): Given; declare const helpers: { findDocsReference: typeof findDocsReference; getFunctionForDocumentation: typeof getFunctionForDocumentation; iterateDocs: typeof iterateDocs; }; export { type PrimRpcDocs, createDocsForModule, helpers };