UNPKG

forma-embedded-view-sdk

Version:

The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma Site Design (previously Spacemaker).

95 lines (94 loc) 3.17 kB
import type { IframeMessenger } from "./iframe-messenger.js"; export type HexColorString = `#${string}`; /** * A building function defines how a building (or part of a building) is used. */ export type BuildingFunction = { /** Unique identifier. Built-in IDs: "residential", "commercial", "unspecified". */ id: string; /** Display name. */ name: string; /** Hex color string, e.g. "#FFEAA5". */ color?: HexColorString; }; export type SettingsResponse = { buildingFunctions: BuildingFunction[]; }; /** * Manage project-level building functions. * * @remarks * Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.settings | settings}.buildingFunctions. */ export declare class BuildingFunctionsApi { #private; /** @hidden */ constructor(iframeMessenger: IframeMessenger); /** * Add a new building function to the project. * * @returns All building functions after the addition. * * @example * const { buildingFunctions } = await Forma.settings.buildingFunctions.add({ name: "Retail", color: "#FF5733" }) */ add(params: { /** Display name for the new building function. */ name: string; /** Optional hex color string, e.g. "#FF5733". */ color?: HexColorString; }): Promise<SettingsResponse>; /** * Update an existing project-level building function by ID. * Returns an error if the ID belongs to a built-in building function. * * @returns All building functions after the update. * * @example * const { buildingFunctions } = await Forma.settings.buildingFunctions.update({ id: "abc123", name: "Updated name" }) */ update(params: { /** ID of the building function to update. */ id: string; /** New display name. */ name: string; /** New hex color string, e.g. "#FF5733". */ color?: HexColorString; }): Promise<SettingsResponse>; /** * Delete a project-level building function by ID. * Returns an error if the ID belongs to a built-in building function. * * @returns All building functions after the deletion. * * @example * const { buildingFunctions } = await Forma.settings.buildingFunctions.delete({ id: "abc123" }) */ delete(params: { /** ID of the building function to delete. */ id: string; }): Promise<SettingsResponse>; } /** * Access and manage project-level settings. * * @remarks * Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.settings | settings}. */ export declare class SettingsApi { #private; /** Manage building functions for the project. */ readonly buildingFunctions: BuildingFunctionsApi; /** @hidden */ constructor(iframeMessenger: IframeMessenger); /** * Fetch all building functions for the project, including the three built-in * defaults (residential, commercial, unspecified). * * @returns All building functions for the project. * * @example * const { buildingFunctions } = await Forma.settings.get() */ get(): Promise<SettingsResponse>; }