"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBriefFlows = void 0;
var tslib_1 = require("tslib");
exports.getBriefFlows = {
    rest: {
        method: 'GET',
        fullPath: '/api/pepsico-content/brief-flows'
    },
    handler: function (ctx) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var filters, query, _a, records, totalCount, _b, _c, _d;
            return tslib_1.__generator(this, function (_e) {
                switch (_e.label) {
                    case 0:
                        filters = ctx.params.filters;
                        query = { fields: ["_id", "name"] };
                        if (filters) {
                            query.filters = JSON.parse(filters);
                        }
                        _c = (_b = Promise).all;
                        return [4, this.getObject('pepsico_material_approval').find(query)];
                    case 1:
                        _d = [
                            _e.sent()
                        ];
                        return [4, this.getObject('pepsico_material_approval').count(query)];
                    case 2: return [4, _c.apply(_b, [_d.concat([
                                _e.sent()
                            ])])];
                    case 3:
                        _a = tslib_1.__read.apply(void 0, [_e.sent(), 2]), records = _a[0], totalCount = _a[1];
                        return [2, {
                                "status": 0,
                                "msg": "",
                                "data": {
                                    "items": records,
                                    "total": totalCount
                                }
                            }];
                }
            });
        });
    }
};
//# sourceMappingURL=briefFlows.js.map