module.exports = function (app) { const router = require('express').Router(), uploadJobCtl = require('../controllers/upload_job')(app), { checkRqPkgSubscription } = require('../middlewares/app_validator'); /** * @api {post} /imports/uploadJob Upload Job items, data or both * @apiVersion 1.2.1 * @apiName PostImportsUploadJob * @apiGroup Imports * @apiDescription Upload the file then update given Job with items, data files. Supported files: zip (AgNav or ESRI shape), kml/kml. Upload uses HTTP MultiPart form data encoding type. * @apiParam {Integer} jobId Job Id * @apiParam {Integer} updateOp Job update type. For aircraft users, value of 1 is normally always be used. * * 1: Only import data files * * 2: Append found items to job items * * 3: Override job items with the found items * * @apiParam name Field name for the file in Multipart. Value must always be "jobs[]" * @apiSuccessExample {json} Success * HTTP/1.1 200 OK * @apiuse JobNotFoundError * @apiuse WrongJobFileError * @apiuse JobNotAssignedError */ router.post('/uploadJob', uploadJobCtl.uploadJob_post); /** * Handle uploading Job areas/data files from a multi-part request */ router.post('/uploadData', uploadJobCtl.uploadData_post); router.post('/cancelImport', uploadJobCtl.cancelImport_post); /** * Handle uploading areas files (from a multi-part request) to add Areas from files to the Client's library * @param ops options in structure: * { * clientId: [applicattor Id], // Optional when readOnly = true * readOnly: [boolean], // Read the areas then return only, not store into db or other processing. * } **/ router.post('/uploadAreas', checkRqPkgSubscription, uploadJobCtl.uploadAreas_post); /** * @api {post} /imports/parseSatLocLog Parse SatLoc Binary Log File * @apiVersion 1.0.0 * @apiName PostImportsParseSatLocLog * @apiGroup Imports * @apiDescription Parse a SatLoc binary log file (.log) and extract application data records * @apiParam {String} filePath Absolute path to the .log file to parse * @apiParam {String} [jobId] Optional Job ID to associate parsed data with * @apiSuccessExample {json} Success * HTTP/1.1 200 OK * { * "success": true, * "fileName": "example.log", * "fileSize": 1048576, * "headerInfo": { * "version": "3.76", * "dataStartOffset": 8 * }, * "statistics": { * "totalRecords": 1500, * "validRecords": 1485, * "invalidRecords": 15, * "recordTypes": { * "1": 800, * "2": 400, * "10": 200, * "30": 85 * } * }, * "recordCount": 1485, * "applicationDetailCount": 800, * "savedToDatabase": 800 * } */ router.post('/parseSatLocLog', uploadJobCtl.parseSatLocLog_post); /** * @api {post} /imports/uploadSatLocLog Upload and Parse SatLoc Binary Log File * @apiVersion 1.0.0 * @apiName PostImportsUploadSatLocLog * @apiGroup Imports * @apiDescription Upload and parse a SatLoc binary log file (.log) with automatic data extraction * @apiParam {File} logFile The .log file to upload (multipart form field) * @apiParam {String} [jobId] Optional Job ID to associate parsed data with * @apiParam {String} [clientId] Optional Client ID for data organization * @apiSuccessExample {json} Success * HTTP/1.1 200 OK * { * "success": true, * "appId": "507f1f77bcf86cd799439011", * "fileName": "flight_001.log", * "fileSize": 2097152, * "headerInfo": { * "version": "3.76", * "dataStartOffset": 8 * }, * "statistics": { * "totalRecords": 2500, * "validRecords": 2485, * "recordTypes": { * "1": 1200, * "2": 600, * "10": 300 * } * }, * "savedToDatabase": 1200 * } */ router.post('/uploadSatLocLog', uploadJobCtl.uploadSatLocLog_post); app.use('/api/imports/', router); }