import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import { apiHit } from "../../../globalUtils/apiHits.js";

const app = new OpenAPIHono({ strict: false });
const current: any = [
    {
        name: "getActiveAv",
        endpoint: "/api/datamart/getarticles",
        description: "Gets all current active AV, with specific critiera.",
    },
    // {
    //     name: "getStockLaneDims",
    //     endpoint: "/api/v1/masterData/getStockDims",
    //     description: "Returns the lane dims along with a column to send actaul dims to be updated.",
    // },
    // {
    //     name: "getAddressInfo",
    //     endpoint: "/api/v1/masterData/getAddressInfo",
    //     description: "Returns current active addresses with street and zip",
    // },
    // {
    //     name: "getMissingPkgData",
    //     endpoint: "/api/v1/masterData/getMissingPKGData",
    //     description: "Returns all packaging data that is missing either printer, layout, or carton layout",
    // },
    {
        name: "getCustomerInventory",
        endpoint: "/api/datamart/getcustomerinventory",
        description:
            "Returns specific customer inventory based on there address ID, with optional to include warehouses, IE 36,41,5. leaving warehouse blank will just pull everything",
        criteria: "customer,whseToInclude",
    },
    // {
    //     name: "getPalletLabels",
    //     endpoint: "/api/v1/masterData/getPalletLabels",
    //     description: "Returns specific amount of pallets RN, Needs label number and printer, Specfic to Dayton.",
    //     criteria: "runningNumber,printerName,count",
    // },
    {
        name: "getopenorders",
        endpoint: "/api/datamart/getopenorders",
        description:
            "Returns open orders based on day count sent over, sDay 15 days in the past eDay 5 days in the future, can be left empty for this default days",
        criteria: "sDay,eDay",
    },
    // {
    //     name: "getOpenIncoming",
    //     endpoint: "/api/v1/masterData/getOpenIncoming",
    //     description:
    //         "Returns open orders based on day count sent over, sDay 15 days in the past eDay 5 days in the future, can be left empty for this default days",
    //     criteria: "sDay,eDay",
    // },
    // {
    //     name: "planningCheckPkg",
    //     endpoint: "/api/v1/masterData/planningPkgCheck",
    //     description: "Returns all lots starting later than today and has a pkg that is missing layouts.",
    // },
    {
        name: "getinventory",
        endpoint: "/api/datamart/getinventory",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns all inventory,  excludes inv locations. no running numbers",
        criteria: "includeRunnningNumbers", // uncomment this out once the improt process can be faster
    },
    // {
    //     name: "getOpenOrderUpdates",
    //     endpoint: "/api/v1/masterData/getOpenOrderUpdates",
    //     // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
    //     description: "Returns all orders based on customer id, leaving empty will pull everythinng in.",
    //     criteria: "customer", // uncomment this out once the improt process can be faster
    // },
    {
        name: "getSiloAdjustment",
        endpoint: "/api/logistics/getsilosdjustment",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns all siloadjustments in selected date range IE: 1/1/2025 to 1/31/2025",
        criteria: "startDate,endDate", // uncomment this out once the improt process can be faster
    },
    {
        name: "Delivery by date trange",
        endpoint: "/api/datamart/deliverybydaterange",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns all Deliverys in selected date range IE: 1/1/2025 to 1/31/2025",
        criteria: "start,end", // uncomment this out once the improt process can be faster
    },
    {
        name: "Fake Edi Update",
        endpoint: "/api/datamart/fakeediupdate",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns all open orders to correct and resubmit, leaving blank will get everything putting an address only returns the specified address",
        criteria: "address", // uncomment this out once the improt process can be faster
    },
    {
        name: "Address Corrections",
        endpoint: "/api/datamart/getaddressdata",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns all addresses that will not process correctly in tms due to incorrect city state setup.",
        //criteria: "address", // uncomment this out once the improt process can be faster
    },
    {
        name: "Fifo index",
        endpoint: "/api/datamart/getfifoindex",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns fifo index for all pallets shipped within the last 90 days.",
        //criteria: "address", // uncomment this out once the improt process can be faster
    },
    {
        name: "Finance Audit inv",
        endpoint: "/api/datamart/getfinanceaudit",
        // description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
        description:
            "Returns all inventory past the date provided, ie: 5/31/2025",
        criteria: "date", // uncomment this out once the improt process can be faster
    },
];

app.openapi(
    createRoute({
        tags: ["dataMart"],
        summary: "Returns all avalible querys.",
        method: "get",
        path: "/getavalibleaquerys",

        responses: responses(),
    }),
    async (c) => {
        //const body = await c.req.json();
        // make sure we have a vaid user being accessed thats really logged in
        apiHit(c, { endpoint: "/getavalibleaquerys" });

        return c.json({
            success: true,
            message: "All Current Active Querys.",
            sheetVersion: 2.8,
            data: current,
        });
    }
);
export default app;
