# `Writer`

> Contract 2.0.0 · package sha256 `a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e` · generated from `configurator-runtime.d.ts` by `services/onsite-scripter/scripts/build-contract-docs.mjs`; edit the source, not this file.

Interface · `import type { Writer } from '@holostep-configurators/runtime-client/contract';` · stable · since 2.0.0 · section 5. Writers, transactions, session

The write surface [`Session`](Session.md) and [`Tx`](Tx.md) share. `C` is the commit options the writer accepts:
[`CommitOptions`](CommitOptions.md) for [`Session`](Session.md), [`NoCommitOptions`](NoCommitOptions.md) for [`Tx`](Tx.md). Handles obtained from a writer are
bound to it and carry the same `C`. Write helpers take a plain `Writer` (member options only), so
they work with both and never pass a commit option a `tx` would refuse. A bare [`Collection`](Collection.md) or
[`Part`](Part.md) is the same: member options only. Type a stored session handle you pass `origin` or
another commit option through as `Collection<CommitOptions>`, or let TypeScript infer it.
Every state write through a writer or its handles that fails inside the runtime before its
commit point rolls back and records 'sync-failed' once. An autocommit one undoes only its own
uncommitted effects, so a write that committed while it loaded keeps its state, and resolves
'rolled-back' with reason 'internal-error'; one through a `tx` rolls the transaction holding it
back to its opening state (spec section 6.4).

## Members

| Member | Kind | Summary |
| --- | --- | --- |
| <a id="node"></a>[`node`](Writer.node.md) | method | The root part of the ModelNode `nodeId`: pose it, hide it, follow it or bound it as a whole. |
| <a id="find"></a>[`find`](Writer.find.md) | method | A saved search over loaded models and collections. |
| <a id="collection"></a>[`collection`](Writer.collection.md) | method | The live collection with this name, bound to this writer; created when absent. |
| <a id="apply"></a>[`apply`](Writer.apply.md) | method | Replaces the look's [`apply()`](Writer.apply.md) block atomically (spec section 6.10, R2). |
| <a id="applypatch"></a>[`applyPatch`](Writer.applyPatch.md) | method | Applies RFC 6902 operations to [`SessionState`](SessionState.md) (recorded; merging; in the write queue). |
| <a id="setscenemodel"></a>[`setSceneModel`](Writer.setSceneModel.md) | method | Replaces the scene model (recorded; replacing; in the write queue). |
| <a id="select"></a>[`select`](Writer.select.md) | method | Selects `material` (a MaterialNode `nodeId`) in the global-material GroupNode `group` (its `nodeId`): recorded, priced and saved. |
| <a id="stage"></a>[`stage`](Writer.stage.md) | property | The stage: lights, environment, background and the colour pipeline. |
| <a id="materials"></a>[`materials`](Writer.materials.md) | property | Reusable materials and reads of stored MaterialNodes. |
| <a id="assembly"></a>[`assembly`](Writer.assembly.md) | property | Connectors and connections between placed models. |
| <a id="camera"></a>[`camera`](Writer.camera.md) | property | The camera: view, lens, limits, mode, rotation, and the projection reads. |
| <a id="animations"></a>[`animations`](Writer.animations.md) | property | Clips of loaded models. |
| <a id="labs"></a>[`labs`](Writer.labs.md) | property | Labs members: they serve one app or wrap an engine-shaped capability, and may change in a minor. |
| <a id="state"></a>[`state`](Writer.state.md) | method | Read class: intent. |
| <a id="getscenemodel"></a>[`getSceneModel`](Writer.getSceneModel.md) | method | Read class: intent. |

## Declaration

```ts
export interface Writer<C extends object = NoCommitOptions> {
  node(nodeId: string): Part<C>;
  find(query: Query): Parts<C>;
  collection(name: string, options?: CollectionOptions): Collection<C>;
  apply(scene: SceneSpec, options?: C & SignalOption): Promise<Report>;
  applyPatch(patch: readonly JsonPatchOp[], options?: RecordedOptions<C> & SignalOption): Promise<Report>;
  setSceneModel(model: DeepReadonly<SceneModel>, options?: RecordedOptions<C> & SceneModelOptions): Promise<Report>;
  select(group: string, material: string, options?: RecordedOptions<C> & SignalOption): Promise<Report>;
  readonly stage: Stage<C>;
  readonly materials: Materials<C>;
  readonly assembly: Assembly<C>;
  readonly camera: Camera<C>;
  readonly animations: Animations<C>;
  readonly labs: Labs<C>;
  state(): SessionState;
  getSceneModel(): DeepReadonly<SceneModel> | null;
}
```

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `Writer` names no product |
| 2. A precedent | not recorded: no ledger row (coverage.json) names this member or its owner |
| 3. Two apps, or labs | not recorded: no ledger row names this member or its owner |
| 4. The cheaper fix first | not recorded per member (Appendix B decides it per need) |
