open-agreements
Version:
Open-source legal template filling CLI and library
76 lines • 3.33 kB
TypeScript
import { type ClosingChecklist } from './schemas.js';
import { type ChecklistPatchEnvelope, type ChecklistPatchOperation } from './patch-schemas.js';
export declare const CHECKLIST_PATCH_VALIDATION_TTL_MS: number;
export type ChecklistPatchValidationErrorCode = 'CHECKLIST_SCHEMA_INVALID' | 'PATCH_SCHEMA_INVALID' | 'REVISION_CONFLICT' | 'TARGET_NOT_FOUND' | 'TARGET_PATH_INVALID' | 'TARGET_PARENT_INVALID' | 'POST_PATCH_SCHEMA_INVALID';
export interface ChecklistPatchValidationDiagnostic {
code: ChecklistPatchValidationErrorCode;
message: string;
path?: string;
operation_index?: number;
}
export interface ResolvedChecklistPatchOperation {
operation_index: number;
op: ChecklistPatchOperation['op'];
path: string;
parent_path: string;
parent_container: 'object' | 'array';
target_exists_before: boolean;
}
export interface ChecklistPatchValidationArtifact {
validation_id: string;
checklist_id: string;
patch_id: string;
patch_hash: string;
expected_revision: number;
created_at_ms: number;
expires_at_ms: number;
resolved_operations: ResolvedChecklistPatchOperation[];
}
export interface ChecklistPatchValidationStore {
set(artifact: ChecklistPatchValidationArtifact): Promise<void>;
get(validationId: string): Promise<ChecklistPatchValidationArtifact | null>;
delete(validationId: string): Promise<void>;
}
export declare function setChecklistPatchValidationStore(store: ChecklistPatchValidationStore | null): void;
export declare function getChecklistPatchValidationStore(): ChecklistPatchValidationStore;
export interface ValidateChecklistPatchInput {
checklist_id: string;
checklist: unknown;
current_revision: number;
patch: unknown;
now_ms?: number;
validation_ttl_ms?: number;
store?: ChecklistPatchValidationStore;
}
export interface ChecklistPatchValidationSuccess {
ok: true;
validation_id: string;
patch_hash: string;
patch: ChecklistPatchEnvelope;
resolved_operations: ResolvedChecklistPatchOperation[];
resulting_state_valid: true;
artifact_expires_at_ms: number;
}
export interface ChecklistPatchValidationFailure {
ok: false;
diagnostics: ChecklistPatchValidationDiagnostic[];
patch?: ChecklistPatchEnvelope;
resolved_operations: ResolvedChecklistPatchOperation[];
}
export type ChecklistPatchValidationResult = ChecklistPatchValidationSuccess | ChecklistPatchValidationFailure;
export declare function computeChecklistPatchHash(patch: ChecklistPatchEnvelope): string;
export declare const DANGEROUS_KEYS: Set<string>;
export type ChecklistPatchOperationApplyResult = {
ok: true;
resolved_operations: ResolvedChecklistPatchOperation[];
} | {
ok: false;
diagnostic: ChecklistPatchValidationDiagnostic;
};
export declare function applyChecklistPatchOperations(root: ClosingChecklist, operations: ChecklistPatchOperation[]): ChecklistPatchOperationApplyResult;
export declare function getChecklistPatchValidationArtifact(validationId: string, opts?: {
now_ms?: number;
store?: ChecklistPatchValidationStore;
}): Promise<ChecklistPatchValidationArtifact | null>;
export declare function validateChecklistPatch(input: ValidateChecklistPatchInput): Promise<ChecklistPatchValidationResult>;
//# sourceMappingURL=patch-validator.d.ts.map