Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This commit modifies the log level in the configuration file from "trace" to "debug" for improved logging clarity. It also introduces new routes for fulfillment, return, and payment policies in the index file, enhancing the marketplace integration capabilities. Additionally, the initialization process is updated to start the marketplace worker, ensuring that the application can handle marketplace operations effectively. Various schemas are updated to include new fields and relationships for policies, improving the overall functionality and flexibility of the marketplace management system.
111 lines
3.8 KiB
JavaScript
111 lines
3.8 KiB
JavaScript
import express from 'express';
|
|
import { isAuthenticated } from '../../keycloak.js';
|
|
import { checkPermissions } from '../../database/permissions.js';
|
|
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
|
|
|
const router = express.Router();
|
|
|
|
const listAllowedFilters = [
|
|
'filament',
|
|
'filament._id',
|
|
'filamentSku',
|
|
'filamentSku._id',
|
|
'state',
|
|
'startingWeight',
|
|
'currentWeight',
|
|
'stockLocation',
|
|
'stockLocation._id',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference',
|
|
];
|
|
const listAllowedSorters = ['createdAt', 'updatedAt', 'filament', 'filamentSku', 'state'];
|
|
const propertiesAllowedFilters = [
|
|
'filament',
|
|
'filament._id',
|
|
'filamentSku',
|
|
'state.type',
|
|
'filamentSku._id',
|
|
];
|
|
import {
|
|
listFilamentStocksRouteHandler,
|
|
getFilamentStockRouteHandler,
|
|
editFilamentStockRouteHandler,
|
|
editMultipleFilamentStocksRouteHandler,
|
|
newFilamentStockRouteHandler,
|
|
deleteFilamentStockRouteHandler,
|
|
listFilamentStocksByPropertiesRouteHandler,
|
|
getFilamentStockStatsRouteHandler,
|
|
getFilamentStockHistoryRouteHandler,
|
|
searchFilamentStocksRouteHandler,
|
|
getFilamentStockPropertyValuesRouteHandler,
|
|
|
|
getFilamentStockNeighborsRouteHandler
|
|
} from '../../services/inventory/filamentstocks.js';
|
|
|
|
// list of filament stocks
|
|
router.get('/', isAuthenticated, checkPermissions('filamentStock', 'list'), async (req, res) => {
|
|
const { page, limit, property, search, sortProperty, sortOrder } = req.query;
|
|
const filter = await getFilter(req.query, listAllowedFilters);
|
|
listFilamentStocksRouteHandler(req, res, page, limit, property, filter, search, getSort(sortProperty, listAllowedSorters), sortOrder);
|
|
});
|
|
|
|
router.get('/properties', checkPermissions('filamentStock', 'list'), isAuthenticated, async (req, res) => {
|
|
let properties = convertPropertiesString(req.query.properties);
|
|
const filter = await getFilter(req.query, propertiesAllowedFilters, false);
|
|
var masterFilter = {};
|
|
if (req.query.masterFilter) {
|
|
masterFilter = JSON.parse(req.query.masterFilter);
|
|
}
|
|
listFilamentStocksByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
|
|
});
|
|
|
|
router.get('/values', checkPermissions('filamentStock', 'list'), isAuthenticated, async (req, res) => {
|
|
const { property } = req.query;
|
|
getFilamentStockPropertyValuesRouteHandler(req, res, property);
|
|
});
|
|
router.get('/search', checkPermissions('filamentStock', 'list'), isAuthenticated, async (req, res) => {
|
|
const { search } = req.query;
|
|
searchFilamentStocksRouteHandler(req, res, search);
|
|
});
|
|
|
|
|
|
router.post('/', isAuthenticated, checkPermissions('filamentStock', 'new'), async (req, res) => {
|
|
newFilamentStockRouteHandler(req, res);
|
|
});
|
|
|
|
// get filament stock stats
|
|
router.get('/stats', isAuthenticated, async (req, res) => {
|
|
getFilamentStockStatsRouteHandler(req, res);
|
|
});
|
|
|
|
// get filament stock history
|
|
router.get('/history', isAuthenticated, async (req, res) => {
|
|
getFilamentStockHistoryRouteHandler(req, res);
|
|
});
|
|
|
|
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
|
const { property, search, sortProperty, sortOrder, id } = req.query;
|
|
const filter = await getFilter(req.query, listAllowedFilters);
|
|
getFilamentStockNeighborsRouteHandler(req, res, property, filter, search, getSort(sortProperty, listAllowedSorters), sortOrder, id);
|
|
});
|
|
|
|
router.get('/:id', isAuthenticated, checkPermissions('filamentStock', 'info'), async (req, res) => {
|
|
getFilamentStockRouteHandler(req, res);
|
|
});
|
|
|
|
// update multiple filament stocks
|
|
router.put('/', isAuthenticated, checkPermissions('filamentStock', 'edit'), async (req, res) => {
|
|
editMultipleFilamentStocksRouteHandler(req, res);
|
|
});
|
|
|
|
router.put('/:id', isAuthenticated, checkPermissions('filamentStock', 'edit'), async (req, res) => {
|
|
editFilamentStockRouteHandler(req, res);
|
|
});
|
|
|
|
router.delete('/:id', isAuthenticated, async (req, res) => {
|
|
deleteFilamentStockRouteHandler(req, res);
|
|
});
|
|
|
|
export default router;
|