Replaces nginx.conf CSP map with inline policy and updates the policy for development. Adds new dependencies including Mantine, Radix, Tabler, FontAwesome, and others. Removes the fetch-openapi.js script and introduces generate-choice-labels.cjs to auto-generate TypeScript choice label constants from Orval enums, updating the api:gen script to run this generator. Also updates orval and other dev dependencies, and makes minor formatting changes in orval.config.ts.
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
import { defineConfig } from "orval";
|
|
|
|
const backendUrl =
|
|
process.env.VITE_BACKEND_URL || 'http://localhost:8000';
|
|
|
|
// může se hodit pokud nechceme při buildu generovat klienta (nechat false pro produkci nebo vynechat)
|
|
const SKIP_ORVAL = process.env.SKIP_ORVAL === "true";
|
|
|
|
if (SKIP_ORVAL) {
|
|
console.log("[ORVAL] Generation skipped.");
|
|
process.exit(0);
|
|
}
|
|
|
|
export default defineConfig({
|
|
// Public endpoints (all endpoints tagged with "public")
|
|
public: {
|
|
input: {
|
|
target: `${backendUrl}/api/schema/`,
|
|
filters: {
|
|
mode: "include",
|
|
tags: ["public"],
|
|
},
|
|
},
|
|
output: {
|
|
target: "api/generated/public/index.ts",
|
|
schemas: "api/generated/public/models",
|
|
mode: "tags",
|
|
clean: true,
|
|
client: "react-query",
|
|
httpClient: "axios",
|
|
tsconfig: "./tsconfig.app.json",
|
|
override: {
|
|
mutator: {
|
|
path: "api/publicClient.ts",
|
|
name: "publicMutator",
|
|
},
|
|
formUrlEncoded: true,
|
|
useDates: true,
|
|
},
|
|
},
|
|
hooks: {
|
|
afterAllFilesWrite: 'prettier --write',
|
|
}
|
|
},
|
|
|
|
// All private endpoints (organized by tags, shared models folder)
|
|
private: {
|
|
input: {
|
|
target: `${backendUrl}/api/schema/`,
|
|
filters: {
|
|
mode: "exclude",
|
|
tags: ["public"], // Exclude public endpoints, include everything else
|
|
},
|
|
},
|
|
output: {
|
|
target: "api/generated/private",
|
|
schemas: "api/generated/private/models",
|
|
mode: "tags-split", // Split by tag into separate files
|
|
clean: true,
|
|
client: "react-query",
|
|
httpClient: "axios",
|
|
tsconfig: "./tsconfig.app.json",
|
|
override: {
|
|
mutator: {
|
|
path: "api/privateClient.ts",
|
|
name: "privateMutator",
|
|
},
|
|
formUrlEncoded: true,
|
|
useDates: true,
|
|
query: {
|
|
useQuery: true,
|
|
useInfinite: false, // Disable infinite queries to avoid page param errors
|
|
},
|
|
},
|
|
},
|
|
hooks: {
|
|
afterAllFilesWrite: 'prettier --write',
|
|
}
|
|
},
|
|
});
|