@altostra/core
Version:
Core library for shared types and logic
68 lines (67 loc) • 2.55 kB
TypeScript
import type { Dict, ResourceId } from "../Common";
import type { ParametersDict } from "../Parameters";
import type { Point } from "../Point";
import type { RawResourceId } from "../Resources";
import { globalEnvironmentVariablesKey } from "./common";
import type { Connection } from "./Connection";
import type { Resource } from "./Resource";
import type { SourceCodeLocation } from "./SourceCodeLocation";
export type { ResourceId };
export declare const SUPPORTED_VERSION = "2019-10-24";
export interface Blueprint extends BlueprintData, BlueprintBrand {
}
/**
* An Altostra blueprint (designer) data without its identifying fields.
*/
export interface BlueprintTemplate {
readonly version: typeof SUPPORTED_VERSION;
description?: string;
sourceCode?: SourceCodeLocation;
resources: Dict<Resource, RawResourceId>;
connections: Dict<Dict<Connection, RawResourceId>, RawResourceId>;
metadata?: BlueprintMetadata;
parameters?: ParametersDict;
[globalEnvironmentVariablesKey]?: Record<string, string>;
}
/**
* An Altostra blueprint (designer) data and identification.
*/
export interface BlueprintData extends BlueprintTemplate {
id: string;
name: string;
/**
* Specifies if the blueprint contains custom (and yet to be supported by Altostra resources)
* This flag is controlled by the `BlueprintHelper`
*/
readonly unsafe?: boolean;
}
export interface BlueprintMetadata {
designer?: DesignerMetadata;
}
/**
* An object that defines the design of a drawing with layout, scaling, and offset.
*/
export interface DesignerMetadata {
resourcePositions: Dict<Point, string>;
zoomLevel?: number;
panOffset?: Point;
}
export interface BlueprintBrand {
readonly Blueprint: unique symbol;
}
/**
* Smart Constructor for Blueprint
*/
export declare function mkBlueprint(bp: BlueprintData): Blueprint;
export declare function mkBlueprint(id: string, name: string, template: BlueprintTemplate): Blueprint;
export declare const isBlueprintTemplate: import("@altostra/type-validations").ObjectOfTypeValidation<BlueprintTemplate>;
/**
* A blueprint type validation.
*/
export declare const isBlueprint: import("@altostra/type-validations").ObjectOfTypeValidation<Blueprint>;
/**
* Validates the blueprint and throws an error if the blueprint is invalid.
* @param bp A blueprint to validate.
*/
export declare function validateBlueprintTemplate(bp: unknown): asserts bp is BlueprintTemplate;
export declare function validateBlueprint(bp: unknown): asserts bp is Blueprint;