import { __awaiter } from "tslib";
import { QoreClient } from "@qorebase/client";
import { generateWebmanifest } from "@qorebase/app-runtime/src/utils/webmanifest";
import { qoreConfig } from "../../../../app/hooks/qoreStorageClient";
const manifest = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
    var _a;
    const client = new QoreClient(qoreConfig);
    client.project.axios.defaults.headers["x-qore-engine-admin-secret"] =
        qoreConfig.adminSecret;
    const revisions = yield client
        .table("revisions")
        .readRows({
        condition: {
            apprevision: { $eq: req.query.appId },
        },
        orderBy: {
            created_at: "DESC",
        },
        limit: 1,
    })
        .toPromise();
    const revision = (_a = revisions.data) === null || _a === void 0 ? void 0 : _a.nodes[0];
    if (!revision)
        return res.status(404).send("Not found");
    const schema = revision.data;
    res.status(200).json(generateWebmanifest(schema));
});
export default manifest;
//# sourceMappingURL=manifest.webmanifest.js.map