feat(orval): add output.artifacts for runtime-safe artifact output groups - #3707
feat(orval): add output.artifacts for runtime-safe artifact output groups#3707the-ult wants to merge 5 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesArtifact group generation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Config
participant normalizeOptions
participant writeSpecs
participant ArtifactBarrels
participant RuntimeTests
Config->>normalizeOptions: provide output.artifacts settings
normalizeOptions->>writeSpecs: return normalized artifact directories and mock generators
writeSpecs->>ArtifactBarrels: generate client group barrel
ArtifactBarrels-->>RuntimeTests: expose separated client, MSW, Faker, and schema entry points
RuntimeTests->>ArtifactBarrels: traverse relative imports and validate boundaries
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in output.artifacts configuration that normalizes to existing output primitives (schemas output + mock generator paths/barrels) and introduces a single additional writer step to emit a runtime-safe client-group barrel in tags-split mode, preventing cross-runtime transitive imports (Angular vs MSW/Faker). This is reinforced by new tests that walk transitive relative-import graphs to prove runtime-safe boundaries.
Changes:
- Add
output.artifactsnormalization (constraints + conflict detection + auto-wiring MSW/Faker generator paths andindexMockFiles). - Add a new client-group barrel writer (
writeClientGroupBarrel) that composes withtagsSplitDeduplicationbarrels and avoids TS2308 conflicts for duplicated Angular httpResource boilerplate. - Add integration coverage: new configs, runtime-safety import-walker tests, updated/new snapshots, and docs updates.
Reviewed changes
Copilot reviewed 113 out of 113 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/configs/mock.config.ts | Adds artifactGroupsFetch test config using output.artifacts with fetch client. |
| tests/configs/angular.config.ts | Adds artifactGroups and artifactGroupsZod configs exercising Angular + artifacts (incl. both + zod schemas). |
| tests/api-generation.spec.ts | Adds transitive relative-import graph walker tests asserting runtime-safe artifact group boundaries. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/petWithTag.ts | New snapshot for schemas group output (fetch artifacts). |
| tests/snapshots/mock/artifact-groups-fetch/schemas/pets.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/petCountry.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/petCallingCode.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/pet.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/listPetsSort.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/listPetsParams.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/labradoodleBreed.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/labradoodle.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/index.ts | New snapshot for schemas barrel in schemas group. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/error.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/dogType.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/dog.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/dachshundBreed.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/dachshund.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/createPetsSort.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/createPetsParams.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/createPetsBody.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/catType.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/schemas/cat.ts | New snapshot for schemas group output. |
| tests/snapshots/mock/artifact-groups-fetch/msw/pets/pets.msw.ts | New snapshot for MSW group output (fetch artifacts). |
| tests/snapshots/mock/artifact-groups-fetch/msw/index.msw.ts | New snapshot for MSW barrel in msw group. |
| tests/snapshots/mock/artifact-groups-fetch/msw/health/health.msw.ts | New snapshot for MSW group output. |
| tests/snapshots/mock/artifact-groups-fetch/faker/pets/pets.faker.ts | New snapshot for Faker group output (fetch artifacts). |
| tests/snapshots/mock/artifact-groups-fetch/faker/index.faker.ts | New snapshot for Faker barrel in faker group. |
| tests/snapshots/mock/artifact-groups-fetch/faker/health/health.faker.ts | New snapshot for Faker group output. |
| tests/snapshots/mock/artifact-groups-fetch/client/pets/pets.ts | New snapshot for client group output (fetch artifacts). |
| tests/snapshots/mock/artifact-groups-fetch/client/index.ts | New snapshot for client group barrel (fetch artifacts). |
| tests/snapshots/mock/artifact-groups-fetch/client/health/health.ts | New snapshot for client group output. |
| tests/snapshots/mock/artifact-groups-fetch/client/common-types.ts | New snapshot for deduplicated common types used by client barrel. |
| tests/snapshots/angular/artifact-groups/schemas/searchPetsBodyStatus.ts | New snapshot for Angular artifacts schemas output. |
| tests/snapshots/angular/artifact-groups/schemas/searchPetsBody.ts | New snapshot for Angular artifacts schemas output. |
| tests/snapshots/angular/artifact-groups/schemas/pets.ts | New snapshot for Angular artifacts schemas output. |
| tests/snapshots/angular/artifact-groups/schemas/pet.ts | New snapshot for Angular artifacts schemas output. |
| tests/snapshots/angular/artifact-groups/schemas/index.ts | New snapshot for Angular artifacts schemas barrel. |
| tests/snapshots/angular/artifact-groups/schemas/error.ts | New snapshot for Angular artifacts schemas output. |
| tests/snapshots/angular/artifact-groups/schemas/createPetsBody.ts | New snapshot for Angular artifacts schemas output. |
| tests/snapshots/angular/artifact-groups/msw/pets/pets.msw.ts | New snapshot for Angular artifacts MSW group output. |
| tests/snapshots/angular/artifact-groups/msw/index.msw.ts | New snapshot for Angular artifacts MSW barrel. |
| tests/snapshots/angular/artifact-groups/msw/health/health.msw.ts | New snapshot for Angular artifacts MSW group output. |
| tests/snapshots/angular/artifact-groups/faker/pets/pets.faker.ts | New snapshot for Angular artifacts Faker group output. |
| tests/snapshots/angular/artifact-groups/faker/index.faker.ts | New snapshot for Angular artifacts Faker barrel. |
| tests/snapshots/angular/artifact-groups/faker/health/health.faker.ts | New snapshot for Angular artifacts Faker group output. |
| tests/snapshots/angular/artifact-groups/client/pets/pets.service.ts | New snapshot for Angular client group service output. |
| tests/snapshots/angular/artifact-groups/client/pets/pets.resource.ts | New snapshot for Angular client group resource output (httpResource). |
| tests/snapshots/angular/artifact-groups/client/index.ts | New snapshot for Angular client group barrel (handles TS2308 boilerplate exports). |
| tests/snapshots/angular/artifact-groups/client/health/health.service.ts | New snapshot for Angular client group service output. |
| tests/snapshots/angular/artifact-groups/client/health/health.resource.ts | New snapshot for Angular client group resource output (canonical boilerplate export source). |
| tests/snapshots/angular/artifact-groups-zod/schemas/petWithTag.zod.ts | New snapshot for artifacts schemas when schemas.type = zod. |
| tests/snapshots/angular/artifact-groups-zod/schemas/pets.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/pet.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/listPetsParams.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/listPetsHeaders.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/labradoodle.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/index.ts | New snapshot for zod schemas barrel. |
| tests/snapshots/angular/artifact-groups-zod/schemas/error.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/dog.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/dachshund.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/createPetsParams.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/createPetsHeaders.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/createPetsBody.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/schemas/cat.zod.ts | New snapshot for zod schemas group output. |
| tests/snapshots/angular/artifact-groups-zod/msw/index.msw.ts | New snapshot for artifacts MSW barrel in zod case. |
| tests/snapshots/angular/artifact-groups-zod/msw/health/health.msw.ts | New snapshot for artifacts MSW output in zod case. |
| tests/snapshots/angular/artifact-groups-zod/faker/pets/pets.faker.ts | New snapshot for artifacts Faker output in zod case. |
| tests/snapshots/angular/artifact-groups-zod/faker/index.faker.ts | New snapshot for artifacts Faker barrel in zod case. |
| tests/snapshots/angular/artifact-groups-zod/faker/health/health.faker.ts | New snapshot for artifacts Faker output in zod case. |
| tests/snapshots/angular/artifact-groups-zod/client/pets/pets.service.ts | New snapshot for Angular client output when schemas are zod. |
| tests/snapshots/angular/artifact-groups-zod/client/index.ts | New snapshot for client group barrel in zod case. |
| tests/snapshots/angular/artifact-groups-zod/client/health/health.service.ts | New snapshot for Angular client output in zod case. |
| samples/angular-app/src/api/artifact-groups/schemas/searchPetsStatus.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/searchPetsParams.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/petStatus.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/pets.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/pet.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/listPetsParams.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/index.ts | Adds sample generated schemas barrel (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/error.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/createPetsBodyStatus.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/schemas/createPetsBody.ts | Adds sample generated schemas group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/msw/index.msw.ts | Adds sample generated MSW barrel group output (angular-app). |
| samples/angular-app/src/api/artifact-groups/client/pets/pets.resource.ts | Adds sample generated Angular httpResource client output (angular-app). |
| samples/angular-app/src/api/artifact-groups/client/index.ts | Adds sample generated client barrel group output (angular-app). |
| samples/angular-app/orval.config.ts | Adds petstoreArtifactGroups sample config using output.artifacts. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/searchPetsStatus.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/searchPetsParams.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/petStatus.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/pets.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/pet.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/listPetsParams.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/index.ts | Snapshot for sample generated schemas barrel. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/error.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/createPetsBodyStatus.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/schemas/createPetsBody.ts | Snapshot for sample generated schemas group output. |
| samples/angular-app/snapshots/api/artifact-groups/msw/index.msw.ts | Snapshot for sample generated MSW barrel. |
| samples/angular-app/snapshots/api/artifact-groups/client/pets/pets.resource.ts | Snapshot for sample generated client resource output. |
| samples/angular-app/snapshots/api/artifact-groups/client/index.ts | Snapshot for sample generated client barrel. |
| packages/orval/src/write-specs.ts | Adds reusable barrel appender + client group barrel emission and integrates it into the write pipeline. |
| packages/orval/src/write-specs.test.ts | Adds unit tests for appendOrCreateBarrel and writeClientGroupBarrel. |
| packages/orval/src/utils/options.ts | Normalizes output.artifacts, validates constraints, merges schemas, and applies mock generator overrides. |
| packages/orval/src/utils/options.test.ts | Adds normalization tests for output.artifacts behavior and conflict rules. |
| packages/orval/src/generate-spec.ts | Extends clean-up logic to include artifacts MSW/Faker directories. |
| packages/core/src/types.ts | Adds public config + normalized types for output.artifacts and artifacts groups. |
| docs/content/docs/reference/configuration/output.mdx | Documents output.artifacts API, constraints, and interaction with mock options. |
| docs/content/docs/guides/angular.mdx | Adds Angular guide section explaining runtime-safe artifact groups and output.artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/orval/src/utils/options.test.ts (1)
1837-2116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGood coverage overall; consider adding tests for the two edge cases flagged in
options.ts.This suite doesn't exercise
{ schemas: false, artifacts: { schemas: '...' } }or a function-formmock.generatorsentry combined withartifacts.msw/artifacts.faker— both currently fail silently instead of throwing (see the corresponding comments onpackages/orval/src/utils/options.ts). Worth adding regression tests once those are fixed, so this suite locks in the corrected behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/orval/src/utils/options.test.ts` around lines 1837 - 2116, Add regression tests in the `output.artifacts normalization` suite for the two validation gaps in `normalizeOptions`: verify `{ schemas: false, artifacts: { schemas: '...' } }` throws, and verify function-form entries in `mock.generators` throw when combined with `artifacts.msw` or `artifacts.faker`. First update the corresponding validation logic in `normalizeOptions` so both invalid configurations fail explicitly, then assert the expected errors in these tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/orval/src/utils/options.ts`:
- Around line 262-317: Update applyArtifactsMockOverrides so function-form
entries for the current mock type are detected before appending a default
generator, causing the existing conflict error to be raised when
output.artifacts.msw or output.artifacts.faker is configured. Adjust the
generator lookup/branching around existingIndex so object-form generators still
receive the artifact path and unrelated generator types remain unchanged.
In `@samples/angular-app/src/api/artifact-groups/client/pets/pets.resource.ts`:
- Around line 173-177: Update the pets resource factory around the request
construction and HttpResourceRequest setup so `version()` and `params()` are
evaluated inside the `httpResource` callback rather than when the factory runs.
Ensure each callback rebuilds the URL and filtered parameters from the current
signal values, matching the pattern used by `searchPetsResource` and the other
resource helpers, so signal updates refresh the request.
In `@samples/angular-app/src/api/artifact-groups/client/pets/pets.service.ts`:
- Around line 193-196: Update the filterParams call in the pets service method
to enable preservation of required nullable query parameters by passing true for
preserveRequiredNullables, while retaining requirednullableString and
requirednullableStringTwo in the existing set. Ensure null values for these
fields remain in the request.
---
Nitpick comments:
In `@packages/orval/src/utils/options.test.ts`:
- Around line 1837-2116: Add regression tests in the `output.artifacts
normalization` suite for the two validation gaps in `normalizeOptions`: verify
`{ schemas: false, artifacts: { schemas: '...' } }` throws, and verify
function-form entries in `mock.generators` throw when combined with
`artifacts.msw` or `artifacts.faker`. First update the corresponding validation
logic in `normalizeOptions` so both invalid configurations fail explicitly, then
assert the expected errors in these tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5eebfb89-6643-4211-b0c9-1617d5a13b20
⛔ Files ignored due to path filters (86)
samples/angular-app/__snapshots__/api/artifact-groups/client/index.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/client/pets/pets.resource.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/client/pets/pets.service.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/msw/index.msw.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/msw/pets/pets.msw.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/createPetsBody.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/createPetsBodyStatus.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/error.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/index.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/listPetsParams.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/pet.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/petStatus.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/pets.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/searchPetsParams.tsis excluded by!**/__snapshots__/**samples/angular-app/__snapshots__/api/artifact-groups/schemas/searchPetsStatus.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/client/health/health.service.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/client/index.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/client/pets/pets.service.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/faker/health/health.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/faker/index.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/faker/pets/pets.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/msw/health/health.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/msw/index.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/msw/pets/pets.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/cat.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/createPetsBody.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/createPetsHeaders.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/createPetsParams.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/dachshund.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/dog.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/error.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/index.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/labradoodle.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/listPetsHeaders.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/listPetsParams.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/pet.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/petWithTag.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups-zod/schemas/pets.zod.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/client/health/health.resource.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/client/health/health.service.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/client/index.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/client/pets/pets.resource.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/client/pets/pets.service.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/faker/health/health.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/faker/index.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/faker/pets/pets.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/msw/health/health.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/msw/index.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/msw/pets/pets.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/createPetsBody.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/error.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/index.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/pet.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/pets.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/searchPetsBody.tsis excluded by!**/__snapshots__/**tests/__snapshots__/angular/artifact-groups/schemas/searchPetsBodyStatus.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/client/common-types.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/client/health/health.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/client/index.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/client/pets/pets.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/faker/health/health.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/faker/index.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/faker/pets/pets.faker.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/msw/health/health.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/msw/index.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/msw/pets/pets.msw.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/cat.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/catType.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/createPetsBody.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/createPetsParams.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/createPetsSort.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/dachshund.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/dachshundBreed.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/dog.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/dogType.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/error.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/index.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/labradoodle.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/labradoodleBreed.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/listPetsParams.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/listPetsSort.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/pet.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/petCallingCode.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/petCountry.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/petWithTag.tsis excluded by!**/__snapshots__/**tests/__snapshots__/mock/artifact-groups-fetch/schemas/pets.tsis excluded by!**/__snapshots__/**
📒 Files selected for processing (27)
docs/content/docs/guides/angular.mdxdocs/content/docs/reference/configuration/output.mdxpackages/core/src/types.tspackages/orval/src/generate-spec.tspackages/orval/src/utils/options.test.tspackages/orval/src/utils/options.tspackages/orval/src/write-specs.test.tspackages/orval/src/write-specs.tssamples/angular-app/orval.config.tssamples/angular-app/src/api/artifact-groups/client/index.tssamples/angular-app/src/api/artifact-groups/client/pets/pets.resource.tssamples/angular-app/src/api/artifact-groups/client/pets/pets.service.tssamples/angular-app/src/api/artifact-groups/msw/index.msw.tssamples/angular-app/src/api/artifact-groups/msw/pets/pets.msw.tssamples/angular-app/src/api/artifact-groups/schemas/createPetsBody.tssamples/angular-app/src/api/artifact-groups/schemas/createPetsBodyStatus.tssamples/angular-app/src/api/artifact-groups/schemas/error.tssamples/angular-app/src/api/artifact-groups/schemas/index.tssamples/angular-app/src/api/artifact-groups/schemas/listPetsParams.tssamples/angular-app/src/api/artifact-groups/schemas/pet.tssamples/angular-app/src/api/artifact-groups/schemas/petStatus.tssamples/angular-app/src/api/artifact-groups/schemas/pets.tssamples/angular-app/src/api/artifact-groups/schemas/searchPetsParams.tssamples/angular-app/src/api/artifact-groups/schemas/searchPetsStatus.tstests/api-generation.spec.tstests/configs/angular.config.tstests/configs/mock.config.ts
@orval/angular
@orval/axios
@orval/core
@orval/effect
@orval/fetch
@orval/hono
@orval/mcp
@orval/mock
orval
@orval/query
@orval/solid-start
@orval/swr
@orval/zod
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/orval/src/write-specs.test.ts (1)
212-215: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider adding a test for partial path-prefix collision in
appendOrCreateBarrel.The
appendOrCreateBarrelimplementation usesdata.includes(export * from '${imp}')to detect already-declared imports. This is a substring check, so if an existing barrel containsexport * from './bc';and a new import'./b'is appended, the check would incorrectly skip it becauseexport * from './b'is a substring ofexport * from './bc'. A test covering this edge case would help guard against missing exports in generated barrels.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/orval/src/write-specs.test.ts` around lines 212 - 215, Add a test covering appendOrCreateBarrel when an existing export path is a longer prefix of a new path, such as './bc' versus './b'. Verify the generated barrel preserves the existing export and appends the new distinct export, preventing substring matching from suppressing it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/orval/src/write-specs.test.ts`:
- Around line 212-215: Add a test covering appendOrCreateBarrel when an existing
export path is a longer prefix of a new path, such as './bc' versus './b'.
Verify the generated barrel preserves the existing export and appends the new
distinct export, preventing substring matching from suppressing it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: eb8a9f86-516a-4b8c-bb75-be2f96758f57
📒 Files selected for processing (4)
packages/orval/src/utils/options.test.tspackages/orval/src/utils/options.tspackages/orval/src/write-specs.test.tspackages/orval/src/write-specs.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/orval/src/utils/options.test.ts
- packages/orval/src/write-specs.ts
- packages/orval/src/utils/options.ts
|
Review feedback addressed:
|
|
Broadened test coverage in d1418e0, per review discussion: added one
|
|
What's the use case? How are these artifacts going to be consumed by the generated clients? Can it be easily done via a post processor? |
|
@aqeelat sent you one more i forgot to send you: GHSA-cxq5-97v7-87j8 |
|
Artifacts might not be the correct naming. The idea was in an nx repo. (Going on vacation now, will dive in it further when I get back. With improved examples, output, etc) |
|
Sorry for the radio silence — back from vacation now. Use case, concretely: in an Nx-style monorepo you want independently-importable libraries so consumers don't pull unrelated runtime code across a boundary — e.g. a How consumers use it: nothing changes for the generated client's own imports. What's new is a second, orthogonal barrel per artifact group — Why not a post-processor: the barrel content isn't derivable from static config — it has to reflect what orval actually wrote (tags-split's file layout, Angular's extra On the naming/Nx idea from before vacation: I still think output: {
mode: 'tags-split',
target: 'libs/data-access/src/lib/generated/client/api.ts',
client: 'angular',
schemas: 'libs/models/src/lib/generated/schemas',
artifacts: {
msw: 'libs/mocks/src/lib/generated/msw',
faker: 'libs/mocks/src/lib/generated/faker',
},
}produces: Each folder is a normal Nx |
2205314 to
5291d7f
Compare
|
We recently added a couple of enhancements around this. In our nx repo, we do put schemas in a separate library than clients. We do use split-tags. I need to check if fakers and msw have the same configs. Check recent releases and let me know if we're still not fully satisfying your requirements. If not, I'll help you get this PR to the finish line. |
…rval-labs#3704) Adds output.artifacts, an opt-in tags-split option that routes schemas, mock (msw/faker), and client files into separate directories with their own barrels, so consumers can import a client bundle without pulling in msw/faker (and vice versa). Angular's httpResource generator duplicates identical helper boilerplate (OrvalHttpResourceOptions, ResourceState, toResourceState) into every .resource.ts file, so the new client barrel re-exports those names explicitly from one canonical file before its wildcard exports, avoiding a TS2308 ambiguous-export error whenever 'both' retrieval mode multi-tag output is combined with the new barrel. 100% backward compatible: artifacts is undefined by default, and all existing snapshots are unchanged. Fixes orval-labs#3704 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Addresses Copilot review on the artifacts barrel helper: appending to an existing index now inserts a separating newline when the file lacks a trailing one and dedupes named re-exports; the misleading 'sorted' test name is corrected (the caller sorts, the helper preserves order) and the new edge cases are covered by tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ts mocks CodeRabbit review: the type-matching findIndex skipped function-form generators, making the conflict guard dead code — a generators array with only a function-form entry silently gained an appended default generator. The guard is now hoisted before matching and rejects any function-form entry, since its type/path cannot be inspected or redirected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…client packages Adds one artifactGroups* test config per remaining client (axios, react-query, swr, vue-query, svelte-query) alongside the existing Angular and fetch coverage, parametrizes the runtime-safety import-graph tests over all of them, and cross-links the feature from msw.mdx/faker.mdx — the docs that motivated the original runtime-safety concern in orval-labs#3704 but previously had no pointer to the fix. solid-start was evaluated and deliberately excluded: wiring it through this config was the first time solid-start-flavored output has ever run through the generated-output typecheck gate (its own solid-start.config.ts has no generate:solid-start script and isn't part of generate-api), and doing so surfaces pre-existing solid-start generator defects unrelated to output.artifacts (missing @solidjs/router devDependency, a genuine TS2395 merged-declaration bug in generated Pets types, both reproducible from solid-start.config.ts's own existing entries in isolation). Left as a documented follow-up rather than folded into this PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ase onto master
The 3-way merge on write-specs.ts's import block silently dropped
`import { unique } from 'remeda';` during the rebase conflict
resolution even though the function is still used by
appendOrCreateBarrel/writeClientGroupBarrel. Master also picked up
~55 commits since this branch was cut, including a typedoc bump
(HTML -> Markdown docs output) and generator improvements (e.g. MSW
handlers now importing from a sibling faker module instead of
duplicating it inline) that regenerate this PR's own fixtures
differently. Regenerated all snapshots against current master to
match.
5291d7f to
9736e17
Compare
|
@aqeelat Thanks — I checked, and you were right: recent releases do cover most of it. I verified the import graph on current
So the runtime-safety core of #3704 — a Node MSW consumer never evaluating Angular — already works today. That's the answer to your question, and it's why I'm retiring this PR: Two genuine gaps remained, both now standalone PRs:
Plus #3814, adjacent hygiene rather than a #3704 requirement: One open question before I'd propose anything further. With Keeping this PR open until those three land, then closing it. |
Note
This PR is being retired (2026-08-05). Current
masteralready provides the runtime-safe artifact separation this proposed — verified by import-graph inspection, see the comment below. The two real remaining gaps are split out as #3813 (Angular resource files honourschemas.importPath/splitByTags) and #3815 (tags-split barrel re-exports*.resource.ts— the one genuinely-new capability here), with #3814 as related hygiene. Kept open until those merge.Summary
Closes #3704.
Adds an opt-in
output.artifactsoption that emits independently importable artifact groups — Zod/TS schemas, the client (services + Angular*.resource.ts), and msw/faker mocks — each with its own group barrel, so a Node-based MSW consumer never evaluates Angular client modules (and vice versa).Design: sugar over existing primitives, one new writer step
A triage pass over the codebase showed most of this already exists:
output.schemasgives an independent schemas barrel, andmock.generators[].path+indexMockFiles: truealready produce dedicated msw/faker dirs withindex.msw.ts/index.faker.tsbarrels. The genuine gap was a complete client-group barrel (intags-splitmode nothing re-exports the per-tag services together with Angular*.resource.tsextra files — the reason consumers hand-roll the unsafe root barrel this issue describes).So the implementation is deliberately thin:
output.artifactsnormalizes onto the existing options (output.schemas,mock.generators[].path, forcedindexMockFiles: true) — no parallel pipeline.writeClientGroupBarrelinwrite-specs.ts, emits<clientDir>/index.tsfrom the actual written implementation +builder.extraFilespaths (never derived from tag names), composing append-only with thetagsSplitDeduplicationbarrel.mode: 'tags-split'and errors loudly on conflicts (workspace,indexFiles: false, duplicate schemas config, conflicting explicit generator paths, overlapping group dirs).output.artifactsas the ergonomic wrapper. If maintainers prefer docs-only + the client-barrel fix, the sugar layer is cleanly separable — happy to split the PR.One real bug was caught by the generated-output typecheck gate during verification: Angular's httpResource generator duplicates helper boilerplate (
OrvalHttpResourceOptions,ResourceState,toResourceState) into every.resource.ts, which makes naiveexport *barrels fail with TS2308. The barrel now re-exports those names explicitly from one canonical file before the wildcards (registry-based; extendDUPLICATED_BOILERPLATE_EXPORTS_BY_CLIENTif future generators duplicate boilerplate).Runtime-safety guarantees (tested)
New
tests/api-generation.spec.tsassertions walk transitive relative imports and prove:.service.ts/.resource.tsfile nor any@angular/*import;.msw.ts/.faker.tsnor importsmsw/@faker-js/faker;Backwards compatibility
100% opt-in:
artifactsisundefinedby default and normalization is byte-identical without it. Full regeneration confirmed zero modified existing snapshots — 101 new files only (new test configsartifactGroups,artifactGroupsZod, client-agnosticartifactGroupsFetch, plus a newsamples/angular-appartifact-groups target that CI compiles).Verification
/tmpflake), angular 222 ✓, mock 297 ✓vp lint --type-aware --type-check✓; all 16 generated clients typecheck ✓Docs
docs/content/docs/guides/angular.mdx: new “Runtime-safe artifact groups” section (problem, recipe with existing options,artifactsconfig, generated tree, monorepopackage.json#exportsmapping, caveats)docs/content/docs/reference/configuration/output.mdx: newartifactsreferenceRelated issues
Sibling cluster: #3702, #3705, #3706, #3700. Prior art this builds on: #3537 (separate mock/faker output paths), #3318 (MSW barrel breaking vitest/jsdom — the failure mode fixed here), #3553 / #3624 (root barrels in split modes), #3592 (tags-split schemas), #2912 (indexFiles import paths), #3333 (rule-based output paths).
🤖 Generated with Claude Code
Summary by CodeRabbit
output.artifactsfor generating independently importable groups (schemas, client, MSW, Faker) with per-group barrels intags-splitmode, including Angular per-tag client re-exports.output.artifactsconstraints/behavior; added tips to Faker and MSW guides.output.artifactsoption normalization/validation, barrel generation behavior, and runtime import-graph separation.