"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ingestMediaUrlsBatch = void 0;
const logger_1 = __importDefault(require("../../../logger"));
const datasetRowsService_1 = require("../../services/datasetRows/datasetRowsService");
const ingestMediaUrlsBatch = async (req, res) => {
    try {
        const { id: datasetId } = req.params;
        const token = (req.headers['x-access-token'] || req.headers.authorization);
        const { orgId, projectId, items } = (req.body ?? {});
        if (!datasetId || !orgId || !projectId) {
            res.status(400).json({ error: 'datasetId, orgId, and projectId are required' });
            return;
        }
        if (!Array.isArray(items) || items.length === 0) {
            res.status(400).json({ error: 'items must be a non-empty array of { url, expectedType? }' });
            return;
        }
        const blobUrls = await datasetRowsService_1.datasetRowsService.ingestMediaUrlItemsForDataset({
            datasetId,
            token,
            items,
        });
        res.json({ blobUrls });
    }
    catch (error) {
        logger_1.default.error(`ingestMediaUrlsBatch: ${error}`);
        const status = typeof error?.status === 'number' ? error.status : 500;
        res.status(status).json({ error: error?.message || 'Failed to ingest media urls' });
    }
};
exports.ingestMediaUrlsBatch = ingestMediaUrlsBatch;
//# sourceMappingURL=ingest-media-urls-batch.js.map