feat(research): prepare stored EOD datasets before canonical admission
This commit is contained in:
parent
366bee810b
commit
0c6aec4dc6
16 changed files with 1897 additions and 61 deletions
|
|
@ -2,6 +2,7 @@ import { Hono } from 'hono';
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import { requireServices, type IServiceContainer } from '@stock-bot/services';
|
||||
import { HistoricalDataRequestError } from '@stock-bot/types';
|
||||
import { StorageService } from '../../../orchestrator/src/services/StorageService';
|
||||
import { canonicalDatasetEntry } from '../services/canonical-research.service';
|
||||
import { DatasetCatalogService } from '../services/dataset-catalog.service';
|
||||
import {
|
||||
|
|
@ -9,6 +10,10 @@ import {
|
|||
previewDatasetPreparation,
|
||||
retainDatasetPreparation,
|
||||
} from '../services/dataset-preparation.service';
|
||||
import {
|
||||
prepareStoredDataset,
|
||||
StoredDatasetPreparationError,
|
||||
} from '../services/stored-dataset-preparation';
|
||||
|
||||
const logger = getLogger('dataset-catalog-routes');
|
||||
|
||||
|
|
@ -23,6 +28,32 @@ export function createDatasetRoutes(container: IServiceContainer) {
|
|||
throw new DatasetPreparationError(400, 'Invalid JSON request');
|
||||
}
|
||||
};
|
||||
app.post('/api/v2/datasets/canonical/stored-source', async c => {
|
||||
c.header('Cache-Control', 'no-store');
|
||||
try {
|
||||
const body = await readBody(c.req.raw);
|
||||
// Request-local read adapter: no initialization, mode changes or shared trading runtime.
|
||||
const storage = new StorageService(container, container.mongodb, null, null);
|
||||
const prepared = await prepareStoredDataset(body, storage, c.req.raw.signal);
|
||||
c.req.raw.signal.throwIfAborted();
|
||||
return c.json(prepared);
|
||||
} catch (error) {
|
||||
if (c.req.raw.signal.aborted) {
|
||||
return Response.json(
|
||||
{ error: 'Stored source preparation cancelled' },
|
||||
{ status: 499, headers: { 'Cache-Control': 'no-store' } }
|
||||
);
|
||||
}
|
||||
if (
|
||||
error instanceof StoredDatasetPreparationError ||
|
||||
error instanceof DatasetPreparationError
|
||||
) {
|
||||
return c.json({ error: error.message }, error.status);
|
||||
}
|
||||
logger.error('Failed to prepare stored source dataset', error);
|
||||
return c.json({ error: 'Stored source preparation unavailable' }, 500);
|
||||
}
|
||||
});
|
||||
app.post('/api/v2/datasets/canonical/preview', async c => {
|
||||
c.header('Cache-Control', 'no-store');
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue