import { EngineServicesClient } from './client'; /** One renderable representation of a document. */ export interface DocumentView { /** The view file's item id — ids survive renames, names do not. */ fileId: string; /** Lowercase format name: 'frag', 'ifc', 'potree', 'pdf', 'tostrm'… */ format: string; /** * A view stored as a HIDDEN file of `fileId`'s item, read by pieces with * `getHiddenFileSignedUrl`: a streamed model's TOSTRM1 bundle hangs from * its .frag (`format: 'tostrm'`). */ hiddenId?: string; /** * The version of `fileId` the view was made from. A view whose versionTag * is not the file's current one is stale: open another view, or remake it. */ versionTag?: string; } /** * What a document IS, for a person: the first thing every documents menu * shows, and what it filters by — each app lists only the types it works * with (Antonio, 21-10: «que pueda ser cualquier cosa es confuso»). The * format stays a property of the document's files; it is not its type. */ export type DocumentType = 'bim' | 'drawings' | 'reality' | 'coordination' | 'generic'; /** Every document type, with the words and the icon every app shows for it. */ export declare const DOCUMENT_TYPES: Record; /** A document's type: the one written in it, else the one its formats say. */ export declare function documentTypeOf(descriptor: Pick): DocumentType; /** The wire shape of `document.json`, schema `thatopen/document@1`. */ export interface DocumentDescriptor { schema: typeof DOCUMENT_SCHEMA; /** The document's own name — what a row shows. Not any file's name. */ name: string; /** * What the document is ({@link DocumentType}). Written by whoever makes the * document; one without it is read by {@link documentTypeOf}. */ type?: DocumentType; /** * The native form, when the document has one (a .rvt, a .3dm). A document * born on the platform (a loose .frag) may not. */ native?: { fileId: string; format: string; }; /** The renderable representations, in no particular order. */ views: DocumentView[]; /** The document this one is made from, when it is made from another (a drawing set's PDF). */ source?: { folderId: string; }; } export declare const DOCUMENT_SCHEMA = "thatopen/document@1"; export declare const DOCUMENT_FILE = "document.json"; /** * Formats whose native file IS its own definitive view (the PDF rule): when * {@link ProjectDocuments.fromFile} converts one, the same fileId is written * as `native` and as `views[0]`. Deliberately NOT here: 'ifc' — its proper 3D * view is the processed frag, so a converted IFC without one shows "Process" * instead of opening a worse view. */ export declare const SELF_VIEWING_FORMATS: string[]; /** One listed document: the folder, and what its descriptor says. */ export interface DocumentInfo { /** The document folder's item id — the id interfaces know the document by. */ folderId: string; descriptor: DocumentDescriptor; } /** * Which version a listed file is at, as its listing says: what tells a kept read from a stale one. Its newest * version's tag (the item's `updatedAt` does not move when a version is added, measured on DEV, 23-10). */ export declare const stampOf: (item: unknown) => string | undefined; export declare class ProjectDocuments { #private; private readonly client; readonly projectId: string; constructor(client: EngineServicesClient, projectId: string); /** * Every document of the project: the folders that carry a descriptor. * Plain folders and loose files simply do not appear. `types` keeps only * the documents of those types ({@link documentTypeOf}): what an app's * documents menu asks for. One folder listing * for the project plus one file listing and one descriptor download per * folder, fetched in parallel — the storage offers nothing cheaper yet. */ list(options?: { types?: DocumentType[]; }): Promise; /** * Converts a loose file into a document: creates the document folder next * to the file, moves the file inside (moving preserves its id), and writes * the descriptor with the file as `native` — and as `views[0]` too when its * format views itself ({@link SELF_VIEWING_FORMATS}; override per call with * `selfView`). * * A file that carries a processed derivative (the old `derivedFileId` link * in its version metadata — an IFC's frag, a LAS's potree) brings it along: * the derivative moves into the same folder and becomes a view, so the * document is born ready to visualize and the link concept retires. */ fromFile(fileId: string, options?: { name?: string; selfView?: boolean; author?: string; /** What the document is; read from its formats when not said. */ type?: DocumentType; }): Promise; /** * Writes the step «uploaded to the platform» in a document's history: the first step of a * document made from a file ({@link fromFile} does it), and the step of each new version of the * file uploaded later. `author` is who uploaded it (a name, or the platform user id). */ recordUpload(folderId: string, file: { fileId: string; name: string; format?: string; versionTag?: string; }, author: string): Promise; /** * The document's descriptor, read and validated, or null when the folder * has none yet (an old folder, or a plain folder that is not a document). */ descriptor(folderId: string): Promise; /** * The first view whose format appears in `formats` — searched in the ORDER * OF THE LIST, so the caller's preference wins (ask `['frag', 'ifc']` and a * document carrying both answers the frag). Null when none matches: that is * where an interface offers "Process". */ view(folderId: string, formats: string[]): Promise; /** * Registers a renderable representation — a processor's last act. One view * per format: an existing view of the same format is replaced (a re-run * processor updates, it does not accumulate). The descriptor must exist; * create it first with {@link setDescriptor}. */ addView(folderId: string, view: DocumentView): Promise; /** Says what a document is: writes its {@link DocumentType}. */ setType(folderId: string, type: DocumentType): Promise; /** Writes the descriptor, creating or replacing `document.json`. */ setDescriptor(folderId: string, descriptor: Omit & Partial>): Promise; /** * The document's DRAFTS: each user's working copy, kept so that closing the * browser never loses work. A draft is not a version — it never enters the * history and never shows in the CDE. See {@link DocumentDrafts}. */ drafts(folderId: string): DocumentDrafts; } /** One user's draft of a document, as listed — no download involved. */ export interface DraftInfo { userId: string; /** When the server stored it: read from the hidden file's own id, not a client clock. */ savedAt: Date; } /** One user's draft, downloaded. */ export interface Draft> extends DraftInfo { blob: Blob; /** Whatever the app put next to the bytes: base version, app, app version… */ meta: Meta; } /** * A document's drafts: one working copy per user, stored as a HIDDEN file under * the document's `document.json`. Hidden files are what make this possible — * a visible file cannot be overwritten without becoming a new version, and a * draft written every few seconds must not fill the history or the CDE. * * Hidden files cannot be edited, so `put` uploads the new draft FIRST and then * deletes that user's previous ones: a failure in between leaves two, and * reads take the newest, never none. Every project member can read every draft; * each app decides whose to offer. */ export declare class DocumentDrafts { #private; private readonly client; private readonly holder; constructor(client: EngineServicesClient, holder: () => Promise<{ id: string; } | undefined>); /** Every user's latest draft, without downloading any. Newest first. */ list(): Promise; /** * One user's draft, downloaded — or, without `userId`, the newest of anyone. * Null when there is none. */ get>(options?: { userId?: string; }): Promise | null>; /** * Stores this user's draft, replacing their previous one: only the latest is * kept. Needs the document to have a descriptor (convert loose files first * with `fromFile`). */ put(blob: Blob, options: { userId: string; meta?: Record; }): Promise; /** Deletes every draft of this user (on an explicit save, typically). */ delete(options: { userId: string; }): Promise; }