Quickstart
import { MetadataStore } from '@quik/metadata';
function MyDecorator(target: unknown, context: ClassDecoratorContext) {
const metadata = MetadataStore.get<{ role?: string }>(context.metadata);
metadata.role = 'admin';
}
Notes
- There is no top-level
set()method —MetadataStore.get(metadata)lazily creates and returns the stored object for a givenDecoratorMetadatakey, and callers mutate it directly. MetadataStore.register(metadata, base)initializes metadata with a specific base object the first time it's seen, and is a no-op on subsequent calls for the same key.- Metadata is keyed by the native decorator
context.metadataobject, not by string names — every class using this pattern gets its own isolated metadata record. @quik/metadatais a low-level building block; most application code will not import it directly and instead uses higher-level decorator APIs (e.g.@quik/entity,@quik/http) that are built on top of it.