## Add codegen script for frontend test mock data ### Summary - Adds a new `npx nx mock:generate twenty-front` and `generate-mock-data.ts` script that fetches object metadata from a running server's `/metadata` endpoint, authenticates with default seeds, and writes the result to a generated TypeScript file (`src/testing/mock-data/generated/mock-metadata-query-result.ts`). This replaces hand-maintained mock metadata with server-sourced data, ensuring tests always reflect the real schema. - Updates all frontend tests to be compatible with the newly generated metadata, fixing hard-coded GraphQL queries, Zod validation schemas, snapshot expectations, and Apollo mock mismatches. ### What changed **New files** - `scripts/generate-mock-data.ts` — codegen script that authenticates against the server, queries `/metadata` for all object metadata (with explicit `__typename` at every level), and writes a typed `.ts` file. - `project.json` — added `mock:generate` Nx target (`dotenv npx tsx scripts/generate-mock-data.ts`). **Schema validation updates** - `objectMetadataItemSchema.ts` — added `universalIdentifier`, made `duplicateCriteria` nullable. - `fieldMetadataItemSchema.ts` — added `universalIdentifier`, `morphId`, `morphRelations`, restructured relation schema. - `indexMetadataItemSchema.ts` — added optional `isCustom` field.
54 lines
1.3 KiB
JSON
54 lines
1.3 KiB
JSON
{
|
|
"compilerOptions": {
|
|
"target": "ES2020",
|
|
"useDefineForClassFields": true,
|
|
"lib": ["ES2020", "DOM", "DOM.Iterable", "ES2023", "ES2023.Array"],
|
|
"module": "ESNext",
|
|
"skipLibCheck": true,
|
|
"allowJs": true,
|
|
"esModuleInterop": true,
|
|
"moduleResolution": "bundler",
|
|
"allowSyntheticDefaultImports": true,
|
|
"allowImportingTsExtensions": false,
|
|
"resolveJsonModule": true,
|
|
"isolatedModules": true,
|
|
"noEmit": true,
|
|
"jsx": "react-jsx",
|
|
"strict": true,
|
|
"noUnusedLocals": false,
|
|
"noUnusedParameters": false,
|
|
"noFallthroughCasesInSwitch": true,
|
|
"forceConsistentCasingInFileNames": true,
|
|
"outDir": "../../.cache/tsc",
|
|
"paths": {
|
|
"@/*": ["./src/modules/*"],
|
|
"~/*": ["./src/*"]
|
|
},
|
|
"types": ["node", "jest"],
|
|
"plugins": [
|
|
{
|
|
"name": "@styled/typescript-styled-plugin",
|
|
"lint": {
|
|
"validProperties": ["container-type"]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"include": [
|
|
"src/**/*.js",
|
|
"src/**/*.jsx",
|
|
"src/**/*.d.ts",
|
|
"src/**/*.ts",
|
|
"src/**/*.tsx",
|
|
"scripts/**/*.ts",
|
|
".storybook/*.ts",
|
|
".storybook/*.tsx",
|
|
"lingui.config.ts",
|
|
"jest.config.mjs",
|
|
"vite.config.ts",
|
|
"vitest.config.ts",
|
|
"setupTests.ts"
|
|
],
|
|
"extends": "../../tsconfig.base.json"
|
|
}
|