import { EngineServicesClient } from './client'; import { DocumentDescriptor, DocumentView } from './documents'; /** One element mutation inside a version. Wire-compatible with the plugins. */ export interface FlowChange { /** create | update | delete. */ type: 'create' | 'update' | 'delete' | string; /** The native application's own id for the element (Revit UniqueId, AutoCAD handle). */ uniqueId: string; } /** Per-version change tallies. */ export interface FlowCounts { added: number; modified: number; removed: number; } /** * One sync of a document. Field names are the wire format the plugins write * (`revitflow_history.json`); do not rename them. */ export interface FlowVersion { /** Identity, minted by the writer. */ guid: string; /** The versions this one was built on; absent on a root. First entry is the continued line. */ parents?: string[] | null; /** The CDE's storage version number, when there is one. Data, never identity. */ version?: number; /** What the author said it was for, when they said anything. */ message?: string; author: string; /** Which application wrote it: 'revit', 'autocad', 'rhino'… */ source: string; /** ISO UTC. */ timestamp: string; changes: FlowChange[]; counts: FlowCounts; /** Hidden-file id of the delta .frag; absent on the baseline and geometry-less versions. */ deltaId?: string; /** Hidden-file id of the same delta as a STREAMED bundle (TOSTRM1, `format: 'tostrm'`): what the viewer opens, * streaming being the default (21-10). Absent where `deltaId` is, and on versions written before it existed. */ streamId?: string; /** Hidden-file id of the per-element geometry fingerprints, when the writer keeps them. */ geomId?: string; /** Platform user id of the committer, when the writer knew it. */ userId?: string; /** This version re-exported the whole model (the visible .frag shows it as of here). */ full?: boolean; compact?: boolean; /** * What kind of step it was, when it was not a plain sync of a native application: 'upload' is a * file brought to the platform (the first step of every document made from a file, Antonio 18-10: * «el histórico siempre explícito: al subir un archivo y crear un documento, se crea el histórico * con un primer paso que es subir el documento a la plataforma»); 'recipe' is a sync whose * changes include a recipe applied in the native application ({@link origin} says which). * Absent: a sync. */ kind?: 'upload' | 'sync' | 'recipe' | 'restore' | string; /** On a 'restore' (Revit's That Open > History > Restore this version): the version it went back to. */ restoredFrom?: { guid: string; version: number; }; /** The file the step brought, on an upload: its id, name and the storage version it landed in. */ file?: FlowFile; /** Where the step came from, when a recipe made it: see {@link FlowOrigin}. */ origin?: FlowOrigin; /** Every recipe applied since the previous step, when more than one was (the first is `origin`). */ origins?: FlowOrigin[]; /** Position in the timeline, derived from the parent graph when read. Never stored. */ ordinal?: number; } /** A file a version brought to the platform. */ export interface FlowFile { fileId: string; name: string; /** Lowercase format: 'ifc', 'rvt', 'pdf'… */ format?: string; /** The storage version it landed in, when known. */ versionTag?: string; } /** * Where a version came from when a recipe made it: the recipe applied and the exact source it * read, so the history says which IFC, at which version, the changes were built from. Agreed with * the platform, 18-10. */ export interface FlowOrigin { /** The recipe's name. */ recipe: string; /** The version of a project's own recipe that made it ('v3'); absent for a built-in. */ recipeVersion?: string; source: { /** The source document's folder. */ folderId: string; fileId: string; /** The source file's name, as it was then. */ name?: string; /** The file's storage version the recipe read. */ version: string; }; /** What it wrote, in a line: «IFC to Revit: 12 wall(s), 3 floor(s)». */ title?: string; /** The settings it ran with, as the person chose them. */ settings?: Record; /** The recipe's name for people ("IFC to Revit"). */ recipeTitle?: string; } /** A connected document, as listed from the project. */ export interface FlowDocInfo { /** The native application that owns it: 'revit', 'autocad'… */ source: string; /** The document's own id within that application. */ docId: string; /** * The document folder's item id — the id the CDE and the documents API * ({@link EngineServicesClient.documents}) know this document by. */ folderId: string; /** The visible model file's name, when one exists yet. */ modelName?: string; /** * True when the folder exists but holds neither history nor model — a * document somebody connected and never synced (a * plugin mid-first-publish, or an abandoned start). A legitimate state, * listed rather than hidden; apps decide whether to show it dimmed. */ empty?: boolean; } /** * One person's current hold on a document's elements, read from the lock * registry the native plugins arbitrate through. Element keys are the native * application's own ids (Revit UniqueIds). Workset-level ownership lives in * Revit's own binary worksharing files (the ownership mirror) and is not * readable here — what IS here is every element-level claim. */ export interface FlowOwner { /** The native application's user name, as the plugin claimed with. */ owner: string; /** The element keys this person currently holds, arbitration applied. */ elements: string[]; } /** * The ordered recipe {@link FlowDoc.modelParts} answers: a baseline plus the * steps that bring it to the asked version. See that method for the * composition rule. */ export interface FlowModelParts { baseline: { /** The visible model file. */ fileId: string; /** The version whose full export it is. */ guid: string; /** * True when the visible file's CURRENT content is this baseline. False * when a later publish rewrote it — then download the file at * `storageVersion` (when recorded) instead of its head. */ current: boolean; /** The CDE storage version the baseline landed in, when the history recorded it. */ storageVersion?: number; }; /** One per version after the baseline, oldest first. */ steps: { guid: string; /** Hidden-file id of the delta .frag; absent on geometry-less versions. */ deltaId?: string; /** Hidden-file id of its streamed bundle (see {@link FlowVersion.streamId}). */ streamId?: string; /** Elements this version removed, by the native app's own stable ids. */ removedUniqueIds: string[]; }[]; /** The version the recipe reaches (the asked one, or the head). */ at: string; } /** What `sync` needs: the change list plus whatever the writer knows. */ export interface SyncInput { author: string; /** When it happened, ISO UTC, when not now (a tutorial's «Ana, yesterday»). */ timestamp?: string; /** Which application/tool is writing: 'revit', 'rhino', 'recipe'… */ source: string; changes: FlowChange[]; message?: string; /** Delta geometry for this version, uploaded as a hidden file. */ delta?: Blob; /** Re-upload of the whole model; marks the version `full`. */ model?: Blob; /** Platform user id, when known. */ userId?: string; /** What kind of step it is, when not a plain sync ('upload', 'recipe'). */ kind?: FlowVersion['kind']; /** The file an upload brought. */ file?: FlowFile; /** Where it came from, when a recipe made it. */ origin?: FlowOrigin; origins?: FlowOrigin[]; /** * The head you built on. When given and the stored head differs, `sync` * refuses with {@link StaleHistoryError} instead of forking silently. */ expectedLatestGuid?: string; } /** The head moved while a writer prepared its version. Re-read and retry. */ export declare class StaleHistoryError extends Error { readonly expectedGuid: string; readonly actualGuid: string | undefined; constructor(expectedGuid: string, actualGuid: string | undefined); } /** * The history of one project. Get it from {@link EngineServicesClient.history}. */ export declare class ProjectHistory { #private; private readonly client; readonly projectId: string; constructor(client: EngineServicesClient, projectId: string); /** The project's connected documents. */ docs(): Promise; /** * One document's history. `source` and `docId` as {@link docs} lists them. * The same object for the same document, so what it has found once (its * folder) it does not ask for again. */ doc(source: string, docId: string): FlowDoc; /** * The history of a document of the platform's own (a folder with its `document.json`, made from * an uploaded file), kept in the document's folder itself. Its source is 'platform' and its id * the folder's. */ document(folderId: string): FlowDoc; /** * @internal The documents' folders (the root's children), listed ONCE and * shared by every document. Each document listing them for itself was ~150 * requests on one Coordinator load with ~30 documents, and the platform * answers 429 past 100 a minute: the app then showed no Revit document and * a queued request never arrived (13-10). Listed again after 30 s, when a * folder is made, or when asked `fresh`. */ childFolders(rootId: string, fresh?: boolean): Promise; /** @internal A folder was made: the next {@link childFolders} lists again. */ forgetFolders(): void; /** @internal The `bimterop` folder id, resolved once. */ rootFolderId(create?: boolean): Promise; } /** * One connected document: its timeline and its model. */ export declare class FlowDoc { #private; private readonly client; private readonly project; readonly source: string; readonly docId: string; constructor(client: EngineServicesClient, project: ProjectHistory, source: string, docId: string, /** The folder, when it is known and not found by name under `bimterop` (a platform document). */ folderId?: string); /** * The document's versions, oldest first, ordered by the parent graph (not * by array position, which concurrent writers do not keep meaningful). * Each version gets its `ordinal` filled in. */ timeline(): Promise; /** The head of the timeline, or null before the first sync. */ latest(): Promise; /** * A version's delta geometry as a .frag. The baseline (`full`) versions have * no delta: their geometry IS the model file — use {@link model}. */ delta(version: FlowVersion): Promise; /** * The visible model .frag AS LAST FULLY EXPORTED — the first commit, or the * last explicit publish. Ordinary syncs only add hidden deltas, so this is * NOT necessarily the head: anything computed on it (a clash run) is as of * the last `full: true` version. For the model at a specific version, read * {@link modelParts} and compose. */ model(): Promise; /** * The ordered recipe for the model AT a version: the baseline full export * at-or-before it, then one step per later version up to it — each step's * delta .frag (absent on geometry-less versions) and the element uniqueIds * it removed. The consumer composes with its geometry engine: load the * baseline, then per step replace elements by uniqueId from the delta and * drop the removed. Composing is NOT done here: writing a merged .frag * takes the fragments engine, which this package deliberately does not * carry. * * UniqueIds are the native application's own stable element ids (a Revit * UniqueId survives syncs, machines and full exports), which is what makes * replace-by-uniqueId the whole composition rule. * * When the baseline is NEWER than the asked version (somebody published * after it), the visible file no longer shows that moment: `baseline` * then carries the older version's `storageVersion` when the history * recorded one, so the consumer can download that stored file version * instead of the current one. */ modelParts(options?: { at?: string; }): Promise; /** The document folder's item id — the id the CDE knows this document by. */ folderId(): Promise; /** * The document descriptor (`document.json`), or null when the folder does * not carry one yet — an old folder from before descriptors existed. */ descriptor(): Promise; /** * The first view whose format appears in `formats`, searched in the order * of the list (the caller's preference wins). Falls back to the visible * model .frag on a descriptor-less folder, so old documents keep viewing. */ view(formats: string[]): Promise; /** * Registers a renderable representation, creating the descriptor when the * folder predates them (named after the model file, or the folder itself). * One view per format: a same-format view is replaced, not accumulated. */ addView(view: DocumentView): Promise; /** * Makes sure the folder carries a descriptor, WRITING one when it predates * them: the visible model .frag becomes the 'frag' view. The explicit form * of what {@link addView} does implicitly — reads like `descriptor()` never * write, so migrating an old folder is this deliberate call. Returns the * descriptor either way, or null when there is nothing to describe yet (no * model file). */ ensureDescriptor(): Promise; /** * Who currently holds which elements, read from the lock registry the * native plugins arbitrate through. Read-only: claiming and releasing stay * with the plugins. Empty when nobody holds anything (or the document has * no lock anchor yet). Arbitration is applied: a key contested by two * claims counts only for the earliest one, matching the plugins' rule. */ ownership(): Promise; /** * Appends one version: uploads the geometry it carries, then the updated * history. Give `expectedLatestGuid` whenever you built on a head you read, * so a concurrent writer surfaces as {@link StaleHistoryError} instead of a * silent fork. */ sync(input: SyncInput): Promise; } /** * Orders versions by walking the parent graph from the root along first * parents, breaking forks by timestamp — array position is not meaningful * once more than one application writes. Fills `ordinal`. */ export declare function orderByGraph(versions: FlowVersion[]): FlowVersion[]; /** A random v4 guid, for version guids and recipe run ids. */ export declare function mintGuid(): string;