[PR #3912] [MERGED] feat: add extended support for versioned entities in the CLI #4587

Closed
opened 2026-03-17 02:06:40 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/3912
Author: @jamesgeorge007
Created: 3/19/2024
Status: Merged
Merged: 3/20/2024
Merged by: @AndrewBastin

Base: release/2024.3.0Head: feat/cli-support-versioning


📝 Commits (3)

  • 99ad3e5 feat: add extended support for versioned entities in the CLI
  • 1e3aca0 test: increase coverage
  • cd76cf5 chore: cleanup

📊 Changes

14 files changed (+352 additions, -159 deletions)

View changed files

📝 packages/hoppscotch-cli/src/__tests__/commands/test.spec.ts (+86 -16)
packages/hoppscotch-cli/src/__tests__/functions/checks/isRESTCollection.spec.ts (+0 -84)
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v1-req-v0.json (+27 -0)
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v1-req-v1.json (+48 -0)
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v2-req-v2.json (+54 -0)
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v2-req-v3.json (+54 -0)
📝 packages/hoppscotch-cli/src/__tests__/samples/collections/collection-level-headers-auth-coll.json (+6 -6)
packages/hoppscotch-cli/src/__tests__/samples/collections/sample-coll.json (+26 -0)
packages/hoppscotch-cli/src/__tests__/samples/environments/env-v0.json (+9 -0)
packages/hoppscotch-cli/src/__tests__/samples/environments/env-v1.json (+10 -0)
📝 packages/hoppscotch-cli/src/options/test/env.ts (+1 -1)
📝 packages/hoppscotch-cli/src/utils/checks.ts (+0 -44)
📝 packages/hoppscotch-cli/src/utils/mutators.ts (+29 -5)
📝 packages/hoppscotch-data/src/collection/index.ts (+2 -3)

📄 Description

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.

github.com/hoppscotch/hoppscotch@faab1d20fd/packages/hoppscotch-cli/src/utils/mutators.ts (L70-L76)

github.com/hoppscotch/hoppscotch@faab1d20fd/packages/hoppscotch-cli/src/utils/checks.ts (L37-L41)

github.com/hoppscotch/hoppscotch@faab1d20fd/packages/hoppscotch-data/src/rest/index.ts (L189-L191)

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/3912 **Author:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Created:** 3/19/2024 **Status:** ✅ Merged **Merged:** 3/20/2024 **Merged by:** [@AndrewBastin](https://github.com/AndrewBastin) **Base:** `release/2024.3.0` ← **Head:** `feat/cli-support-versioning` --- ### 📝 Commits (3) - [`99ad3e5`](https://github.com/hoppscotch/hoppscotch/commit/99ad3e5822285339a3da85ba31a67ccdb3525ec1) feat: add extended support for versioned entities in the CLI - [`1e3aca0`](https://github.com/hoppscotch/hoppscotch/commit/1e3aca05abd791b9c69f62ecf800af7e9edc8890) test: increase coverage - [`cd76cf5`](https://github.com/hoppscotch/hoppscotch/commit/cd76cf5df652714e7fb8f5b8d908f0c68bd4ab00) chore: cleanup ### 📊 Changes **14 files changed** (+352 additions, -159 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-cli/src/__tests__/commands/test.spec.ts` (+86 -16) ➖ `packages/hoppscotch-cli/src/__tests__/functions/checks/isRESTCollection.spec.ts` (+0 -84) ➕ `packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v1-req-v0.json` (+27 -0) ➕ `packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v1-req-v1.json` (+48 -0) ➕ `packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v2-req-v2.json` (+54 -0) ➕ `packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v2-req-v3.json` (+54 -0) 📝 `packages/hoppscotch-cli/src/__tests__/samples/collections/collection-level-headers-auth-coll.json` (+6 -6) ➕ `packages/hoppscotch-cli/src/__tests__/samples/collections/sample-coll.json` (+26 -0) ➕ `packages/hoppscotch-cli/src/__tests__/samples/environments/env-v0.json` (+9 -0) ➕ `packages/hoppscotch-cli/src/__tests__/samples/environments/env-v1.json` (+10 -0) 📝 `packages/hoppscotch-cli/src/options/test/env.ts` (+1 -1) 📝 `packages/hoppscotch-cli/src/utils/checks.ts` (+0 -44) 📝 `packages/hoppscotch-cli/src/utils/mutators.ts` (+29 -5) 📝 `packages/hoppscotch-data/src/collection/index.ts` (+2 -3) </details> ### 📄 Description ### 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. https://github.com/hoppscotch/hoppscotch/blob/faab1d20fde9a6be660db40fc73dcf28f9038008/packages/hoppscotch-cli/src/utils/mutators.ts#L70-L76 https://github.com/hoppscotch/hoppscotch/blob/faab1d20fde9a6be660db40fc73dcf28f9038008/packages/hoppscotch-cli/src/utils/checks.ts#L37-L41 https://github.com/hoppscotch/hoppscotch/blob/faab1d20fde9a6be660db40fc73dcf28f9038008/packages/hoppscotch-data/src/rest/index.ts#L189-L191 This PR extends the support for versioned entities in the CLI by ensuring the supplied collection contents come in via [verzod](https://github.com/AndrewBastin/verzod) and are translated to the latest version before consumption. Closes HFE-452. ### Changes - Leverage [verzod](https://github.com/AndrewBastin/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](https://github.com/AndrewBastin/verzod) based parsing. ### Checks - [x] My pull request adheres to the code style of this project - [x] All the tests have passed ### Note to reviewers Please refer to the [test suite](https://github.com/hoppscotch/hoppscotch/pull/3912/files#diff-4620ebaebd19183ecd749097a8bae19a95b56017fb749f728b74faee307ee95a) and associated [fixtures](https://github.com/hoppscotch/hoppscotch/pull/3912/files?file-filters%5B%5D=.json&show-deleted-files=false&show-viewed-files=false) for sample collections & environment export files following different version ranges to verify the behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:06:40 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4587
No description provided.