# Hamelin Compiler

**NOTICE:** This package is not licensed for use. All rights are reserved. No permission is granted to use, copy, modify, merge, publish, distribute, sublicense, or sell copies of the Software.

## Preparing a catalog

`compileHamelinQuery`, `checkIncrementalEligibility`, `getCompletions` and `getOutputTimestampColumns`
accept either a `Catalog` or a `PreparedCatalog`. Preparing converts the catalog once, so repeated
calls against the same catalog skip that work.

```ts
import { compileHamelinQuery, prepareCatalog } from "@hamelin.sh/compiler"

using prepared = await prepareCatalog(catalog)
await compileHamelinQuery(prepared, query, null, defaultSpace)
```

A `PreparedCatalog` is a snapshot. It does not see later changes to the `Catalog` it came from, so
prepare a new one and free the old one when the catalog changes. `prepareCatalog` rejects a catalog
it cannot convert, even though `getCompletions` called with that same plain catalog quietly falls
back to syntax-only completions.

Disposal is synchronous, so `using` is enough. Keep the handle alive until every call that uses it
has settled: freeing it while a call is still pending makes that call reject. Where `using` is
unavailable, call `prepared.free()` when done. A handle that is never freed is reclaimed by a
`FinalizationRegistry`, but only when the garbage collector gets to it. Runtimes without
`Symbol.dispose` (older Safari) need a polyfill for `using`; `free()` works everywhere.
