@deployport/specular-runtime
Version:
Runtime for Specular API clients with support for Node.js and Browser
65 lines (64 loc) • 2.53 kB
TypeScript
import Content from "../runtime/content.js";
import Resource from "./resource.js";
import Struct, { StructPath } from "./struct.js";
import UserDefinedType from "./userDefinedType.js";
import { GenericProperties, Struct as RuntimeStruct } from "../runtime/struct.js";
export declare function normalizeMapEntry(key: string): string;
export declare const moduleSuperType = "application/spec";
export declare const mediaTypeSeparator = ".";
/**
* PackagePath contains the scope of the package
*/
export declare class PackagePath {
readonly namespace: string;
readonly name: string;
/**
* mediaTypeSubType returns the media type sub type for the package
* as in application/spec.<namespace>.<module>
*/
readonly mediaTypeSubType: string;
constructor(namespace: string, name: string);
toString(): string;
}
/**
* Package
*/
export default class Package {
readonly path: PackagePath;
private readonly resources;
private readonly types;
annotations: any[];
/**
* allPackages is a list of all packages including this and all imported
*/
private allPackages;
private structsByFQTN;
constructor(namespace: string, module: string);
importPackage(pkg: Package): void;
_addAnnotation<T>(annotation: T, config?: (annotation: T) => void): void;
/**
* Resource by name returns the resource with the given name
* or undefined if not found
* @param name name of the resource
* @returns
*/
resourceByName(name: string): Resource | null;
_addResource(resource: Resource): void;
typeByName(name: string): UserDefinedType | null;
requireTypeByName(name: string): UserDefinedType;
_addType(tp: UserDefinedType): void;
/**
* Returns the Struct with the given FQTN, otherwise throws an error @TypeNotFoundError
* @param fqtn
* @returns
*/
structByFQTN(structPath: StructPath): Struct;
buildByFQTN(structPath: StructPath, content: Content): RuntimeStruct;
requireBuildFromJSON(structPath: StructPath, structJSON: Record<string, any> | object | any): RuntimeStruct;
requireBuildByFQTN(structPath: StructPath, content: Content): RuntimeStruct;
requireBuildArrayNullableItems(structPath: StructPath, contentArray: (Content | null)[]): (GenericProperties | null)[];
requireBuildArrayNonNullableItems(structPath: StructPath, contentArray: (Content | null)[]): GenericProperties[];
}
export declare class TypeNotFoundError extends Error {
constructor(typeName: string);
}