# SaC Facade API

SaC help does not duplicate the full Facade API reference. Univerfile sidecars include local generated `types/*.d.ts` files under the resolved hidden sidecar; use them as the authoring reference for method names, overloads, enum names, and data shapes.

## Local Types

A migration `apply` function receives the initialized Facade API for the target runtime session:

```typescript
apply({ univerAPI }) {
  const localUnitId = "replace-with-discovered-sheet-localUnitId";
  const workbook = univerAPI.getWorkbook(localUnitId);
  const sheet = workbook.getSheetByName("Summary") ?? workbook.create("Summary", 1000, 26);
  sheet.getRange("A1").setValue("ready");
}
```

- `univerAPI` is the target-bound runtime Facade root. Use explicit unit lookups such as `getWorkbook(localUnitId)` after discovering the sheet unit inside the target `.univer` container; do not depend on an active workbook or a default workbook id.
- The runtime session is already bound to the target univerfile, so `apply` does not receive `{ univerfile }`, `{ workbook }`, `{ sheet }`, or another target selector. The first context shape is `{ univerAPI }`.
- SaC helper declarations define only the wrapper shape. Unit lifecycle APIs such as `getUnitById`, `createUnit`, or `deleteUnit` belong to the generated Univer/runtime Facade types when they exist there.

```bash
rg "class FRange|setFormula|setValues" .Budget.univer.sac/types
rg "interface ICellData|enum BorderType" .Budget.univer.sac/types
rg "createDocument|class FDocument|IDocumentData|IDocumentBody" .Budget.univer.sac/types
pnpm exec tsc -p tsconfig.json --pretty false
```

Use only APIs present in local sidecar `types/*.d.ts`. Do not guess Facade method names, and do not hand-write local ambient declarations or shim files for Facade, unit lifecycle APIs, or `univer:sac/*` helpers.

If a public Facade API or type is missing from the generated assets, treat it as a CLI type asset gap instead of patching the SaC project with private declarations.
