UNPKG

@dossierhq/core

Version:

The core Dossier library used by clients and server alike, used to interact with schema and entities directly, as well as remotely through a client.

33 lines (32 loc) 1.64 kB
import type { PublishedSchema } from '../schema/PublishedSchema.js'; import type { Schema } from '../schema/Schema.js'; import type { Entity, EntityCreate, EntityUpdate } from '../Types.js'; import type { ContentValuePath } from './ContentPath.js'; import { type ContentTraverseNode } from './ContentTraverser.js'; export interface SaveValidationIssue { type: 'save'; path: ContentValuePath; message: string; } export interface PublishValidationIssue { type: 'publish'; path: ContentValuePath; message: string; } export declare function validateEntityInfo(schema: Schema, path: ContentValuePath, entity: Entity): SaveValidationIssue | null; export declare function validateEntityInfoForCreate(schema: Schema, path: ContentValuePath, entity: EntityCreate): SaveValidationIssue | null; export declare function validateEntityInfoForUpdate(path: ContentValuePath, existingEntity: { info: { type: string; authKey: string; version: number; }; }, entity: EntityUpdate): SaveValidationIssue | null; export declare function validateTraverseNodeForSave<TSchema extends Schema | PublishedSchema>(schema: TSchema, node: ContentTraverseNode<TSchema>, options?: { ignoreExtraContentFields: boolean; }): SaveValidationIssue | null; export declare function validateTraverseNodeForPublish(schema: Schema, node: ContentTraverseNode<PublishedSchema>): PublishValidationIssue | null; export declare function groupValidationIssuesByTopLevelPath<TError extends SaveValidationIssue | PublishValidationIssue>(errors: TError[]): { root: TError[]; children: Map<number | string, TError[]>; };