feat: add extended support for versioned entities in the CLI #3912
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The public data structures like
collections
,requests
&environments
follow versioning where the new fields being added are introduced as new versioned entities, Ref #3457. When a collection/environment file is imported into the app, it is translated to the latest version, so that the same variant of the incoming data can be consumed across from that point without ambiguities. For the CLI, this was the case for environments, but not with collections, especially withREST
requests, previously it would expect the incoming request entry to conform to the latest schema and rejects if not.hoppscotch/packages/hoppscotch-cli/src/utils/mutators.ts
Lines 70 to 76 in faab1d2
hoppscotch/packages/hoppscotch-cli/src/utils/checks.ts
Lines 37 to 41 in faab1d2
hoppscotch/packages/hoppscotch-data/src/rest/index.ts
Lines 189 to 191 in faab1d2
This PR extends the support for versioned entities in the CLI by ensuring the supplied collection contents come in via verzod and are translated to the latest version before consumption.
Closes HFE-452.
Changes
v
field parsing for theHoppCollection
versioned entity. The intended type isnumber
.isHoppRESTCollection
helper and related test suite in favor of verzod based parsing.Checks
Note to reviewers
Please refer to the test suite and associated fixtures for sample collections & environment export files following different version ranges to verify the behavior.