73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
import z from "zod";
|
|
|
|
/**
|
|
* Zod schema for `UndoStackOptions`.
|
|
*/
|
|
export const UndoStackOptionsSchema = z
|
|
.object({
|
|
maxEntries: z.number().int().positive().optional(),
|
|
maxMemoryBytes: z.number().int().positive().optional(),
|
|
onTruncate: z.function().optional(),
|
|
clock: z.function().optional(),
|
|
idGenerator: z.function().optional(),
|
|
})
|
|
.strict();
|
|
|
|
export type UndoStackOptionsInput = z.input<typeof UndoStackOptionsSchema>;
|
|
|
|
/**
|
|
* Zod schema for `BranchingOptions`.
|
|
*/
|
|
export const BranchingOptionsSchema = z
|
|
.object({
|
|
initialBranchLabel: z.string().min(1).optional(),
|
|
branchOnDiverge: z.boolean().optional(),
|
|
maxEntries: z.number().int().positive().optional(),
|
|
clock: z.function().optional(),
|
|
idGenerator: z.function().optional(),
|
|
})
|
|
.strict();
|
|
|
|
export type BranchingOptionsInput = z.input<typeof BranchingOptionsSchema>;
|
|
|
|
/**
|
|
* Zod schema for `HistoryCompressorOptions`.
|
|
*/
|
|
export const HistoryCompressorOptionsSchema = z
|
|
.object({
|
|
compressionDepth: z.number().int().min(0).optional(),
|
|
maxHistorySize: z.number().int().positive().optional(),
|
|
})
|
|
.strict();
|
|
|
|
export type HistoryCompressorOptionsInput = z.input<
|
|
typeof HistoryCompressorOptionsSchema
|
|
>;
|
|
|
|
/**
|
|
* Zod schema for `CommandMergerOptions`.
|
|
*/
|
|
export const CommandMergerOptionsSchema = z
|
|
.object({
|
|
maxCount: z.number().int().positive().optional(),
|
|
timeWindowMs: z.number().positive().optional(),
|
|
clock: z.function().optional(),
|
|
})
|
|
.strict();
|
|
|
|
export type CommandMergerOptionsInput = z.input<
|
|
typeof CommandMergerOptionsSchema
|
|
>;
|
|
|
|
/**
|
|
* Zod schema for `SelectiveUndoOptions`.
|
|
*/
|
|
export const SelectiveUndoOptionsSchema = UndoStackOptionsSchema.extend({
|
|
throwOnConflict: z.boolean().optional(),
|
|
dependencyCheck: z.function().optional(),
|
|
});
|
|
|
|
export type SelectiveUndoOptionsInput = z.input<
|
|
typeof SelectiveUndoOptionsSchema
|
|
>;
|