@next-vibe/checker 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/bin/vibe-runtime.js +10 -19
- package/.dist/bin/vibe-runtime.js.map +3 -3
- package/check.config.ts +4 -4
- package/package.json +2 -9
- package/src/app/api/[locale]/LICENSE +674 -0
- package/src/app/api/[locale]/i18n/de/index.ts +13 -0
- package/src/app/api/[locale]/i18n/en/index.ts +12 -0
- package/src/app/api/[locale]/i18n/pl/index.ts +11 -0
- package/src/app/api/[locale]/shared/i18n/de/index.ts +85 -0
- package/src/app/api/[locale]/shared/i18n/en/index.ts +83 -0
- package/src/app/api/[locale]/shared/i18n/pl/index.ts +85 -0
- package/src/app/api/[locale]/shared/stats-filtering.ts +202 -0
- package/src/app/api/[locale]/shared/types/common.schema.ts +55 -0
- package/src/app/api/[locale]/shared/types/response.schema.ts +372 -0
- package/src/app/api/[locale]/shared/types/stats-filtering.schema.ts +375 -0
- package/src/app/api/[locale]/shared/types/utils.ts +190 -0
- package/src/app/api/[locale]/shared/utils/base64.ts +49 -0
- package/src/app/api/[locale]/shared/utils/env-util.ts +40 -0
- package/src/app/api/[locale]/shared/utils/i18n/de/index.ts +21 -0
- package/src/app/api/[locale]/shared/utils/i18n/en/index.ts +19 -0
- package/src/app/api/[locale]/shared/utils/i18n/pl/index.ts +21 -0
- package/src/app/api/[locale]/shared/utils/index.ts +11 -0
- package/src/app/api/[locale]/shared/utils/object-path.ts +41 -0
- package/src/app/api/[locale]/shared/utils/object.test.ts +82 -0
- package/src/app/api/[locale]/shared/utils/object.ts +75 -0
- package/src/app/api/[locale]/shared/utils/parse-error.ts +134 -0
- package/src/app/api/[locale]/shared/utils/parse-json.ts +70 -0
- package/src/app/api/[locale]/shared/utils/time.ts +53 -0
- package/src/app/api/[locale]/shared/utils/validation.ts +127 -0
- package/src/app/api/[locale]/shared/utils/zod-required-fields.ts +116 -0
- package/src/app/api/[locale]/system/builder/definition.ts +1942 -0
- package/src/app/api/[locale]/system/builder/enum.ts +77 -0
- package/src/app/api/[locale]/system/builder/i18n/de/index.ts +677 -0
- package/src/app/api/[locale]/system/builder/i18n/en/index.ts +665 -0
- package/src/app/api/[locale]/system/builder/i18n/pl/index.ts +668 -0
- package/src/app/api/[locale]/system/builder/repository/build-executor.test.ts +182 -0
- package/src/app/api/[locale]/system/builder/repository/build-executor.ts +583 -0
- package/src/app/api/[locale]/system/builder/repository/bun-compiler.ts +261 -0
- package/src/app/api/[locale]/system/builder/repository/bundle-analyzer.ts +197 -0
- package/src/app/api/[locale]/system/builder/repository/config-loader.ts +159 -0
- package/src/app/api/[locale]/system/builder/repository/config-validator.ts +97 -0
- package/src/app/api/[locale]/system/builder/repository/constants.ts +125 -0
- package/src/app/api/[locale]/system/builder/repository/error-suggester.ts +75 -0
- package/src/app/api/[locale]/system/builder/repository/file-copier.ts +98 -0
- package/src/app/api/[locale]/system/builder/repository/folder-cleaner.ts +80 -0
- package/src/app/api/[locale]/system/builder/repository/index.ts +2 -0
- package/src/app/api/[locale]/system/builder/repository/npm-package-generator.ts +146 -0
- package/src/app/api/[locale]/system/builder/repository/output-formatter.ts +104 -0
- package/src/app/api/[locale]/system/builder/repository/profile-service.ts +79 -0
- package/src/app/api/[locale]/system/builder/repository/report-generator.ts +125 -0
- package/src/app/api/[locale]/system/builder/repository/vite-compiler.ts +291 -0
- package/src/app/api/[locale]/system/builder/route.ts +21 -0
- package/src/app/api/[locale]/system/builder/test-files/file1.ts +2 -0
- package/src/app/api/[locale]/system/builder/test-files/file2.tsx +10 -0
- package/src/app/api/[locale]/system/builder/test-files/file3.tsx +16 -0
- package/src/app/api/[locale]/system/builder/test-files/folderToCopy/fileInFolder.ts +2 -0
- package/src/app/api/[locale]/system/builder/test-files/test-config.ts +38 -0
- package/src/app/api/[locale]/system/builder/test-files/test-delete-config.ts +8 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/package.json +24 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/constants.ts +6 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/greet.ts +18 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/index.ts +7 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/utils/calculate.ts +27 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/tsconfig.json +19 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/tsconfig.tsbuildinfo +1 -0
- package/src/app/api/[locale]/system/builder/test-files/test3.css +1 -0
- package/src/app/api/[locale]/system/check/config/repository.ts +819 -0
- package/src/app/api/[locale]/system/check/config/shared.ts +396 -0
- package/src/app/api/[locale]/system/check/config/types.ts +616 -0
- package/src/app/api/[locale]/system/check/config/utils.ts +171 -0
- package/src/app/api/[locale]/system/check/i18n/de/index.ts +15 -0
- package/src/app/api/[locale]/system/check/i18n/en/index.ts +14 -0
- package/src/app/api/[locale]/system/check/i18n/pl/index.ts +15 -0
- package/src/app/api/[locale]/system/check/lint/definition.ts +414 -0
- package/src/app/api/[locale]/system/check/lint/enum.ts +37 -0
- package/src/app/api/[locale]/system/check/lint/i18n/de/index.ts +164 -0
- package/src/app/api/[locale]/system/check/lint/i18n/en/index.ts +162 -0
- package/src/app/api/[locale]/system/check/lint/i18n/pl/index.ts +164 -0
- package/src/app/api/[locale]/system/check/lint/repository.ts +753 -0
- package/src/app/api/[locale]/system/check/lint/route.ts +21 -0
- package/src/app/api/[locale]/system/check/oxlint/README.md +190 -0
- package/src/app/api/[locale]/system/check/oxlint/definition.ts +414 -0
- package/src/app/api/[locale]/system/check/oxlint/enum.ts +37 -0
- package/src/app/api/[locale]/system/check/oxlint/i18n/de/index.ts +171 -0
- package/src/app/api/[locale]/system/check/oxlint/i18n/en/index.ts +168 -0
- package/src/app/api/[locale]/system/check/oxlint/i18n/pl/index.ts +172 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/i18n/src/index.ts +372 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/jsx-capitalization/README.md +246 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/jsx-capitalization/src/index.ts +583 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/restricted-syntax/src/index.ts +500 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/restricted-syntax/test.tsx +74 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/shared/config-loader.ts +305 -0
- package/src/app/api/[locale]/system/check/oxlint/repository.ts +959 -0
- package/src/app/api/[locale]/system/check/oxlint/route.ts +21 -0
- package/src/app/api/[locale]/system/check/oxlint/types.ts +193 -0
- package/src/app/api/[locale]/system/check/test-project/bun.lock +449 -0
- package/src/app/api/[locale]/system/check/test-project/check.config.ts +989 -0
- package/src/app/api/[locale]/system/check/test-project/package.json +20 -0
- package/src/app/api/[locale]/system/check/test-project/src/constants.ts +6 -0
- package/src/app/api/[locale]/system/check/test-project/src/greet.ts +18 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/a11y-issues.tsx +107 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/eslint-issues.tsx +37 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/general-issues.ts +137 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/i18n-issues.tsx +129 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/jsx-capitalization-issues.tsx +131 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/nextjs-issues.tsx +95 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/promise-issues.ts +76 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/react-issues.tsx +95 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/restricted-syntax-issues.tsx +61 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/typescript-issues.ts +80 -0
- package/src/app/api/[locale]/system/check/test-project/src/utils/calculate.ts +27 -0
- package/src/app/api/[locale]/system/check/test-project/tsconfig.json +38 -0
- package/src/app/api/[locale]/system/check/test-project/tsconfig.tsbuildinfo +1 -0
- package/src/app/api/[locale]/system/check/typecheck/definition.ts +369 -0
- package/src/app/api/[locale]/system/check/typecheck/enum.ts +37 -0
- package/src/app/api/[locale]/system/check/typecheck/i18n/de/index.ts +159 -0
- package/src/app/api/[locale]/system/check/typecheck/i18n/en/index.ts +150 -0
- package/src/app/api/[locale]/system/check/typecheck/i18n/pl/index.ts +155 -0
- package/src/app/api/[locale]/system/check/typecheck/repository.ts +919 -0
- package/src/app/api/[locale]/system/check/typecheck/route.ts +22 -0
- package/src/app/api/[locale]/system/check/typecheck/utils.ts +168 -0
- package/src/app/api/[locale]/system/check/vibe-check/definition.ts +568 -0
- package/src/app/api/[locale]/system/check/vibe-check/enum.ts +69 -0
- package/src/app/api/[locale]/system/check/vibe-check/i18n/de/index.ts +192 -0
- package/src/app/api/[locale]/system/check/vibe-check/i18n/en/index.ts +189 -0
- package/src/app/api/[locale]/system/check/vibe-check/i18n/pl/index.ts +192 -0
- package/src/app/api/[locale]/system/check/vibe-check/repository.ts +545 -0
- package/src/app/api/[locale]/system/check/vibe-check/route.test.ts +1142 -0
- package/src/app/api/[locale]/system/check/vibe-check/route.ts +21 -0
- package/src/app/api/[locale]/system/generated/endpoint.ts +313 -0
- package/src/app/api/[locale]/system/generated/endpoints.ts +156 -0
- package/src/app/api/[locale]/system/generated/route-handlers.ts +224 -0
- package/src/app/api/[locale]/system/generators/endpoint/definition.ts +193 -0
- package/src/app/api/[locale]/system/generators/endpoint/i18n/de/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/endpoint/i18n/en/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/endpoint/i18n/pl/index.ts +50 -0
- package/src/app/api/[locale]/system/generators/endpoint/repository.ts +291 -0
- package/src/app/api/[locale]/system/generators/endpoint/route.ts +21 -0
- package/src/app/api/[locale]/system/generators/endpoints/definition.ts +246 -0
- package/src/app/api/[locale]/system/generators/endpoints/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/generators/endpoints/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/generators/endpoints/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/generators/endpoints/options-repository.ts +463 -0
- package/src/app/api/[locale]/system/generators/endpoints/repository.ts +383 -0
- package/src/app/api/[locale]/system/generators/endpoints/route.ts +18 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/definition.ts +194 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/i18n/de/index.ts +71 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/i18n/en/index.ts +69 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/i18n/pl/index.ts +71 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/repository.ts +294 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/route.ts +18 -0
- package/src/app/api/[locale]/system/generators/generate-all/definition.ts +355 -0
- package/src/app/api/[locale]/system/generators/generate-all/i18n/de/index.ts +96 -0
- package/src/app/api/[locale]/system/generators/generate-all/i18n/en/index.ts +94 -0
- package/src/app/api/[locale]/system/generators/generate-all/i18n/pl/index.ts +96 -0
- package/src/app/api/[locale]/system/generators/generate-all/repository.ts +257 -0
- package/src/app/api/[locale]/system/generators/generate-all/route.ts +20 -0
- package/src/app/api/[locale]/system/generators/i18n/de/index.ts +15 -0
- package/src/app/api/[locale]/system/generators/i18n/en/index.ts +14 -0
- package/src/app/api/[locale]/system/generators/i18n/pl/index.ts +15 -0
- package/src/app/api/[locale]/system/generators/route-handlers/definition.ts +198 -0
- package/src/app/api/[locale]/system/generators/route-handlers/i18n/de/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/route-handlers/i18n/en/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/route-handlers/i18n/pl/index.ts +50 -0
- package/src/app/api/[locale]/system/generators/route-handlers/repository.ts +277 -0
- package/src/app/api/[locale]/system/generators/route-handlers/route.ts +17 -0
- package/src/app/api/[locale]/system/generators/shared/utils.ts +233 -0
- package/src/app/api/[locale]/system/help/definition.ts +445 -0
- package/src/app/api/[locale]/system/help/i18n/de/index.ts +267 -0
- package/src/app/api/[locale]/system/help/i18n/en/index.ts +262 -0
- package/src/app/api/[locale]/system/help/i18n/pl/index.ts +265 -0
- package/src/app/api/[locale]/system/help/interactive/definition.ts +125 -0
- package/src/app/api/[locale]/system/help/interactive/i18n/de/index.ts +22 -0
- package/src/app/api/[locale]/system/help/interactive/i18n/en/index.ts +19 -0
- package/src/app/api/[locale]/system/help/interactive/i18n/pl/index.ts +22 -0
- package/src/app/api/[locale]/system/help/interactive/repository.ts +1025 -0
- package/src/app/api/[locale]/system/help/interactive/route.ts +53 -0
- package/src/app/api/[locale]/system/help/list/definition.ts +372 -0
- package/src/app/api/[locale]/system/help/list/repository.ts +110 -0
- package/src/app/api/[locale]/system/help/list/route.ts +21 -0
- package/src/app/api/[locale]/system/help/repository.ts +212 -0
- package/src/app/api/[locale]/system/help/route.ts +16 -0
- package/src/app/api/[locale]/system/i18n/de/index.ts +68 -0
- package/src/app/api/[locale]/system/i18n/en/index.ts +65 -0
- package/src/app/api/[locale]/system/i18n/pl/index.ts +66 -0
- package/src/app/api/[locale]/system/release-tool/definition.ts +3104 -0
- package/src/app/api/[locale]/system/release-tool/i18n/de/index.ts +813 -0
- package/src/app/api/[locale]/system/release-tool/i18n/en/index.ts +797 -0
- package/src/app/api/[locale]/system/release-tool/i18n/pl/index.ts +810 -0
- package/src/app/api/[locale]/system/release-tool/repository/asset-zipper.ts +128 -0
- package/src/app/api/[locale]/system/release-tool/repository/changelog-generator.ts +212 -0
- package/src/app/api/[locale]/system/release-tool/repository/ci-detector.ts +566 -0
- package/src/app/api/[locale]/system/release-tool/repository/config.ts +113 -0
- package/src/app/api/[locale]/system/release-tool/repository/constants.ts +407 -0
- package/src/app/api/[locale]/system/release-tool/repository/dependency-manager.ts +527 -0
- package/src/app/api/[locale]/system/release-tool/repository/git-service.ts +403 -0
- package/src/app/api/[locale]/system/release-tool/repository/hook-runner.ts +100 -0
- package/src/app/api/[locale]/system/release-tool/repository/index.ts +1 -0
- package/src/app/api/[locale]/system/release-tool/repository/notification-service.ts +638 -0
- package/src/app/api/[locale]/system/release-tool/repository/package-service.ts +169 -0
- package/src/app/api/[locale]/system/release-tool/repository/publisher.ts +253 -0
- package/src/app/api/[locale]/system/release-tool/repository/quality-runner.ts +428 -0
- package/src/app/api/[locale]/system/release-tool/repository/release-creator.ts +293 -0
- package/src/app/api/[locale]/system/release-tool/repository/release-executor.ts +1198 -0
- package/src/app/api/[locale]/system/release-tool/repository/snyk-service.ts +136 -0
- package/src/app/api/[locale]/system/release-tool/repository/utils.ts +642 -0
- package/src/app/api/[locale]/system/release-tool/repository/validation.ts +288 -0
- package/src/app/api/[locale]/system/release-tool/repository/version-service.ts +297 -0
- package/src/app/api/[locale]/system/release-tool/route.ts +21 -0
- package/src/app/api/[locale]/system/unified-interface/README.md +328 -0
- package/src/app/api/[locale]/system/unified-interface/cli/README.md +349 -0
- package/src/app/api/[locale]/system/unified-interface/cli/auth/cli-handler.ts +95 -0
- package/src/app/api/[locale]/system/unified-interface/cli/auth/cli-user.ts +146 -0
- package/src/app/api/[locale]/system/unified-interface/cli/auth/session-file.ts +266 -0
- package/src/app/api/[locale]/system/unified-interface/cli/env.ts +26 -0
- package/src/app/api/[locale]/system/unified-interface/cli/i18n/de/index.ts +157 -0
- package/src/app/api/[locale]/system/unified-interface/cli/i18n/en/index.ts +155 -0
- package/src/app/api/[locale]/system/unified-interface/cli/i18n/pl/index.ts +158 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/debug.ts +595 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/entry-point.ts +129 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/environment.ts +155 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/execution-errors.ts +452 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/parsing.ts +297 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/route-executor.ts +859 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/i18n/de/index.ts +12 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/i18n/en/index.ts +11 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/i18n/pl/index.ts +12 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/definition.ts +262 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/repository.ts +421 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/route.ts +25 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/definition.ts +181 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/i18n/de/index.ts +61 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/i18n/en/index.ts +59 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/i18n/pl/index.ts +61 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/repository.ts +195 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/route.ts +22 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/definition.ts +188 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/repository.ts +209 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/route.ts +24 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/definition.ts +200 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/repository.ts +113 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/route.ts +22 -0
- package/src/app/api/[locale]/system/unified-interface/cli/vibe-runtime.ts +304 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/core/base-renderer.ts +270 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/core/registry.ts +309 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/core/types.ts +126 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/i18n/de/index.ts +67 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/i18n/en/index.ts +65 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/i18n/pl/index.ts +67 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/accordion.ts +74 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/avatar.ts +39 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/badge.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-output.ts +298 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-quality-files.ts +89 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-quality-list.ts +298 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-quality-summary.ts +96 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/container.ts +186 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-card.ts +65 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-cards.ts +570 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-list.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-table.ts +385 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/editable-text.ts +99 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/empty-state.ts +55 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/errors.ts +67 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/grouped-list.ts +729 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/link-card.ts +87 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/link-list.ts +112 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/link.ts +59 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/loading.ts +50 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/markdown.ts +131 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/metric.ts +291 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/section.ts +120 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/stats-grid.ts +149 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/tabs.ts +61 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/text.ts +78 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/title.ts +42 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/renderers/response-renderer.ts +418 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/renderers/schema-handler.ts +534 -0
- package/src/app/api/[locale]/system/unified-interface/i18n/de/index.ts +42 -0
- package/src/app/api/[locale]/system/unified-interface/i18n/en/index.ts +40 -0
- package/src/app/api/[locale]/system/unified-interface/i18n/pl/index.ts +43 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/README.md +114 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/converter.ts +146 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/i18n/de/index.ts +182 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/i18n/en/index.ts +179 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/i18n/pl/index.ts +181 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/registry.ts +343 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/serve/definition.ts +147 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/serve/repository.ts +38 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/serve/route.ts +14 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/server/protocol-handler.ts +309 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/server/server.ts +154 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/server/stdio-transport.ts +193 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/types.ts +246 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/create-form.ts +1510 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/create.ts +581 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/endpoint-to-metadata.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/loader.ts +152 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definitions/registry.ts +265 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/permissions/registry.ts +680 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/executor.ts +220 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/handler.ts +325 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/multi.ts +184 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/request-validator.ts +201 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/single.ts +58 -0
- package/src/app/api/[locale]/system/unified-interface/shared/env/define-env-client.ts +49 -0
- package/src/app/api/[locale]/system/unified-interface/shared/env/define-env.ts +47 -0
- package/src/app/api/[locale]/system/unified-interface/shared/env/validation-logger.ts +58 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/enum.ts +110 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/specialized.ts +339 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/utils.test.ts +408 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/utils.ts +1349 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field-config/endpoint-field-types.ts +107 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field-config/field-config-types.ts +268 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/colors.ts +114 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/endpoint.ts +169 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/file-logger.ts +88 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/formatters.ts +177 -0
- package/src/app/api/[locale]/system/unified-interface/shared/server-only/auth/base-auth-handler.ts +82 -0
- package/src/app/api/[locale]/system/unified-interface/shared/server-only/auth/factory.ts +33 -0
- package/src/app/api/[locale]/system/unified-interface/shared/server-only/server-only.ts +4 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/actions.ts +289 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/endpoint.ts +1167 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/enums.ts +382 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/platform.ts +34 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/types.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/ui-config.ts +76 -0
- package/src/app/api/[locale]/system/unified-interface/shared/utils/error-types.ts +27 -0
- package/src/app/api/[locale]/system/unified-interface/shared/utils/path.ts +63 -0
- package/src/app/api/[locale]/system/unified-interface/shared/utils/scanner.ts +241 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/actions.ts +256 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/configs.ts +1158 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/helpers.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/accordion.ts +82 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/avatar.ts +75 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/badge.ts +89 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/code-output.ts +302 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/code-quality-list.ts +202 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/container.ts +129 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-card.ts +81 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-cards.ts +258 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-list.ts +123 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-table.ts +387 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/editable-text.ts +89 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/empty-state.ts +78 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/errors.ts +93 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/grouped-list.ts +448 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/index.ts +38 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/link-card.ts +130 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/link-list.ts +127 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/link.ts +68 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/loading.ts +81 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/markdown.ts +176 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/metric-card.ts +241 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/section.ts +90 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/stats-grid.ts +71 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/tabs.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/text.ts +105 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/title.ts +72 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/types.ts +240 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/field-helpers.ts +137 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/formatting.ts +437 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/url.ts +40 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/widget-helpers.ts +465 -0
- package/src/app/api/[locale]/user/auth/enum.ts +16 -0
- package/src/app/api/[locale]/user/auth/i18n/de/index.ts +227 -0
- package/src/app/api/[locale]/user/auth/i18n/en/index.ts +205 -0
- package/src/app/api/[locale]/user/auth/i18n/pl/index.ts +219 -0
- package/src/app/api/[locale]/user/auth/types.ts +110 -0
- package/src/app/api/[locale]/user/enum.ts +64 -0
- package/src/app/api/[locale]/user/private/i18n/de/index.ts +3 -0
- package/src/app/api/[locale]/user/private/i18n/en/index.ts +1 -0
- package/src/app/api/[locale]/user/private/i18n/pl/index.ts +3 -0
- package/src/app/api/[locale]/user/types.ts +118 -0
- package/src/app/api/[locale]/user/user-roles/enum.ts +112 -0
- package/src/app/api/[locale]/user/user-roles/i18n/de/index.ts +85 -0
- package/src/app/api/[locale]/user/user-roles/i18n/en/index.ts +83 -0
- package/src/app/api/[locale]/user/user-roles/i18n/pl/index.ts +86 -0
- package/src/app/api/[locale]/user/user-roles/types.ts +34 -0
- package/src/app/api/i18n/de/index.ts +6 -0
- package/src/app/api/i18n/en/index.ts +5 -0
- package/src/app/api/i18n/pl/index.ts +5 -0
- package/src/app/i18n/de/index.ts +6 -0
- package/src/app/i18n/en/index.ts +5 -0
- package/src/app/i18n/pl/index.ts +5 -0
package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/create-form.ts
ADDED
|
@@ -0,0 +1,1510 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Form Endpoint Utility
|
|
3
|
+
*
|
|
4
|
+
* Utility for creating DRY form endpoints that support both GET and POST methods:
|
|
5
|
+
* - GET: Fetches initial/current data (response-only fields)
|
|
6
|
+
* - POST: Sends changed data, returns updated data (request+response fields)
|
|
7
|
+
*
|
|
8
|
+
* This eliminates duplication between GET and POST endpoints that share the same data structure.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
ExamplesList,
|
|
15
|
+
ExtractInput,
|
|
16
|
+
ExtractOutput,
|
|
17
|
+
FieldUsageConfig,
|
|
18
|
+
InferInputFromFieldForMethod,
|
|
19
|
+
InferOutputFromFieldForMethod,
|
|
20
|
+
InferSchemaFromFieldForMethod,
|
|
21
|
+
ObjectField,
|
|
22
|
+
PrimitiveField,
|
|
23
|
+
UnifiedField,
|
|
24
|
+
} from "@/app/api/[locale]/system/unified-interface/shared/types/endpoint";
|
|
25
|
+
import type { EndpointErrorTypes } from "@/app/api/[locale]/system/unified-interface/shared/types/enums";
|
|
26
|
+
import {
|
|
27
|
+
FieldUsage,
|
|
28
|
+
Methods,
|
|
29
|
+
} from "@/app/api/[locale]/system/unified-interface/shared/types/enums";
|
|
30
|
+
import type { WidgetConfig } from "@/app/api/[locale]/system/unified-interface/shared/widgets/configs";
|
|
31
|
+
import {
|
|
32
|
+
UserRole,
|
|
33
|
+
type UserRoleValue,
|
|
34
|
+
} from "@/app/api/[locale]/user/user-roles/enum";
|
|
35
|
+
|
|
36
|
+
import { type CreateApiEndpoint } from "./create";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for a single method in a form endpoint
|
|
40
|
+
*/
|
|
41
|
+
export interface FormMethodConfig<TScopedTranslationKey extends string> {
|
|
42
|
+
readonly title: TScopedTranslationKey;
|
|
43
|
+
readonly description: TScopedTranslationKey;
|
|
44
|
+
readonly tags: TScopedTranslationKey[];
|
|
45
|
+
readonly icon: string;
|
|
46
|
+
readonly aliases?: string[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Examples configuration for form endpoints
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Cache schemas for a method to avoid repeated evaluation
|
|
54
|
+
*/
|
|
55
|
+
export interface CachedMethodSchemas<
|
|
56
|
+
TScopedTranslationKey extends string,
|
|
57
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
58
|
+
TMethod extends Methods,
|
|
59
|
+
> {
|
|
60
|
+
requestData: InferSchemaFromFieldForMethod<
|
|
61
|
+
TScopedTranslationKey,
|
|
62
|
+
TFields,
|
|
63
|
+
TMethod,
|
|
64
|
+
FieldUsage.RequestData
|
|
65
|
+
>;
|
|
66
|
+
response: InferSchemaFromFieldForMethod<
|
|
67
|
+
TScopedTranslationKey,
|
|
68
|
+
TFields,
|
|
69
|
+
TMethod,
|
|
70
|
+
FieldUsage.Response
|
|
71
|
+
>;
|
|
72
|
+
urlParams: InferSchemaFromFieldForMethod<
|
|
73
|
+
TScopedTranslationKey,
|
|
74
|
+
TFields,
|
|
75
|
+
TMethod,
|
|
76
|
+
FieldUsage.RequestUrlParams
|
|
77
|
+
>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Build examples structure from cached schemas
|
|
82
|
+
*/
|
|
83
|
+
export interface MethodExamples<
|
|
84
|
+
TSchemas extends CachedMethodSchemas<
|
|
85
|
+
string,
|
|
86
|
+
UnifiedField<string, z.ZodTypeAny>,
|
|
87
|
+
Methods
|
|
88
|
+
>,
|
|
89
|
+
TExampleKey extends string,
|
|
90
|
+
> {
|
|
91
|
+
requests?: ExtractInput<TSchemas["requestData"]> extends never
|
|
92
|
+
? undefined
|
|
93
|
+
: ExamplesList<ExtractInput<TSchemas["requestData"]>, TExampleKey>;
|
|
94
|
+
responses: ExamplesList<ExtractOutput<TSchemas["response"]>, TExampleKey>;
|
|
95
|
+
urlPathParams?: ExtractInput<TSchemas["urlParams"]> extends never
|
|
96
|
+
? undefined
|
|
97
|
+
: ExamplesList<ExtractInput<TSchemas["urlParams"]>, TExampleKey>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* FormExamples - inlines the full structure to avoid intermediate type depth
|
|
102
|
+
*/
|
|
103
|
+
// oxlint-disable-next-line consistent-type-definitions
|
|
104
|
+
export type FormExamples<
|
|
105
|
+
TScopedTranslationKey extends string,
|
|
106
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
107
|
+
TExampleKey extends string,
|
|
108
|
+
TMethods extends {
|
|
109
|
+
GET?: FormMethodConfig<TScopedTranslationKey>;
|
|
110
|
+
POST?: FormMethodConfig<TScopedTranslationKey>;
|
|
111
|
+
PATCH?: FormMethodConfig<TScopedTranslationKey>;
|
|
112
|
+
DELETE?: FormMethodConfig<TScopedTranslationKey>;
|
|
113
|
+
} = {
|
|
114
|
+
GET?: FormMethodConfig<TScopedTranslationKey>;
|
|
115
|
+
POST?: FormMethodConfig<TScopedTranslationKey>;
|
|
116
|
+
PATCH?: FormMethodConfig<TScopedTranslationKey>;
|
|
117
|
+
DELETE?: FormMethodConfig<TScopedTranslationKey>;
|
|
118
|
+
},
|
|
119
|
+
> = {
|
|
120
|
+
GET?: "GET" extends keyof TMethods
|
|
121
|
+
? {
|
|
122
|
+
requests?: ExtractInput<
|
|
123
|
+
InferSchemaFromFieldForMethod<
|
|
124
|
+
TScopedTranslationKey,
|
|
125
|
+
TFields,
|
|
126
|
+
Methods.GET,
|
|
127
|
+
FieldUsage.RequestData
|
|
128
|
+
>
|
|
129
|
+
> extends never
|
|
130
|
+
? undefined
|
|
131
|
+
: ExamplesList<
|
|
132
|
+
ExtractInput<
|
|
133
|
+
InferSchemaFromFieldForMethod<
|
|
134
|
+
TScopedTranslationKey,
|
|
135
|
+
TFields,
|
|
136
|
+
Methods.GET,
|
|
137
|
+
FieldUsage.RequestData
|
|
138
|
+
>
|
|
139
|
+
>,
|
|
140
|
+
TExampleKey
|
|
141
|
+
>;
|
|
142
|
+
responses: ExamplesList<
|
|
143
|
+
ExtractOutput<
|
|
144
|
+
InferSchemaFromFieldForMethod<
|
|
145
|
+
TScopedTranslationKey,
|
|
146
|
+
TFields,
|
|
147
|
+
Methods.GET,
|
|
148
|
+
FieldUsage.Response
|
|
149
|
+
>
|
|
150
|
+
>,
|
|
151
|
+
TExampleKey
|
|
152
|
+
>;
|
|
153
|
+
urlPathParams?: ExtractInput<
|
|
154
|
+
InferSchemaFromFieldForMethod<
|
|
155
|
+
TScopedTranslationKey,
|
|
156
|
+
TFields,
|
|
157
|
+
Methods.GET,
|
|
158
|
+
FieldUsage.RequestUrlParams
|
|
159
|
+
>
|
|
160
|
+
> extends never
|
|
161
|
+
? undefined
|
|
162
|
+
: ExamplesList<
|
|
163
|
+
ExtractInput<
|
|
164
|
+
InferSchemaFromFieldForMethod<
|
|
165
|
+
TScopedTranslationKey,
|
|
166
|
+
TFields,
|
|
167
|
+
Methods.GET,
|
|
168
|
+
FieldUsage.RequestUrlParams
|
|
169
|
+
>
|
|
170
|
+
>,
|
|
171
|
+
TExampleKey
|
|
172
|
+
>;
|
|
173
|
+
}
|
|
174
|
+
: never;
|
|
175
|
+
POST?: "POST" extends keyof TMethods
|
|
176
|
+
? {
|
|
177
|
+
requests?: ExtractInput<
|
|
178
|
+
InferSchemaFromFieldForMethod<
|
|
179
|
+
TScopedTranslationKey,
|
|
180
|
+
TFields,
|
|
181
|
+
Methods.POST,
|
|
182
|
+
FieldUsage.RequestData
|
|
183
|
+
>
|
|
184
|
+
> extends never
|
|
185
|
+
? undefined
|
|
186
|
+
: ExamplesList<
|
|
187
|
+
ExtractInput<
|
|
188
|
+
InferSchemaFromFieldForMethod<
|
|
189
|
+
TScopedTranslationKey,
|
|
190
|
+
TFields,
|
|
191
|
+
Methods.POST,
|
|
192
|
+
FieldUsage.RequestData
|
|
193
|
+
>
|
|
194
|
+
>,
|
|
195
|
+
TExampleKey
|
|
196
|
+
>;
|
|
197
|
+
responses: ExamplesList<
|
|
198
|
+
ExtractOutput<
|
|
199
|
+
InferSchemaFromFieldForMethod<
|
|
200
|
+
TScopedTranslationKey,
|
|
201
|
+
TFields,
|
|
202
|
+
Methods.POST,
|
|
203
|
+
FieldUsage.Response
|
|
204
|
+
>
|
|
205
|
+
>,
|
|
206
|
+
TExampleKey
|
|
207
|
+
>;
|
|
208
|
+
urlPathParams?: ExtractInput<
|
|
209
|
+
InferSchemaFromFieldForMethod<
|
|
210
|
+
TScopedTranslationKey,
|
|
211
|
+
TFields,
|
|
212
|
+
Methods.POST,
|
|
213
|
+
FieldUsage.RequestUrlParams
|
|
214
|
+
>
|
|
215
|
+
> extends never
|
|
216
|
+
? undefined
|
|
217
|
+
: ExamplesList<
|
|
218
|
+
ExtractInput<
|
|
219
|
+
InferSchemaFromFieldForMethod<
|
|
220
|
+
TScopedTranslationKey,
|
|
221
|
+
TFields,
|
|
222
|
+
Methods.POST,
|
|
223
|
+
FieldUsage.RequestUrlParams
|
|
224
|
+
>
|
|
225
|
+
>,
|
|
226
|
+
TExampleKey
|
|
227
|
+
>;
|
|
228
|
+
}
|
|
229
|
+
: never;
|
|
230
|
+
PATCH?: "PATCH" extends keyof TMethods
|
|
231
|
+
? {
|
|
232
|
+
requests?: ExtractInput<
|
|
233
|
+
InferSchemaFromFieldForMethod<
|
|
234
|
+
TScopedTranslationKey,
|
|
235
|
+
TFields,
|
|
236
|
+
Methods.PATCH,
|
|
237
|
+
FieldUsage.RequestData
|
|
238
|
+
>
|
|
239
|
+
> extends never
|
|
240
|
+
? undefined
|
|
241
|
+
: ExamplesList<
|
|
242
|
+
ExtractInput<
|
|
243
|
+
InferSchemaFromFieldForMethod<
|
|
244
|
+
TScopedTranslationKey,
|
|
245
|
+
TFields,
|
|
246
|
+
Methods.PATCH,
|
|
247
|
+
FieldUsage.RequestData
|
|
248
|
+
>
|
|
249
|
+
>,
|
|
250
|
+
TExampleKey
|
|
251
|
+
>;
|
|
252
|
+
responses: ExamplesList<
|
|
253
|
+
ExtractOutput<
|
|
254
|
+
InferSchemaFromFieldForMethod<
|
|
255
|
+
TScopedTranslationKey,
|
|
256
|
+
TFields,
|
|
257
|
+
Methods.PATCH,
|
|
258
|
+
FieldUsage.Response
|
|
259
|
+
>
|
|
260
|
+
>,
|
|
261
|
+
TExampleKey
|
|
262
|
+
>;
|
|
263
|
+
urlPathParams?: ExtractInput<
|
|
264
|
+
InferSchemaFromFieldForMethod<
|
|
265
|
+
TScopedTranslationKey,
|
|
266
|
+
TFields,
|
|
267
|
+
Methods.PATCH,
|
|
268
|
+
FieldUsage.RequestUrlParams
|
|
269
|
+
>
|
|
270
|
+
> extends never
|
|
271
|
+
? undefined
|
|
272
|
+
: ExamplesList<
|
|
273
|
+
ExtractInput<
|
|
274
|
+
InferSchemaFromFieldForMethod<
|
|
275
|
+
TScopedTranslationKey,
|
|
276
|
+
TFields,
|
|
277
|
+
Methods.PATCH,
|
|
278
|
+
FieldUsage.RequestUrlParams
|
|
279
|
+
>
|
|
280
|
+
>,
|
|
281
|
+
TExampleKey
|
|
282
|
+
>;
|
|
283
|
+
}
|
|
284
|
+
: never;
|
|
285
|
+
DELETE?: "DELETE" extends keyof TMethods
|
|
286
|
+
? {
|
|
287
|
+
requests?: ExtractInput<
|
|
288
|
+
InferSchemaFromFieldForMethod<
|
|
289
|
+
TScopedTranslationKey,
|
|
290
|
+
TFields,
|
|
291
|
+
Methods.DELETE,
|
|
292
|
+
FieldUsage.RequestData
|
|
293
|
+
>
|
|
294
|
+
> extends never
|
|
295
|
+
? undefined
|
|
296
|
+
: ExamplesList<
|
|
297
|
+
ExtractInput<
|
|
298
|
+
InferSchemaFromFieldForMethod<
|
|
299
|
+
TScopedTranslationKey,
|
|
300
|
+
TFields,
|
|
301
|
+
Methods.DELETE,
|
|
302
|
+
FieldUsage.RequestData
|
|
303
|
+
>
|
|
304
|
+
>,
|
|
305
|
+
TExampleKey
|
|
306
|
+
>;
|
|
307
|
+
responses: ExamplesList<
|
|
308
|
+
ExtractOutput<
|
|
309
|
+
InferSchemaFromFieldForMethod<
|
|
310
|
+
TScopedTranslationKey,
|
|
311
|
+
TFields,
|
|
312
|
+
Methods.DELETE,
|
|
313
|
+
FieldUsage.Response
|
|
314
|
+
>
|
|
315
|
+
>,
|
|
316
|
+
TExampleKey
|
|
317
|
+
>;
|
|
318
|
+
urlPathParams?: ExtractInput<
|
|
319
|
+
InferSchemaFromFieldForMethod<
|
|
320
|
+
TScopedTranslationKey,
|
|
321
|
+
TFields,
|
|
322
|
+
Methods.DELETE,
|
|
323
|
+
FieldUsage.RequestUrlParams
|
|
324
|
+
>
|
|
325
|
+
> extends never
|
|
326
|
+
? undefined
|
|
327
|
+
: ExamplesList<
|
|
328
|
+
ExtractInput<
|
|
329
|
+
InferSchemaFromFieldForMethod<
|
|
330
|
+
TScopedTranslationKey,
|
|
331
|
+
TFields,
|
|
332
|
+
Methods.DELETE,
|
|
333
|
+
FieldUsage.RequestUrlParams
|
|
334
|
+
>
|
|
335
|
+
>,
|
|
336
|
+
TExampleKey
|
|
337
|
+
>;
|
|
338
|
+
}
|
|
339
|
+
: never;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Configuration for creating a form endpoint with GET, POST, PATCH, and DELETE methods
|
|
344
|
+
*/
|
|
345
|
+
export interface CreateFormEndpointConfig<
|
|
346
|
+
TScopedTranslationKey extends string,
|
|
347
|
+
TExampleKey extends string,
|
|
348
|
+
TUserRoleValue extends readonly UserRoleValue[],
|
|
349
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
350
|
+
TMethods extends {
|
|
351
|
+
GET?: FormMethodConfig<TScopedTranslationKey>;
|
|
352
|
+
POST?: FormMethodConfig<TScopedTranslationKey>;
|
|
353
|
+
PATCH?: FormMethodConfig<TScopedTranslationKey>;
|
|
354
|
+
DELETE?: FormMethodConfig<TScopedTranslationKey>;
|
|
355
|
+
},
|
|
356
|
+
> {
|
|
357
|
+
// Shared configuration
|
|
358
|
+
readonly path: readonly string[];
|
|
359
|
+
readonly category: NoInfer<TScopedTranslationKey>;
|
|
360
|
+
readonly allowedRoles: TUserRoleValue;
|
|
361
|
+
|
|
362
|
+
readonly debug?: boolean;
|
|
363
|
+
|
|
364
|
+
// Method-specific configuration
|
|
365
|
+
readonly methods: TMethods;
|
|
366
|
+
|
|
367
|
+
// Shared field definitions - will be automatically adapted for each method
|
|
368
|
+
readonly fields: TFields;
|
|
369
|
+
|
|
370
|
+
// Shared error and success configuration
|
|
371
|
+
readonly errorTypes: Record<
|
|
372
|
+
EndpointErrorTypes,
|
|
373
|
+
{
|
|
374
|
+
title: NoInfer<TScopedTranslationKey>;
|
|
375
|
+
description: NoInfer<TScopedTranslationKey>;
|
|
376
|
+
}
|
|
377
|
+
>;
|
|
378
|
+
readonly successTypes: {
|
|
379
|
+
title: NoInfer<TScopedTranslationKey>;
|
|
380
|
+
description: NoInfer<TScopedTranslationKey>;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// Method-specific examples
|
|
384
|
+
readonly examples: NoInfer<
|
|
385
|
+
FormExamples<TScopedTranslationKey, TFields, TExampleKey, TMethods>
|
|
386
|
+
>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ============================================================================
|
|
390
|
+
// METHOD-SPECIFIC TYPE FILTERING
|
|
391
|
+
// ============================================================================
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Enhanced usage matching that supports both old format and method-specific format
|
|
395
|
+
*/
|
|
396
|
+
type SupportsMethodAndUsage<
|
|
397
|
+
TUsage extends FieldUsageConfig,
|
|
398
|
+
TMethod extends Methods,
|
|
399
|
+
TTargetUsage extends FieldUsage,
|
|
400
|
+
> =
|
|
401
|
+
// Check if it's method-specific format first
|
|
402
|
+
TMethod extends keyof TUsage
|
|
403
|
+
? TUsage[TMethod] extends infer TMethodUsage
|
|
404
|
+
? TTargetUsage extends FieldUsage.RequestData
|
|
405
|
+
? TMethodUsage extends { request: "data" | "data&urlPathParams" }
|
|
406
|
+
? true
|
|
407
|
+
: false
|
|
408
|
+
: TTargetUsage extends FieldUsage.RequestUrlParams
|
|
409
|
+
? TMethodUsage extends {
|
|
410
|
+
request: "urlPathParams" | "data&urlPathParams";
|
|
411
|
+
}
|
|
412
|
+
? true
|
|
413
|
+
: false
|
|
414
|
+
: TTargetUsage extends FieldUsage.Response
|
|
415
|
+
? TMethodUsage extends { response: true }
|
|
416
|
+
? true
|
|
417
|
+
: false
|
|
418
|
+
: false
|
|
419
|
+
: false
|
|
420
|
+
: // Fall back to original logic for backward compatibility
|
|
421
|
+
TTargetUsage extends FieldUsage.RequestData
|
|
422
|
+
? TUsage extends { request: "data" | "data&urlPathParams" }
|
|
423
|
+
? true
|
|
424
|
+
: false
|
|
425
|
+
: TTargetUsage extends FieldUsage.RequestUrlParams
|
|
426
|
+
? TUsage extends { request: "urlPathParams" | "data&urlPathParams" }
|
|
427
|
+
? true
|
|
428
|
+
: false
|
|
429
|
+
: TTargetUsage extends FieldUsage.Response
|
|
430
|
+
? TUsage extends { response: true }
|
|
431
|
+
? true
|
|
432
|
+
: false
|
|
433
|
+
: false;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Filter schema for a specific method and usage type
|
|
437
|
+
*/
|
|
438
|
+
export type FilterSchemaForMethod<
|
|
439
|
+
TScopedTranslationKey extends string,
|
|
440
|
+
TFields,
|
|
441
|
+
TTargetUsage extends FieldUsage,
|
|
442
|
+
TMethod extends Methods,
|
|
443
|
+
> =
|
|
444
|
+
TFields extends PrimitiveField<
|
|
445
|
+
infer TSchema,
|
|
446
|
+
FieldUsageConfig,
|
|
447
|
+
TScopedTranslationKey,
|
|
448
|
+
WidgetConfig<TScopedTranslationKey>
|
|
449
|
+
>
|
|
450
|
+
? SupportsMethodAndUsage<
|
|
451
|
+
TFields["usage"],
|
|
452
|
+
TMethod,
|
|
453
|
+
TTargetUsage
|
|
454
|
+
> extends true
|
|
455
|
+
? TSchema
|
|
456
|
+
: z.ZodNever
|
|
457
|
+
: TFields extends ObjectField<
|
|
458
|
+
infer TChildren,
|
|
459
|
+
FieldUsageConfig,
|
|
460
|
+
TScopedTranslationKey,
|
|
461
|
+
WidgetConfig<TScopedTranslationKey>
|
|
462
|
+
>
|
|
463
|
+
? SupportsMethodAndUsage<
|
|
464
|
+
TFields["usage"],
|
|
465
|
+
TMethod,
|
|
466
|
+
TTargetUsage
|
|
467
|
+
> extends true
|
|
468
|
+
? z.ZodObject<{
|
|
469
|
+
[K in keyof TChildren as FilterSchemaForMethod<
|
|
470
|
+
TScopedTranslationKey,
|
|
471
|
+
TChildren[K],
|
|
472
|
+
TTargetUsage,
|
|
473
|
+
TMethod
|
|
474
|
+
> extends z.ZodNever
|
|
475
|
+
? never
|
|
476
|
+
: K]: FilterSchemaForMethod<
|
|
477
|
+
TScopedTranslationKey,
|
|
478
|
+
TChildren[K],
|
|
479
|
+
TTargetUsage,
|
|
480
|
+
TMethod
|
|
481
|
+
>;
|
|
482
|
+
}>
|
|
483
|
+
: z.ZodNever
|
|
484
|
+
: z.ZodNever;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Method-specific endpoint type that extends CreateApiEndpoint
|
|
488
|
+
* This ensures perfect type inference for each HTTP method and compatibility with hooks
|
|
489
|
+
*/
|
|
490
|
+
export type MethodSpecificEndpoint<
|
|
491
|
+
TExampleKey extends string,
|
|
492
|
+
TMethod extends Methods,
|
|
493
|
+
TUserRoleValue extends readonly UserRoleValue[],
|
|
494
|
+
TScopedTranslationKey extends string,
|
|
495
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
496
|
+
> = CreateApiEndpoint<
|
|
497
|
+
TExampleKey,
|
|
498
|
+
TMethod,
|
|
499
|
+
TUserRoleValue,
|
|
500
|
+
TScopedTranslationKey,
|
|
501
|
+
TFields,
|
|
502
|
+
// Override type parameters with method-specific inference
|
|
503
|
+
InferInputFromFieldForMethod<
|
|
504
|
+
TScopedTranslationKey,
|
|
505
|
+
TFields,
|
|
506
|
+
TMethod,
|
|
507
|
+
FieldUsage.RequestData
|
|
508
|
+
>,
|
|
509
|
+
InferOutputFromFieldForMethod<
|
|
510
|
+
TScopedTranslationKey,
|
|
511
|
+
TFields,
|
|
512
|
+
TMethod,
|
|
513
|
+
FieldUsage.RequestData
|
|
514
|
+
>,
|
|
515
|
+
InferInputFromFieldForMethod<
|
|
516
|
+
TScopedTranslationKey,
|
|
517
|
+
TFields,
|
|
518
|
+
TMethod,
|
|
519
|
+
FieldUsage.Response
|
|
520
|
+
>,
|
|
521
|
+
InferOutputFromFieldForMethod<
|
|
522
|
+
TScopedTranslationKey,
|
|
523
|
+
TFields,
|
|
524
|
+
TMethod,
|
|
525
|
+
FieldUsage.Response
|
|
526
|
+
>,
|
|
527
|
+
InferInputFromFieldForMethod<
|
|
528
|
+
TScopedTranslationKey,
|
|
529
|
+
TFields,
|
|
530
|
+
TMethod,
|
|
531
|
+
FieldUsage.RequestUrlParams
|
|
532
|
+
>,
|
|
533
|
+
InferOutputFromFieldForMethod<
|
|
534
|
+
TScopedTranslationKey,
|
|
535
|
+
TFields,
|
|
536
|
+
TMethod,
|
|
537
|
+
FieldUsage.RequestUrlParams
|
|
538
|
+
>
|
|
539
|
+
>;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Type Helper: Extract Request Schema from Fields for a specific Method
|
|
543
|
+
* Combines data fields + URL path params for a specific HTTP method
|
|
544
|
+
* Used for testing the request schema generation chain
|
|
545
|
+
*/
|
|
546
|
+
export type GetRequestSchemaFromFields<
|
|
547
|
+
TScopedTranslationKey extends string,
|
|
548
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
549
|
+
TMethod extends Methods,
|
|
550
|
+
> = z.ZodObject<{
|
|
551
|
+
data: InferSchemaFromFieldForMethod<
|
|
552
|
+
TScopedTranslationKey,
|
|
553
|
+
TFields,
|
|
554
|
+
TMethod,
|
|
555
|
+
FieldUsage.RequestData
|
|
556
|
+
>;
|
|
557
|
+
urlPathParams: InferSchemaFromFieldForMethod<
|
|
558
|
+
TScopedTranslationKey,
|
|
559
|
+
TFields,
|
|
560
|
+
TMethod,
|
|
561
|
+
FieldUsage.RequestUrlParams
|
|
562
|
+
>;
|
|
563
|
+
}>;
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Type Helper: Extract Response Schema from Fields for a specific Method
|
|
567
|
+
* Gets response-only fields for a specific HTTP method
|
|
568
|
+
* Used for testing the response schema generation chain
|
|
569
|
+
*/
|
|
570
|
+
export type GetResponseSchemaFromFields<
|
|
571
|
+
TScopedTranslationKey extends string,
|
|
572
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
573
|
+
TMethod extends Methods,
|
|
574
|
+
> = InferSchemaFromFieldForMethod<
|
|
575
|
+
TScopedTranslationKey,
|
|
576
|
+
TFields,
|
|
577
|
+
TMethod,
|
|
578
|
+
FieldUsage.Response
|
|
579
|
+
>;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Return type for createFormEndpoint - provides GET, POST, PATCH, and DELETE endpoints
|
|
583
|
+
* Uses method-specific type inference for perfect type safety
|
|
584
|
+
* Only includes methods that are actually defined in the config
|
|
585
|
+
*/
|
|
586
|
+
export type CreateFormEndpointReturn<
|
|
587
|
+
TExampleKey extends string,
|
|
588
|
+
TUserRoleValue extends readonly UserRoleValue[],
|
|
589
|
+
TScopedTranslationKey extends string,
|
|
590
|
+
TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
591
|
+
TMethods extends {
|
|
592
|
+
GET?: FormMethodConfig<TScopedTranslationKey>;
|
|
593
|
+
POST?: FormMethodConfig<TScopedTranslationKey>;
|
|
594
|
+
PATCH?: FormMethodConfig<TScopedTranslationKey>;
|
|
595
|
+
DELETE?: FormMethodConfig<TScopedTranslationKey>;
|
|
596
|
+
},
|
|
597
|
+
> = (TMethods["GET"] extends FormMethodConfig<string>
|
|
598
|
+
? {
|
|
599
|
+
GET: MethodSpecificEndpoint<
|
|
600
|
+
TExampleKey,
|
|
601
|
+
Methods.GET,
|
|
602
|
+
TUserRoleValue,
|
|
603
|
+
TScopedTranslationKey,
|
|
604
|
+
TFields
|
|
605
|
+
>;
|
|
606
|
+
}
|
|
607
|
+
: Record<string, never>) &
|
|
608
|
+
(TMethods["POST"] extends FormMethodConfig<string>
|
|
609
|
+
? {
|
|
610
|
+
POST: MethodSpecificEndpoint<
|
|
611
|
+
TExampleKey,
|
|
612
|
+
Methods.POST,
|
|
613
|
+
TUserRoleValue,
|
|
614
|
+
TScopedTranslationKey,
|
|
615
|
+
TFields
|
|
616
|
+
>;
|
|
617
|
+
}
|
|
618
|
+
: Record<string, never>) &
|
|
619
|
+
(TMethods["PATCH"] extends FormMethodConfig<string>
|
|
620
|
+
? {
|
|
621
|
+
PATCH: MethodSpecificEndpoint<
|
|
622
|
+
TExampleKey,
|
|
623
|
+
Methods.PATCH,
|
|
624
|
+
TUserRoleValue,
|
|
625
|
+
TScopedTranslationKey,
|
|
626
|
+
TFields
|
|
627
|
+
>;
|
|
628
|
+
}
|
|
629
|
+
: Record<string, never>) &
|
|
630
|
+
(TMethods["DELETE"] extends FormMethodConfig<string>
|
|
631
|
+
? {
|
|
632
|
+
DELETE: MethodSpecificEndpoint<
|
|
633
|
+
TExampleKey,
|
|
634
|
+
Methods.DELETE,
|
|
635
|
+
TUserRoleValue,
|
|
636
|
+
TScopedTranslationKey,
|
|
637
|
+
TFields
|
|
638
|
+
>;
|
|
639
|
+
}
|
|
640
|
+
: Record<string, never>);
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* ============================================================================
|
|
644
|
+
* TYPE EXTRACTION UTILITIES
|
|
645
|
+
* ============================================================================
|
|
646
|
+
*
|
|
647
|
+
* These utilities extract types from createFormEndpoint CONFIG (not return value).
|
|
648
|
+
* They work around TypeScript's cross-module typeof limitation by inferring types
|
|
649
|
+
* from the input config parameters instead of from the return value.
|
|
650
|
+
*
|
|
651
|
+
* Usage in definition files:
|
|
652
|
+
* ```typescript
|
|
653
|
+
* const config = { ... } as const;
|
|
654
|
+
* export const { GET, POST } = createFormEndpoint(config);
|
|
655
|
+
*
|
|
656
|
+
* // Extract types from CONFIG, not return value
|
|
657
|
+
* export type GetRequest = ExtractMethodRequestOutput<typeof config, "GET">;
|
|
658
|
+
* export type PostResponse = ExtractMethodResponseOutput<typeof config, "POST">;
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Extract the Config type from a createFormEndpoint call
|
|
664
|
+
*/
|
|
665
|
+
export type ExtractConfig<T> =
|
|
666
|
+
T extends CreateFormEndpointConfig<
|
|
667
|
+
infer TScopedTranslationKey,
|
|
668
|
+
infer TExampleKey,
|
|
669
|
+
infer TUserRoleValue,
|
|
670
|
+
infer TFields,
|
|
671
|
+
infer TMethods
|
|
672
|
+
>
|
|
673
|
+
? CreateFormEndpointConfig<
|
|
674
|
+
TScopedTranslationKey,
|
|
675
|
+
TExampleKey,
|
|
676
|
+
TUserRoleValue,
|
|
677
|
+
TFields,
|
|
678
|
+
TMethods
|
|
679
|
+
>
|
|
680
|
+
: never;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Extract RequestOutput type for a specific method from config
|
|
684
|
+
*/
|
|
685
|
+
export type ExtractMethodRequestOutput<
|
|
686
|
+
TConfig extends {
|
|
687
|
+
fields: UnifiedField<string, z.ZodTypeAny>;
|
|
688
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
689
|
+
methods: Record<string, any>;
|
|
690
|
+
},
|
|
691
|
+
TMethodKey extends "GET" | "POST" | "PATCH" | "DELETE",
|
|
692
|
+
> = TConfig extends { fields: infer TFields; methods: infer TMethods }
|
|
693
|
+
? TFields extends UnifiedField<infer TScopedTranslationKey, z.ZodTypeAny>
|
|
694
|
+
? TMethodKey extends keyof TMethods
|
|
695
|
+
? InferOutputFromFieldForMethod<
|
|
696
|
+
TScopedTranslationKey,
|
|
697
|
+
TFields,
|
|
698
|
+
TMethodKey extends "GET"
|
|
699
|
+
? Methods.GET
|
|
700
|
+
: TMethodKey extends "POST"
|
|
701
|
+
? Methods.POST
|
|
702
|
+
: TMethodKey extends "PATCH"
|
|
703
|
+
? Methods.PATCH
|
|
704
|
+
: Methods.DELETE,
|
|
705
|
+
FieldUsage.RequestData
|
|
706
|
+
>
|
|
707
|
+
: never
|
|
708
|
+
: never
|
|
709
|
+
: never;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Extract ResponseOutput type for a specific method from config
|
|
713
|
+
*/
|
|
714
|
+
export type ExtractMethodResponseOutput<
|
|
715
|
+
TConfig extends {
|
|
716
|
+
fields: UnifiedField<string, z.ZodTypeAny>;
|
|
717
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
718
|
+
methods: Record<string, any>;
|
|
719
|
+
},
|
|
720
|
+
TMethodKey extends "GET" | "POST" | "PATCH" | "DELETE",
|
|
721
|
+
> = TConfig extends { fields: infer TFields; methods: infer TMethods }
|
|
722
|
+
? TFields extends UnifiedField<infer TScopedTranslationKey, z.ZodTypeAny>
|
|
723
|
+
? TMethodKey extends keyof TMethods
|
|
724
|
+
? InferOutputFromFieldForMethod<
|
|
725
|
+
TScopedTranslationKey,
|
|
726
|
+
TFields,
|
|
727
|
+
TMethodKey extends "GET"
|
|
728
|
+
? Methods.GET
|
|
729
|
+
: TMethodKey extends "POST"
|
|
730
|
+
? Methods.POST
|
|
731
|
+
: TMethodKey extends "PATCH"
|
|
732
|
+
? Methods.PATCH
|
|
733
|
+
: Methods.DELETE,
|
|
734
|
+
FieldUsage.Response
|
|
735
|
+
>
|
|
736
|
+
: never
|
|
737
|
+
: never
|
|
738
|
+
: never;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Extract UrlVariablesOutput type for a specific method from config
|
|
742
|
+
*/
|
|
743
|
+
export type ExtractMethodUrlVariablesOutput<
|
|
744
|
+
TConfig extends {
|
|
745
|
+
fields: UnifiedField<string, z.ZodTypeAny>;
|
|
746
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
747
|
+
methods: Record<string, any>;
|
|
748
|
+
},
|
|
749
|
+
TMethodKey extends "GET" | "POST" | "PATCH" | "DELETE",
|
|
750
|
+
> = TConfig extends { fields: infer TFields; methods: infer TMethods }
|
|
751
|
+
? TFields extends UnifiedField<infer TScopedTranslationKey, z.ZodTypeAny>
|
|
752
|
+
? TMethodKey extends keyof TMethods
|
|
753
|
+
? InferOutputFromFieldForMethod<
|
|
754
|
+
TScopedTranslationKey,
|
|
755
|
+
TFields,
|
|
756
|
+
TMethodKey extends "GET"
|
|
757
|
+
? Methods.GET
|
|
758
|
+
: TMethodKey extends "POST"
|
|
759
|
+
? Methods.POST
|
|
760
|
+
: TMethodKey extends "PATCH"
|
|
761
|
+
? Methods.PATCH
|
|
762
|
+
: Methods.DELETE,
|
|
763
|
+
FieldUsage.RequestUrlParams
|
|
764
|
+
>
|
|
765
|
+
: never
|
|
766
|
+
: never
|
|
767
|
+
: never;
|
|
768
|
+
|
|
769
|
+
// ============================================================================
|
|
770
|
+
// METHOD-SPECIFIC SCHEMA GENERATORS
|
|
771
|
+
// ============================================================================
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Transform method-specific field to simple field for a specific method
|
|
775
|
+
* This converts fields with method-specific usage to simple usage patterns
|
|
776
|
+
* @deprecated - Replaced by generateSchemaForMethodAndUsage
|
|
777
|
+
* Note: This function is used recursively within itself
|
|
778
|
+
*/
|
|
779
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
780
|
+
function transformFieldForMethod<F>(field: F, method: Methods): F {
|
|
781
|
+
interface FieldWithType {
|
|
782
|
+
type: "primitive" | "object" | "array";
|
|
783
|
+
usage?: FieldUsageConfig;
|
|
784
|
+
children?: Record<string, UnifiedField<string, z.ZodTypeAny>>;
|
|
785
|
+
child?: UnifiedField<string, z.ZodTypeAny>;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
const typedField = field as F & FieldWithType;
|
|
789
|
+
|
|
790
|
+
if (typedField.type === "primitive") {
|
|
791
|
+
// Check if field has method-specific usage
|
|
792
|
+
if (typedField.usage && isMethodSpecificUsage(typedField.usage)) {
|
|
793
|
+
const methodSpecificUsage = typedField.usage as Record<
|
|
794
|
+
string,
|
|
795
|
+
{
|
|
796
|
+
request?: "data" | "urlPathParams" | "data&urlPathParams";
|
|
797
|
+
response?: boolean;
|
|
798
|
+
}
|
|
799
|
+
>;
|
|
800
|
+
const methodUsage = methodSpecificUsage[method];
|
|
801
|
+
if (!methodUsage) {
|
|
802
|
+
// Method not supported for this field - return field with empty usage that will result in z.never()
|
|
803
|
+
return {
|
|
804
|
+
...field,
|
|
805
|
+
usage: {},
|
|
806
|
+
} as F;
|
|
807
|
+
}
|
|
808
|
+
return {
|
|
809
|
+
...field,
|
|
810
|
+
usage: methodUsage,
|
|
811
|
+
} as F;
|
|
812
|
+
}
|
|
813
|
+
// Return field with original usage (might be simple usage)
|
|
814
|
+
return field;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (typedField.type === "object") {
|
|
818
|
+
// Transform object field usage
|
|
819
|
+
let objectUsage = typedField.usage;
|
|
820
|
+
if (typedField.usage && isMethodSpecificUsage(typedField.usage)) {
|
|
821
|
+
const methodSpecificUsage = typedField.usage as Record<
|
|
822
|
+
string,
|
|
823
|
+
{
|
|
824
|
+
request?: "data" | "urlPathParams" | "data&urlPathParams";
|
|
825
|
+
response?: boolean;
|
|
826
|
+
}
|
|
827
|
+
>;
|
|
828
|
+
const methodUsage = methodSpecificUsage[method];
|
|
829
|
+
if (!methodUsage) {
|
|
830
|
+
// Method not supported for this object - use empty usage
|
|
831
|
+
objectUsage = {};
|
|
832
|
+
} else {
|
|
833
|
+
objectUsage = methodUsage as FieldUsageConfig;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// Transform all children recursively
|
|
838
|
+
const transformedChildren: Record<
|
|
839
|
+
string,
|
|
840
|
+
UnifiedField<string, z.ZodTypeAny>
|
|
841
|
+
> = {};
|
|
842
|
+
if (typedField.children) {
|
|
843
|
+
for (const [key, childField] of Object.entries(typedField.children)) {
|
|
844
|
+
transformedChildren[key] = transformFieldForMethod(childField, method);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
return {
|
|
849
|
+
...field,
|
|
850
|
+
usage: objectUsage,
|
|
851
|
+
children: transformedChildren,
|
|
852
|
+
} as F;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (typedField.type === "array") {
|
|
856
|
+
// Transform array field usage
|
|
857
|
+
let arrayUsage = typedField.usage;
|
|
858
|
+
if (typedField.usage && isMethodSpecificUsage(typedField.usage)) {
|
|
859
|
+
const methodSpecificUsage = typedField.usage as Record<
|
|
860
|
+
string,
|
|
861
|
+
{
|
|
862
|
+
request?: "data" | "urlPathParams" | "data&urlPathParams";
|
|
863
|
+
response?: boolean;
|
|
864
|
+
}
|
|
865
|
+
>;
|
|
866
|
+
const methodUsage = methodSpecificUsage[method];
|
|
867
|
+
if (!methodUsage) {
|
|
868
|
+
// Method not supported for this array - use empty usage
|
|
869
|
+
arrayUsage = {};
|
|
870
|
+
} else {
|
|
871
|
+
arrayUsage = methodUsage as FieldUsageConfig;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// Transform child field recursively
|
|
876
|
+
const transformedChild = typedField.child
|
|
877
|
+
? transformFieldForMethod(typedField.child, method)
|
|
878
|
+
: undefined;
|
|
879
|
+
|
|
880
|
+
return {
|
|
881
|
+
...field,
|
|
882
|
+
usage: arrayUsage,
|
|
883
|
+
child: transformedChild,
|
|
884
|
+
} as F;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
return field;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Generate schema for method-specific usage with proper field filtering
|
|
892
|
+
* This function correctly handles method-specific usage patterns where individual fields
|
|
893
|
+
* may have different usage patterns than their parent object
|
|
894
|
+
*/
|
|
895
|
+
export function generateSchemaForMethodAndUsage<F, Usage extends FieldUsage>(
|
|
896
|
+
field: F,
|
|
897
|
+
method: Methods,
|
|
898
|
+
targetUsage: Usage,
|
|
899
|
+
): z.ZodTypeAny {
|
|
900
|
+
interface FieldWithType {
|
|
901
|
+
type: "primitive" | "object" | "array";
|
|
902
|
+
usage?: FieldUsageConfig;
|
|
903
|
+
schema?: z.ZodTypeAny;
|
|
904
|
+
children?: Record<string, UnifiedField<string, z.ZodTypeAny>>;
|
|
905
|
+
child?: UnifiedField<string, z.ZodTypeAny>;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
const typedField = field as F & FieldWithType;
|
|
909
|
+
const hasMethodSpecificUsage = (
|
|
910
|
+
usage: FieldUsageConfig | undefined,
|
|
911
|
+
): boolean => {
|
|
912
|
+
if (!usage) {
|
|
913
|
+
return false;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// Check if the usage object has any method keys
|
|
917
|
+
// Handle both computed property syntax [Methods.X] and string keys "X"
|
|
918
|
+
const usageObj = usage as Record<string, FieldUsageConfig>;
|
|
919
|
+
return (
|
|
920
|
+
"GET" in usageObj ||
|
|
921
|
+
"POST" in usageObj ||
|
|
922
|
+
"PUT" in usageObj ||
|
|
923
|
+
"PATCH" in usageObj ||
|
|
924
|
+
"DELETE" in usageObj ||
|
|
925
|
+
Methods.GET in usageObj ||
|
|
926
|
+
Methods.POST in usageObj ||
|
|
927
|
+
Methods.PUT in usageObj ||
|
|
928
|
+
Methods.PATCH in usageObj ||
|
|
929
|
+
Methods.DELETE in usageObj
|
|
930
|
+
);
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
const getUsageForMethod = (
|
|
934
|
+
usage: FieldUsageConfig | undefined,
|
|
935
|
+
method: Methods,
|
|
936
|
+
): FieldUsageConfig | undefined => {
|
|
937
|
+
if (!usage) {
|
|
938
|
+
return undefined;
|
|
939
|
+
}
|
|
940
|
+
if (!hasMethodSpecificUsage(usage)) {
|
|
941
|
+
return usage;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// Handle method-specific usage extraction with support for both formats
|
|
945
|
+
// Use flexible Record type to handle both computed property syntax and string keys
|
|
946
|
+
const methodSpecificUsage = usage as Record<
|
|
947
|
+
string,
|
|
948
|
+
{
|
|
949
|
+
request?: "data" | "urlPathParams" | "data&urlPathParams";
|
|
950
|
+
response?: boolean;
|
|
951
|
+
}
|
|
952
|
+
>;
|
|
953
|
+
|
|
954
|
+
// Try to get usage with both enum value and string key
|
|
955
|
+
let methodUsage = methodSpecificUsage[method]; // Try enum value first (e.g., "POST")
|
|
956
|
+
if (!methodUsage) {
|
|
957
|
+
// Try string key as fallback (handles computed property syntax issues)
|
|
958
|
+
const stringKey = method.toString();
|
|
959
|
+
methodUsage = methodSpecificUsage[stringKey];
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
return methodUsage ? convertMethodUsageToStandard(methodUsage) : undefined;
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
const convertMethodUsageToStandard = (methodUsage: {
|
|
966
|
+
request?: "data" | "urlPathParams" | "data&urlPathParams";
|
|
967
|
+
response?: boolean;
|
|
968
|
+
}): FieldUsageConfig => {
|
|
969
|
+
if (methodUsage.request && methodUsage.response) {
|
|
970
|
+
// Both request and response
|
|
971
|
+
return {
|
|
972
|
+
request: methodUsage.request,
|
|
973
|
+
response: true,
|
|
974
|
+
} as FieldUsageConfig;
|
|
975
|
+
} else if (methodUsage.request) {
|
|
976
|
+
// Request only
|
|
977
|
+
return { request: methodUsage.request } as FieldUsageConfig;
|
|
978
|
+
} else if (methodUsage.response) {
|
|
979
|
+
// Response only
|
|
980
|
+
return { response: true } as FieldUsageConfig;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// Empty usage
|
|
984
|
+
return {} as FieldUsageConfig;
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
const hasTargetUsage = (usage: FieldUsageConfig | undefined): boolean => {
|
|
988
|
+
if (!usage) {
|
|
989
|
+
return false;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
switch (targetUsage) {
|
|
993
|
+
case FieldUsage.Response:
|
|
994
|
+
return "response" in usage && usage.response === true;
|
|
995
|
+
case FieldUsage.RequestData:
|
|
996
|
+
return (
|
|
997
|
+
"request" in usage &&
|
|
998
|
+
(usage.request === "data" || usage.request === "data&urlPathParams")
|
|
999
|
+
);
|
|
1000
|
+
case FieldUsage.RequestUrlParams:
|
|
1001
|
+
return (
|
|
1002
|
+
"request" in usage &&
|
|
1003
|
+
(usage.request === "urlPathParams" ||
|
|
1004
|
+
usage.request === "data&urlPathParams")
|
|
1005
|
+
);
|
|
1006
|
+
default:
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
if (typedField.type === "primitive") {
|
|
1012
|
+
const methodUsage = getUsageForMethod(typedField.usage, method);
|
|
1013
|
+
if (methodUsage && hasTargetUsage(methodUsage)) {
|
|
1014
|
+
return (
|
|
1015
|
+
typedField.schema ??
|
|
1016
|
+
(targetUsage === FieldUsage.RequestData ? z.undefined() : z.never())
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
return targetUsage === FieldUsage.RequestData ? z.undefined() : z.never();
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
if (typedField.type === "object") {
|
|
1023
|
+
// Build shape object by processing children FIRST
|
|
1024
|
+
// Children can have different usage than container (e.g., URL params even if container doesn't declare them)
|
|
1025
|
+
const shape: Record<string, z.ZodTypeAny> = {};
|
|
1026
|
+
|
|
1027
|
+
if (typedField.children) {
|
|
1028
|
+
for (const [key, childField] of Object.entries(typedField.children)) {
|
|
1029
|
+
const childSchema = generateSchemaForMethodAndUsage(
|
|
1030
|
+
childField,
|
|
1031
|
+
method,
|
|
1032
|
+
targetUsage,
|
|
1033
|
+
);
|
|
1034
|
+
if (!(childSchema instanceof z.ZodNever)) {
|
|
1035
|
+
shape[key] = childSchema;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// If we have matching children, return the object
|
|
1041
|
+
if (Object.keys(shape).length > 0) {
|
|
1042
|
+
return z.object(shape);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// No matching children - check if container itself should be included
|
|
1046
|
+
const objectMethodUsage = getUsageForMethod(typedField.usage, method);
|
|
1047
|
+
if (!objectMethodUsage || !hasTargetUsage(objectMethodUsage)) {
|
|
1048
|
+
return targetUsage === FieldUsage.RequestData ? z.undefined() : z.never();
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// Container matches but no children - return empty object
|
|
1052
|
+
return z.object({});
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
if (typedField.type === "array") {
|
|
1056
|
+
const methodUsage = getUsageForMethod(typedField.usage, method);
|
|
1057
|
+
if (methodUsage && hasTargetUsage(methodUsage) && typedField.child) {
|
|
1058
|
+
const childSchema = generateSchemaForMethodAndUsage(
|
|
1059
|
+
typedField.child,
|
|
1060
|
+
method,
|
|
1061
|
+
targetUsage,
|
|
1062
|
+
);
|
|
1063
|
+
return childSchema instanceof z.ZodNever
|
|
1064
|
+
? targetUsage === FieldUsage.RequestData
|
|
1065
|
+
? z.undefined()
|
|
1066
|
+
: z.never()
|
|
1067
|
+
: z.array(childSchema);
|
|
1068
|
+
}
|
|
1069
|
+
return targetUsage === FieldUsage.RequestData ? z.undefined() : z.never();
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
return targetUsage === FieldUsage.RequestData ? z.undefined() : z.never();
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Generate request data schema for a specific HTTP method using proper method-specific filtering
|
|
1077
|
+
*/
|
|
1078
|
+
export function generateRequestDataSchemaForMethod<F>(
|
|
1079
|
+
field: F,
|
|
1080
|
+
method: Methods,
|
|
1081
|
+
): z.ZodTypeAny {
|
|
1082
|
+
return generateSchemaForMethodAndUsage(field, method, FieldUsage.RequestData);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* Generate response schema for a specific HTTP method using proper method-specific filtering
|
|
1087
|
+
*/
|
|
1088
|
+
export function generateResponseSchemaForMethod<F>(
|
|
1089
|
+
field: F,
|
|
1090
|
+
method: Methods,
|
|
1091
|
+
): z.ZodTypeAny {
|
|
1092
|
+
return generateSchemaForMethodAndUsage(field, method, FieldUsage.Response);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* Generate request URL params schema for a specific HTTP method using proper method-specific filtering
|
|
1097
|
+
*/
|
|
1098
|
+
export function generateRequestUrlSchemaForMethod<F>(
|
|
1099
|
+
field: F,
|
|
1100
|
+
method: Methods,
|
|
1101
|
+
): z.ZodTypeAny {
|
|
1102
|
+
return generateSchemaForMethodAndUsage(
|
|
1103
|
+
field,
|
|
1104
|
+
method,
|
|
1105
|
+
FieldUsage.RequestUrlParams,
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Create a form endpoint with GET, POST, PATCH, and/or DELETE methods
|
|
1111
|
+
*
|
|
1112
|
+
* This utility creates multiple endpoints that share field definitions using method-specific usage patterns.
|
|
1113
|
+
* Each method can have different field usage (request/response) defined in the field's usage configuration.
|
|
1114
|
+
*
|
|
1115
|
+
* @param config Configuration for the form endpoint with method-specific settings
|
|
1116
|
+
* @returns Object with endpoint definitions for the specified HTTP methods
|
|
1117
|
+
*/
|
|
1118
|
+
export function createFormEndpoint<
|
|
1119
|
+
const TScopedTranslationKey extends string,
|
|
1120
|
+
const TFields extends UnifiedField<TScopedTranslationKey, z.ZodTypeAny>,
|
|
1121
|
+
const TExampleKey extends string,
|
|
1122
|
+
const TUserRoleValue extends readonly UserRoleValue[],
|
|
1123
|
+
const TMethods extends {
|
|
1124
|
+
GET?: FormMethodConfig<TScopedTranslationKey>;
|
|
1125
|
+
POST?: FormMethodConfig<TScopedTranslationKey>;
|
|
1126
|
+
PATCH?: FormMethodConfig<TScopedTranslationKey>;
|
|
1127
|
+
DELETE?: FormMethodConfig<TScopedTranslationKey>;
|
|
1128
|
+
},
|
|
1129
|
+
>(
|
|
1130
|
+
config: CreateFormEndpointConfig<
|
|
1131
|
+
TScopedTranslationKey,
|
|
1132
|
+
TExampleKey,
|
|
1133
|
+
TUserRoleValue,
|
|
1134
|
+
TFields,
|
|
1135
|
+
TMethods
|
|
1136
|
+
>,
|
|
1137
|
+
): CreateFormEndpointReturn<
|
|
1138
|
+
TExampleKey,
|
|
1139
|
+
TUserRoleValue,
|
|
1140
|
+
TScopedTranslationKey,
|
|
1141
|
+
TFields,
|
|
1142
|
+
TMethods
|
|
1143
|
+
> {
|
|
1144
|
+
// Generate schemas directly from the original fields with method-specific filtering
|
|
1145
|
+
|
|
1146
|
+
// Helper function for authentication check
|
|
1147
|
+
const requiresAuthentication = (): boolean => {
|
|
1148
|
+
return !config.allowedRoles.includes(UserRole.PUBLIC);
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
// Helper to create properly typed endpoint
|
|
1152
|
+
const createMethodEndpoint = <TMethod extends Methods>(
|
|
1153
|
+
method: TMethod,
|
|
1154
|
+
methodConfig: FormMethodConfig<TScopedTranslationKey>,
|
|
1155
|
+
requestSchema: InferSchemaFromFieldForMethod<
|
|
1156
|
+
TScopedTranslationKey,
|
|
1157
|
+
TFields,
|
|
1158
|
+
TMethod,
|
|
1159
|
+
FieldUsage.RequestData
|
|
1160
|
+
>,
|
|
1161
|
+
responseSchema: InferSchemaFromFieldForMethod<
|
|
1162
|
+
TScopedTranslationKey,
|
|
1163
|
+
TFields,
|
|
1164
|
+
TMethod,
|
|
1165
|
+
FieldUsage.Response
|
|
1166
|
+
>,
|
|
1167
|
+
urlSchema: InferSchemaFromFieldForMethod<
|
|
1168
|
+
TScopedTranslationKey,
|
|
1169
|
+
TFields,
|
|
1170
|
+
TMethod,
|
|
1171
|
+
FieldUsage.RequestUrlParams
|
|
1172
|
+
>,
|
|
1173
|
+
examples: (ExtractInput<
|
|
1174
|
+
InferSchemaFromFieldForMethod<
|
|
1175
|
+
TScopedTranslationKey,
|
|
1176
|
+
TFields,
|
|
1177
|
+
TMethod,
|
|
1178
|
+
FieldUsage.RequestData
|
|
1179
|
+
>
|
|
1180
|
+
> extends undefined
|
|
1181
|
+
? { requests?: undefined }
|
|
1182
|
+
: ExtractInput<
|
|
1183
|
+
InferSchemaFromFieldForMethod<
|
|
1184
|
+
TScopedTranslationKey,
|
|
1185
|
+
TFields,
|
|
1186
|
+
TMethod,
|
|
1187
|
+
FieldUsage.RequestData
|
|
1188
|
+
>
|
|
1189
|
+
> extends never
|
|
1190
|
+
? { requests?: undefined }
|
|
1191
|
+
: {
|
|
1192
|
+
requests: ExamplesList<
|
|
1193
|
+
ExtractInput<
|
|
1194
|
+
InferSchemaFromFieldForMethod<
|
|
1195
|
+
TScopedTranslationKey,
|
|
1196
|
+
TFields,
|
|
1197
|
+
TMethod,
|
|
1198
|
+
FieldUsage.RequestData
|
|
1199
|
+
>
|
|
1200
|
+
>,
|
|
1201
|
+
TExampleKey
|
|
1202
|
+
>;
|
|
1203
|
+
}) &
|
|
1204
|
+
(ExtractInput<
|
|
1205
|
+
InferSchemaFromFieldForMethod<
|
|
1206
|
+
TScopedTranslationKey,
|
|
1207
|
+
TFields,
|
|
1208
|
+
TMethod,
|
|
1209
|
+
FieldUsage.RequestUrlParams
|
|
1210
|
+
>
|
|
1211
|
+
> extends undefined
|
|
1212
|
+
? { urlPathParams?: undefined }
|
|
1213
|
+
: ExtractInput<
|
|
1214
|
+
InferSchemaFromFieldForMethod<
|
|
1215
|
+
TScopedTranslationKey,
|
|
1216
|
+
TFields,
|
|
1217
|
+
TMethod,
|
|
1218
|
+
FieldUsage.RequestUrlParams
|
|
1219
|
+
>
|
|
1220
|
+
> extends never
|
|
1221
|
+
? { urlPathParams?: undefined }
|
|
1222
|
+
: {
|
|
1223
|
+
urlPathParams: ExamplesList<
|
|
1224
|
+
ExtractInput<
|
|
1225
|
+
InferSchemaFromFieldForMethod<
|
|
1226
|
+
TScopedTranslationKey,
|
|
1227
|
+
TFields,
|
|
1228
|
+
TMethod,
|
|
1229
|
+
FieldUsage.RequestUrlParams
|
|
1230
|
+
>
|
|
1231
|
+
>,
|
|
1232
|
+
TExampleKey
|
|
1233
|
+
>;
|
|
1234
|
+
}) & {
|
|
1235
|
+
responses: ExamplesList<
|
|
1236
|
+
ExtractOutput<
|
|
1237
|
+
InferSchemaFromFieldForMethod<
|
|
1238
|
+
TScopedTranslationKey,
|
|
1239
|
+
TFields,
|
|
1240
|
+
TMethod,
|
|
1241
|
+
FieldUsage.Response
|
|
1242
|
+
>
|
|
1243
|
+
>,
|
|
1244
|
+
TExampleKey
|
|
1245
|
+
>;
|
|
1246
|
+
},
|
|
1247
|
+
): MethodSpecificEndpoint<
|
|
1248
|
+
TExampleKey,
|
|
1249
|
+
TMethod,
|
|
1250
|
+
TUserRoleValue,
|
|
1251
|
+
TScopedTranslationKey,
|
|
1252
|
+
TFields
|
|
1253
|
+
> => {
|
|
1254
|
+
return {
|
|
1255
|
+
method,
|
|
1256
|
+
path: config.path,
|
|
1257
|
+
title: methodConfig.title,
|
|
1258
|
+
description: methodConfig.description,
|
|
1259
|
+
category: config.category,
|
|
1260
|
+
tags: methodConfig.tags,
|
|
1261
|
+
allowedRoles: config.allowedRoles,
|
|
1262
|
+
debug: config.debug,
|
|
1263
|
+
aliases: methodConfig.aliases,
|
|
1264
|
+
icon: methodConfig.icon,
|
|
1265
|
+
fields: config.fields,
|
|
1266
|
+
errorTypes: config.errorTypes,
|
|
1267
|
+
successTypes: config.successTypes,
|
|
1268
|
+
examples: examples as never,
|
|
1269
|
+
requestSchema: requestSchema as never,
|
|
1270
|
+
responseSchema: responseSchema as never,
|
|
1271
|
+
requestUrlPathParamsSchema: urlSchema as never,
|
|
1272
|
+
requiresAuthentication,
|
|
1273
|
+
types: {
|
|
1274
|
+
RequestInput: undefined! as InferInputFromFieldForMethod<
|
|
1275
|
+
TScopedTranslationKey,
|
|
1276
|
+
TFields,
|
|
1277
|
+
TMethod,
|
|
1278
|
+
FieldUsage.RequestData
|
|
1279
|
+
>,
|
|
1280
|
+
RequestOutput: undefined! as InferOutputFromFieldForMethod<
|
|
1281
|
+
TScopedTranslationKey,
|
|
1282
|
+
TFields,
|
|
1283
|
+
TMethod,
|
|
1284
|
+
FieldUsage.RequestData
|
|
1285
|
+
>,
|
|
1286
|
+
ResponseInput: undefined! as InferInputFromFieldForMethod<
|
|
1287
|
+
TScopedTranslationKey,
|
|
1288
|
+
TFields,
|
|
1289
|
+
TMethod,
|
|
1290
|
+
FieldUsage.Response
|
|
1291
|
+
>,
|
|
1292
|
+
ResponseOutput: undefined! as InferOutputFromFieldForMethod<
|
|
1293
|
+
TScopedTranslationKey,
|
|
1294
|
+
TFields,
|
|
1295
|
+
TMethod,
|
|
1296
|
+
FieldUsage.Response
|
|
1297
|
+
>,
|
|
1298
|
+
UrlVariablesInput: undefined! as InferInputFromFieldForMethod<
|
|
1299
|
+
TScopedTranslationKey,
|
|
1300
|
+
TFields,
|
|
1301
|
+
TMethod,
|
|
1302
|
+
FieldUsage.RequestUrlParams
|
|
1303
|
+
>,
|
|
1304
|
+
UrlVariablesOutput: undefined! as InferOutputFromFieldForMethod<
|
|
1305
|
+
TScopedTranslationKey,
|
|
1306
|
+
TFields,
|
|
1307
|
+
TMethod,
|
|
1308
|
+
FieldUsage.RequestUrlParams
|
|
1309
|
+
>,
|
|
1310
|
+
Fields: undefined! as TFields,
|
|
1311
|
+
ExampleKey: undefined! as TExampleKey,
|
|
1312
|
+
Method: undefined! as TMethod,
|
|
1313
|
+
UserRoleValue: undefined! as TUserRoleValue,
|
|
1314
|
+
ScopedTranslationKey: undefined! as TScopedTranslationKey,
|
|
1315
|
+
},
|
|
1316
|
+
};
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
// Cast fields to TFields since the conditional type is for validation only
|
|
1320
|
+
const fields = config.fields as TFields;
|
|
1321
|
+
|
|
1322
|
+
// Create endpoints using the helper function with proper type assertions
|
|
1323
|
+
const getEndpoint = config.methods.GET
|
|
1324
|
+
? createMethodEndpoint(
|
|
1325
|
+
Methods.GET,
|
|
1326
|
+
config.methods.GET as FormMethodConfig<TScopedTranslationKey>,
|
|
1327
|
+
generateRequestDataSchemaForMethod(
|
|
1328
|
+
fields,
|
|
1329
|
+
Methods.GET,
|
|
1330
|
+
) as InferSchemaFromFieldForMethod<
|
|
1331
|
+
TScopedTranslationKey,
|
|
1332
|
+
TFields,
|
|
1333
|
+
Methods.GET,
|
|
1334
|
+
FieldUsage.RequestData
|
|
1335
|
+
>,
|
|
1336
|
+
generateResponseSchemaForMethod(
|
|
1337
|
+
fields,
|
|
1338
|
+
Methods.GET,
|
|
1339
|
+
) as InferSchemaFromFieldForMethod<
|
|
1340
|
+
TScopedTranslationKey,
|
|
1341
|
+
TFields,
|
|
1342
|
+
Methods.GET,
|
|
1343
|
+
FieldUsage.Response
|
|
1344
|
+
>,
|
|
1345
|
+
generateRequestUrlSchemaForMethod(
|
|
1346
|
+
fields,
|
|
1347
|
+
Methods.GET,
|
|
1348
|
+
) as InferSchemaFromFieldForMethod<
|
|
1349
|
+
TScopedTranslationKey,
|
|
1350
|
+
TFields,
|
|
1351
|
+
Methods.GET,
|
|
1352
|
+
FieldUsage.RequestUrlParams
|
|
1353
|
+
>,
|
|
1354
|
+
(config.examples.GET || {
|
|
1355
|
+
requests: undefined,
|
|
1356
|
+
responses: undefined as never,
|
|
1357
|
+
urlPathParams: undefined,
|
|
1358
|
+
}) as never,
|
|
1359
|
+
)
|
|
1360
|
+
: undefined;
|
|
1361
|
+
|
|
1362
|
+
const postEndpoint = config.methods.POST
|
|
1363
|
+
? createMethodEndpoint(
|
|
1364
|
+
Methods.POST,
|
|
1365
|
+
config.methods.POST as FormMethodConfig<TScopedTranslationKey>,
|
|
1366
|
+
generateRequestDataSchemaForMethod(
|
|
1367
|
+
fields,
|
|
1368
|
+
Methods.POST,
|
|
1369
|
+
) as InferSchemaFromFieldForMethod<
|
|
1370
|
+
TScopedTranslationKey,
|
|
1371
|
+
TFields,
|
|
1372
|
+
Methods.POST,
|
|
1373
|
+
FieldUsage.RequestData
|
|
1374
|
+
>,
|
|
1375
|
+
generateResponseSchemaForMethod(
|
|
1376
|
+
fields,
|
|
1377
|
+
Methods.POST,
|
|
1378
|
+
) as InferSchemaFromFieldForMethod<
|
|
1379
|
+
TScopedTranslationKey,
|
|
1380
|
+
TFields,
|
|
1381
|
+
Methods.POST,
|
|
1382
|
+
FieldUsage.Response
|
|
1383
|
+
>,
|
|
1384
|
+
generateRequestUrlSchemaForMethod(
|
|
1385
|
+
fields,
|
|
1386
|
+
Methods.POST,
|
|
1387
|
+
) as InferSchemaFromFieldForMethod<
|
|
1388
|
+
TScopedTranslationKey,
|
|
1389
|
+
TFields,
|
|
1390
|
+
Methods.POST,
|
|
1391
|
+
FieldUsage.RequestUrlParams
|
|
1392
|
+
>,
|
|
1393
|
+
(config.examples.POST || {
|
|
1394
|
+
requests: {} as never,
|
|
1395
|
+
responses: {} as never,
|
|
1396
|
+
urlPathParams: undefined,
|
|
1397
|
+
}) as never,
|
|
1398
|
+
)
|
|
1399
|
+
: undefined;
|
|
1400
|
+
|
|
1401
|
+
const patchEndpoint = config.methods.PATCH
|
|
1402
|
+
? createMethodEndpoint(
|
|
1403
|
+
Methods.PATCH,
|
|
1404
|
+
config.methods.PATCH as FormMethodConfig<TScopedTranslationKey>,
|
|
1405
|
+
generateRequestDataSchemaForMethod(
|
|
1406
|
+
fields,
|
|
1407
|
+
Methods.PATCH,
|
|
1408
|
+
) as InferSchemaFromFieldForMethod<
|
|
1409
|
+
TScopedTranslationKey,
|
|
1410
|
+
TFields,
|
|
1411
|
+
Methods.PATCH,
|
|
1412
|
+
FieldUsage.RequestData
|
|
1413
|
+
>,
|
|
1414
|
+
generateResponseSchemaForMethod(
|
|
1415
|
+
fields,
|
|
1416
|
+
Methods.PATCH,
|
|
1417
|
+
) as InferSchemaFromFieldForMethod<
|
|
1418
|
+
TScopedTranslationKey,
|
|
1419
|
+
TFields,
|
|
1420
|
+
Methods.PATCH,
|
|
1421
|
+
FieldUsage.Response
|
|
1422
|
+
>,
|
|
1423
|
+
generateRequestUrlSchemaForMethod(
|
|
1424
|
+
fields,
|
|
1425
|
+
Methods.PATCH,
|
|
1426
|
+
) as InferSchemaFromFieldForMethod<
|
|
1427
|
+
TScopedTranslationKey,
|
|
1428
|
+
TFields,
|
|
1429
|
+
Methods.PATCH,
|
|
1430
|
+
FieldUsage.RequestUrlParams
|
|
1431
|
+
>,
|
|
1432
|
+
(config.examples.PATCH || {
|
|
1433
|
+
requests: {} as never,
|
|
1434
|
+
responses: {} as never,
|
|
1435
|
+
urlPathParams: undefined,
|
|
1436
|
+
}) as never,
|
|
1437
|
+
)
|
|
1438
|
+
: undefined;
|
|
1439
|
+
|
|
1440
|
+
const deleteEndpoint = config.methods.DELETE
|
|
1441
|
+
? createMethodEndpoint(
|
|
1442
|
+
Methods.DELETE,
|
|
1443
|
+
config.methods.DELETE as FormMethodConfig<TScopedTranslationKey>,
|
|
1444
|
+
generateRequestDataSchemaForMethod(
|
|
1445
|
+
fields,
|
|
1446
|
+
Methods.DELETE,
|
|
1447
|
+
) as InferSchemaFromFieldForMethod<
|
|
1448
|
+
TScopedTranslationKey,
|
|
1449
|
+
TFields,
|
|
1450
|
+
Methods.DELETE,
|
|
1451
|
+
FieldUsage.RequestData
|
|
1452
|
+
>,
|
|
1453
|
+
generateResponseSchemaForMethod(
|
|
1454
|
+
fields,
|
|
1455
|
+
Methods.DELETE,
|
|
1456
|
+
) as InferSchemaFromFieldForMethod<
|
|
1457
|
+
TScopedTranslationKey,
|
|
1458
|
+
TFields,
|
|
1459
|
+
Methods.DELETE,
|
|
1460
|
+
FieldUsage.Response
|
|
1461
|
+
>,
|
|
1462
|
+
generateRequestUrlSchemaForMethod(
|
|
1463
|
+
fields,
|
|
1464
|
+
Methods.DELETE,
|
|
1465
|
+
) as InferSchemaFromFieldForMethod<
|
|
1466
|
+
TScopedTranslationKey,
|
|
1467
|
+
TFields,
|
|
1468
|
+
Methods.DELETE,
|
|
1469
|
+
FieldUsage.RequestUrlParams
|
|
1470
|
+
>,
|
|
1471
|
+
(config.examples.DELETE || {
|
|
1472
|
+
requests: {} as never,
|
|
1473
|
+
responses: {} as never,
|
|
1474
|
+
urlPathParams: undefined,
|
|
1475
|
+
}) as never,
|
|
1476
|
+
)
|
|
1477
|
+
: undefined;
|
|
1478
|
+
|
|
1479
|
+
// Return object - let overload signatures provide the type
|
|
1480
|
+
return {
|
|
1481
|
+
...(getEndpoint && { GET: getEndpoint }),
|
|
1482
|
+
...(postEndpoint && { POST: postEndpoint }),
|
|
1483
|
+
...(patchEndpoint && { PATCH: patchEndpoint }),
|
|
1484
|
+
...(deleteEndpoint && { DELETE: deleteEndpoint }),
|
|
1485
|
+
} as CreateFormEndpointReturn<
|
|
1486
|
+
TExampleKey,
|
|
1487
|
+
TUserRoleValue,
|
|
1488
|
+
TScopedTranslationKey,
|
|
1489
|
+
TFields,
|
|
1490
|
+
TMethods
|
|
1491
|
+
>;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// ============================================================================
|
|
1495
|
+
// HELPER FUNCTIONS
|
|
1496
|
+
// ============================================================================
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Type guard to check if usage is method-specific format
|
|
1500
|
+
*/
|
|
1501
|
+
function isMethodSpecificUsage(usage: FieldUsageConfig): boolean {
|
|
1502
|
+
const hasMethodKeys =
|
|
1503
|
+
Methods.GET in usage ||
|
|
1504
|
+
Methods.POST in usage ||
|
|
1505
|
+
Methods.PUT in usage ||
|
|
1506
|
+
Methods.PATCH in usage ||
|
|
1507
|
+
Methods.DELETE in usage;
|
|
1508
|
+
|
|
1509
|
+
return hasMethodKeys;
|
|
1510
|
+
}
|