
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
manifest-pattern
Advanced tools
A simple pattern to help build type-safe dynamic user interfaces or applications without having specific code littered throughout your codebase.
manifest-patternThe Manifest Pattern helps engineers build type-safe dynamic user interfaces and applications without having implementation-specific code littered throughout your codebase. The Manifest Pattern encourages implementation code to be co-located to improve development experience and confidence when implementing new functionality. Your builds will fail unless new functionality is fully implemented.
The Manifest Pattern pairs well with a discriminated union, and can be used to build dynamic forms, dashboard widget systems, complex logic builders, and more.
This repository contains tool(s) to help get you started using the manifest pattern, but they are entirely optional. The package has no dependencies.
You can read more about the Manifest Pattern on my blog.
npm install manifest-pattern
Manifests are built around a union type, much like a discriminated union. Your Manifest interface can encapsulate all the functionality your application needs, including defining values, functions, and UI components for each unique implementation.
You can extend your Manifest interface over time and implement the changes across every Manifest-implementation to ensure your application will function correctly, and your build is successful.
import type { Manifest } from 'manifest-pattern';
type ValueType = 'number' | 'string';
interface ValueTypeManifest<T extends ValueType = ValueType> extends Manifest<T> {
listName: string; // Specific to an application
shouldAllowSelection(): boolean; // Specific to an application
isValid(val: unknown): boolean; // Specific to an application
viewComponent: React.ComponentType<ViewComponentProps> | null; // Specific to an application
}
Create classes or objects that implement your Manifest type for each of the union values.
const numberManifest: ValueTypeManifest<'number'> = {
type: 'number',
listName: 'Number',
shouldAllowSelection: () => true,
isValid: x => typeof x === 'number',
viewComponent: null
};
const stringManifest: ValueTypeManifest<'string'> = {
type: 'string',
listName: 'String',
shouldAllowSelection: () => true,
isValid: x => typeof x === 'string',
viewComponent: null
};
Create a registry and add the instances, or use the helper provided.
import { ManifestRegistry, createManifestRegistry } from 'manifest-pattern';
// Option 1: Add-when needed/ready
const valueTypeManifestRegistry = new ManifestRegistry<ValueTypeManifest>()
.addManifest(numberManifest)
.addManifest(stringManifest);
// Option 2: Add-all upfront
const valueTypeManifestRegistry = createManifestRegistry<ValueTypeManifest>({
number: numberManifest,
string: stringManifest
});
You'll need a way to get access to the registry throughout your codebase, such as an in-memory cache, context, or file import.
getManifestsGet all Manifest instances added to the registry. Useful when allowing users to select an option from a list, rendering dynamic content, and more.
type SelectOption = {
id: ValueType;
label: string;
};
const selectOptions = valueTypeManifestRegistry
.getManifests()
.filter(m => m.shouldAllowSelection())
.map(
(m): SelectOption => ({
id: m.type,
label: m.listName
})
);
getManifestOrNullGet a specific instance of a manifest by type, or return null. This method is the most-used and allows code to remain ignorant of specific implementation details.
Dynamic React Component Rendering Example:
const ViewComponent = valueTypeManifestRegistry.getManifestOrNull('number')?.viewComponent ?? null;
if (ViewComponent === null) {
return <div>Something went wrong.</div>;
}
return <ViewComponent />;
Dynamic Function Usage Example:
const formValidator = (formValues): string | null => {
const manifest = valueTypeManifestRegistry.getManifestOrNull(formValues.selectedValueType);
if (manifest === null) {
return 'Invalid Value Type Selected';
}
return !manifest.isValid(formValues.value) ? 'Value Entered is Invalid' : null;
};
getManifestOrThrowSimilar to the above but instead throws an Error when a manifest is not found for the type given.
const formValidator = (formValues): string | null => {
try {
const manifest = valueTypeManifestRegistry.getManifestOrNull(formValues.selectedValueType);
return !manifest.isValid(formValues.value) ? 'Value Entered is Invalid' : null;
} catch (err) {
return 'Invalid Value Type Selected';
}
};
See CONTRIBUTING for the contributing guide/information.
Copyright (c) 2025 Andrew Hathaway. Licensed under MIT license, see LICENSE for the full license.
FAQs
A simple pattern to help build type-safe dynamic user interfaces or applications without having specific code littered throughout your codebase.
The npm package manifest-pattern receives a total of 1 weekly downloads. As such, manifest-pattern popularity was classified as not popular.
We found that manifest-pattern demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.