/** * Authors an interoperability OPERATION — the set of changes a recipe asks of * one document — and hands back its bytes: what a native application's plugin * applies, in one transaction. * * WHY THIS EXISTS AND WHY IT LOOKS LIKE THIS. An operation is carried as a * .frag with no geometry at all: the envelope in `Model.metadata`, and one * geometry-less item per change whose attributes ARE the change. That was * cheap on the C# side, which already had a writer, and it is the reason a * converter had to be a console tool once: nothing in the browser could * produce one. So the format stayed, and this builds it here instead. * * Nothing above this class needs to know any of that. You say add / set / * remove and get the bytes of a recipe's result. * * WHAT IT DOES NOT DO. It does not translate. Attributes are written exactly * as given, in the TARGET application's own terms and units, because data * that gets translated on the way in has to be untranslated on the way out * and the day somebody forgets a field nothing complains. Deciding what a * Rhino layer means in Revit is the recipe's job; this only carries the * answer. * * DEPENDENCIES, loaded at build() time and declared as OPTIONAL PEERS: * `@thatopen/fragments` (the .frag schema) and `flatbuffers`. An app that * authors operations has both already; everything else in this package works * without them. */ /** The schema this writes. An applier that speaks a different one must refuse rather than guess. */ export declare const OP_SCHEMA = "revitflow/op@2"; export interface OperationTarget { /** Platform project id. */ project: string; /** Document name within the project — the model these edits are for. */ document: string; /** * The commit this was authored against. The elements named here existed * then; by the time somebody applies it they may not, and the applier * reports what it could not resolve. */ baseCommit: number; /** Who authored it, for the history. */ author?: string; /** Platform user id, so the same person is not two names depending on which tool wrote it. */ userId?: string; /** Groups the operations one authored action produced across several models. */ batchId?: string; title?: string; } /** Where an added item goes, and how it is turned, in the target's own terms. */ export interface Placement { /** * What it is placed IN: another change of this operation, by its `source` (a door's wall, made in the same * operation), or an element the target already has, by its id. The applier hosts it there. */ host?: string; /** [x, y, z] in the TARGET model's own units and axes. Not converted here. */ position?: [number, number, number]; /** Degrees about Z, in the target's convention. */ rotationDeg?: number; /** * The id of the object that caused this change, in the AUTHOR's own terms — * a Rhino guid, a row of a spreadsheet, whatever asked for it. Optional, and * only useful to whoever wrote it: pass it when you expect to come back and * find what you created. */ source?: string; } export declare class OperationBuilder { private readonly target; private readonly changes; constructor(target: OperationTarget); /** How many changes are queued. An operation with none is refused by `build`. */ get length(): number; get batchId(): string | undefined; get title(): string; get author(): string; get userId(): string | undefined; get baseCommit(): number; /** * Create something. There is no id yet: the attributes describe what it is, * the placement says where it goes, and the operation answers with the id * it got. */ add(attrs: Record, placement?: Placement): this; /** Write attributes onto an item that already exists, named by the id the target published. */ set(item: string, attrs: Record, placement?: Placement): this; /** Delete an item. Whatever the target cascades along with it is reported, not guessed at here. */ remove(item: string): this; /** * A label for what this operation mostly does. Derived, never read to * decide anything: one operation may add, set and remove at once and still * be atomic, so what each change does is written on the change. */ get summary(): 'add' | 'set' | 'remove' | 'mixed'; /** * The .frag bytes, zlib-deflated, ready to upload as the operation's * payload. * * `opId` is taken rather than generated so the caller can put the same id * in the queue entry it writes next ({@link Recipes} mints it before the * run); an id this class invented and did not return would have to be dug * back out of the bytes. */ build(opId: string): Promise; /** Placement rides in the attributes, in the same string form the target published. */ private pack; private requireId; /** * The buffer itself. * * Laid out exactly as the C# writer lays it out, because the add-in's * reader is the one that has to accept both: items first and the container * after, ids handed out by one monotonic counter, attributes as * `[name, value, type]` JSON triples, and a Meshes table that exists but is * empty. * * Empty rather than absent: the reader asks for it unconditionally, and a * model that draws nothing is still a model. Nothing here gets a sample — * an item with no triangles must not have one, because a sample's bounding * box would then have no size and the reader turns a box into a "dimension" * and rejects a falsy one. */ private flatbuffer; }