Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extended support for versioned entities in the CLI #3912

Merged
merged 3 commits into from Mar 20, 2024

Conversation

jamesgeorge007
Copy link
Member

@jamesgeorge007 jamesgeorge007 commented Mar 19, 2024

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 with REST requests, previously it would expect the incoming request entry to conform to the latest schema and rejects if not.

if (maybeArrayOfCollections.some((x) => !isRESTCollection(x))) {
throw error({
code: "MALFORMED_COLLECTION",
path,
data: "Please check the collection data.",
});
}

// Checks each requests array to be valid HoppRESTRequest.
const checkRequests = A.every(isHoppRESTRequest)(param.requests);
if (!checkRequests) {
return false;
}

export function isHoppRESTRequest(x: unknown): x is HoppRESTRequest {
return HoppRESTRequest.isLatest(x)
}

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

  • Leverage verzod to parse the incoming data and translate them to the latest version, if valid.
  • Fix the v field parsing for the HoppCollection versioned entity. The intended type is number.
  • Test suite updates ensuring different version ranges of the data structures are supported.
  • Remove stale isHoppRESTCollection helper and related test suite in favor of verzod based parsing.

Checks

  • My pull request adheres to the code style of this project
  • All the tests have passed

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.

@jamesgeorge007 jamesgeorge007 changed the title feat: add support for versioned entities in the CLI feat: extended support for versioned entities in the CLI Mar 20, 2024
@jamesgeorge007 jamesgeorge007 changed the title feat: extended support for versioned entities in the CLI feat: add extended support for versioned entities in the CLI Mar 20, 2024
@jamesgeorge007 jamesgeorge007 force-pushed the feat/cli-support-versioning branch 2 times, most recently from 9f4da05 to 0ac987f Compare March 20, 2024 08:21
@AndrewBastin AndrewBastin merged commit 7621ff2 into release/2024.3.0 Mar 20, 2024
1 check passed
@jamesgeorge007 jamesgeorge007 deleted the feat/cli-support-versioning branch March 20, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants