Skip to main content

Quik Framework :: Metadata

Supplies a metadata store used by decorators. The module exports the store implementation and related utilities.

Installation

npm install @quik/metadata

Usage

import { MetadataStore } from '@quik/metadata';

const metadata = MetadataStore.get<{ role?: string }>(context.metadata);
metadata.role = 'admin';

API Highlights

  • MetadataStore.register(metadata, base) initializes metadata and returns the stored object.
  • MetadataStore.get(metadata) retrieves metadata.
  • MetadataStore.all() returns the internal WeakMap.
  • MetadataStore.snapshot() returns a memoized snapshot array.

Notes on Decorators & Reflection

Metadata is stored per-decorator context and does not rely on runtime reflection of class members. Because of this, dynamically added properties or runtime mutation of class shapes will not be reflected in metadata unless the decorator was applied to those members at definition time.

Testing & Coverage

See the root instructions for details on running pnpm run test:coverage and accessing coverage artifacts.

API Reference

Generated API documentation is available in the metadata API section.