Files
plainleaf/plug-api/types/index.ts
T
Zef Hemel 0773df31e2 Add validation and error handling for object indexing
- Introduced a new `validate` callback for `tag.define`
- Added `index.validateObjects` API to validate and transform objects before indexing.
- Updated relevant documentation and examples to reflect these changes.
2026-02-03 15:59:04 +01:00

57 lines
1.4 KiB
TypeScript

export type FileMeta = {
name: string;
created: number;
lastModified: number;
contentType: string;
size: number;
perm: "ro" | "rw";
};
/**
* Decorates a page when it matches certain criteria
*/
export type PageDecoration = {
prefix?: string;
cssClasses?: string[];
hide?: boolean;
renderWidgets?: boolean; // Defaults to true
};
export type PageMeta = ObjectValue<
{
name: string;
created: string; // indexing it as a string
lastModified: string; // indexing it as a string
perm: "ro" | "rw";
lastOpened?: number;
pageDecoration?: PageDecoration;
} & Record<string, any>
>;
export type DocumentMeta = ObjectValue<
{
name: string;
contentType: string;
created: string;
lastModified: string;
size: number;
perm: "ro" | "rw";
extension: string;
} & Record<string, any>
>;
export type SyscallMeta = {
name: string;
requiredPermissions: string[];
argCount: number;
};
/**
* An ObjectValue that can be indexed by the `index` plug, needs to have a minimum of
* of two fields:
* - ref: a unique reference (id) for the object, ideally a page reference
* - tags: a list of tags that the object belongs to
*/
export type ObjectValue<T = any> = {
ref: string;
tag: string; // main tag
range?: [number, number];
tags?: string[];
itags?: string[]; // implicit or inherited tags (inherited from the page for instance)
} & T;