UNPKG

forma-embedded-view-sdk

Version:

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

102 lines (100 loc) 3.37 kB
import type { IframeMessenger } from "./iframe-messenger.js"; /** * Library item status * * @remarks * Used to indicate the state of the element the item points to. * Ie. ordering and processing the data necessary to create the element takes some time, so you create the library item first with status `pending`, then once the element is completed, you update the item with the urn of the element and status `success`. */ export type Status = "success" | "failed" | "pending"; /** Data which defines the content of a library item */ export type LibraryItemData = { /** Name for the item */ name: string; /** Current status */ status: Status; /** URN for the element referenced by the item */ urn?: string; }; /** Record of an item in the library service */ export type LibraryItem = LibraryItemData & { /** Access scope of the item */ authContext: string; /** Unique ID within the library service */ id: string; /** ISO timestamp for the latest update performed on the item */ updatedAt: number; }; /** * Manage items in the user's * [Library](https://help.autodeskforma.com/en/articles/6976465-library-and-importing-files) * of available data. * * @remarks * Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.library | library}. */ export declare class LibraryApi { #private; /** @hidden */ constructor(iframeMessenger: IframeMessenger); /** * Add data to Library as a new item. * * Requires edit access. See {@link EmbeddedViewSdk.getCanEdit | getCanEdit} for more info. * * @returns The newly created item. * * @example * const urn = mockRegisterElementInSystem() // See e.g. integrate-elements module * const item = await Forma.library.createItem({ * data: { name: "My new item", status: "success", urn: urn } * }) */ createItem(request: { /** * Authcontext to use with the request. * * As of now, the currently open project id is both default * and only allowed value. */ authcontext?: string | undefined; /** Content of the item to create. */ data: LibraryItemData; }): Promise<LibraryItem>; /** * Update an existing library item. * * Requires edit access. See {@link EmbeddedViewSdk.getCanEdit | getCanEdit} for more info. * * @returns The updated item. */ updateItem(request: { /** * Authcontext to use with the request. * * As of now, the currently open project id is both default * and only allowed value. */ authcontext?: string | undefined; /** ID of the item to update. */ id: string; /** Updated content for the relevant item. */ data: LibraryItemData; }): Promise<LibraryItem>; /** * Delete an existing library item. * * Requires edit access. See {@link EmbeddedViewSdk.getCanEdit | getCanEdit} for more info. */ deleteItem(request: { /** * Authcontext to use with the request. * * As of now, the currently open project id is both default * and only allowed value. */ authcontext?: string | undefined; /** ID of the item to delete. */ id: string; }): Promise<void>; }