19 lines
1.1 KiB
JavaScript
19 lines
1.1 KiB
JavaScript
import fs from 'node:fs';
|
|
import { Store } from '../../src/server/store.mjs';
|
|
import { TaskPlanManager } from '../../src/core/tasks/task-plan-manager.mjs';
|
|
import { readingStep } from './task-plan-fixture.mjs';
|
|
|
|
const [inputFile] = process.argv.slice(2), input = JSON.parse(fs.readFileSync(inputFile, 'utf8'));
|
|
const store = new Store(input.data), session = store.session(input.sessionId), manager = new TaskPlanManager(store);
|
|
const put = store.putRecord.bind(store);
|
|
store.putRecord = (kind, ...args) => {
|
|
const selected = kind === (input.operation === 'plan' ? 'task_plan' : 'task_proof');
|
|
if (selected && input.point === 'before') process.exit(71);
|
|
const result = put(kind, ...args);
|
|
if (selected && input.point === 'after') process.exit(71);
|
|
return result;
|
|
};
|
|
if (input.operation === 'plan') await manager.plan(session, { expected_revision: 0, steps: [readingStep()] });
|
|
else await manager.verify(session, { plan_id: input.planId, expected_revision: 1, step_key: 'read', evidence_id: input.evidenceId });
|
|
throw new Error('The declared process exit point was not reached.');
|