@mantis-core/commons
v0.1.2
Published
Shared contracts and common primitives for Mantis Core packages.
Maintainers
Readme
@mantis-core/commons
Shared contracts and primitive types used by other @mantis-core/* packages and app adapters.
Scope
- Generic action/result contracts.
- Shared pagination contract.
- Zero runtime side effects.
Out Of Scope
- Domain entities (house/lead/blog/etc).
- UI components.
- App-specific API shapes.
Public API
export type ResultWrapper<T> = { data: T | null; error: string | null };
export type ActionResult<T> = Promise<ResultWrapper<T>>;
export type Paginated<T> = {
data: T[];
pagination: {
page: number;
pageSize: number;
totalCount: number;
totalPages: number;
hasNextPage: boolean;
hasPreviousPage: boolean;
};
};Usage Example
import type { ActionResult, Paginated } from "@mantis-core/commons";
type Item = { id: string; name: string };
export async function getItems(): ActionResult<Paginated<Item>> {
return {
data: {
data: [{ id: "1", name: "Example" }],
pagination: {
page: 1,
pageSize: 10,
totalCount: 1,
totalPages: 1,
hasNextPage: false,
hasPreviousPage: false,
},
},
error: null,
};
}Build
pnpm --filter @mantis-core/commons build
pnpm --filter @mantis-core/commons typecheckNotes
- Keep API minimal and stable.
- Prefer additive changes for backward compatibility.
