Skip to content

TypeScript API / @contentia/vite-plugin / ContentiaTypegen

Class: ContentiaTypegen ​

Stateful typegen engine. Holds the per-item declaration blocks in memory and (re)writes the aggregate .contentia/vite-generated/types.d.ts plus per-collection union aliases. Safe to use one-shot (build / cold dev, no channel) or incrementally (dev, driven by a ContentChangeChannel).

Constructors ​

Constructor ​

ts
new ContentiaTypegen(options): ContentiaTypegen;

Parameters ​

ParameterType
optionsContentiaTypegenOptions

Returns ​

ContentiaTypegen

Methods ​

dispose() ​

ts
dispose(): Promise<void>;

Stop listening to the channel and write any pending changes.

Returns ​

Promise<void>


flush() ​

ts
flush(): Promise<void>;

Force an immediate write of all outputs.

Returns ​

Promise<void>


ingest() ​

ts
ingest(
   id, 
   content, 
   meta
): Promise<void>;

Ingest one item's concrete { content, meta } (e.g. from a Vite load hook). Computes its declaration block and schedules a debounced write.

Parameters ​

ParameterType
idstring | ContentiaId
contentRecord<string, unknown>
metaRecord<string, unknown>

Returns ​

Promise<void>


regenerateAll() ​

ts
regenerateAll(repos?): Promise<void>;

Full rebuild: enumerate every item in every namespace via the reader and regenerate all blocks, then flush synchronously. Works with no channel (build + cold dev).

Parameters ​

ParameterType
repos?ContentiaRepositories

Returns ​

Promise<void>


regenerateItem() ​

ts
regenerateItem(id, repos?): Promise<void>;

Read one item via the reader and ingest it.

Parameters ​

ParameterType
idstring | ContentiaId
repos?ContentiaRepositories

Returns ​

Promise<void>


remove() ​

ts
remove(id): Promise<void>;

Drop an item's types and schedule a write.

Parameters ​

ParameterType
idstring | ContentiaId

Returns ​

Promise<void>