Repository navigation
Export and import a workspace's overrides and rules - #30
Merged
Merged
Conversation
Export writes the active workspace's overrides (content, the base when it differs, match, on/off, a response override's settings) and rules to one JSON file through a save dialog. Import adds a file's to the active workspace: each entry is checked as the app's own input, one the workspace already has is left out (its own version is kept), and the toast says what was added and left out before the page reloads. Both are in a menu on the Explorer's Overrides section and in the palette.
…menu in e2e A menu closes when the window blurs or its list scrolls, both of which a switch can do while its page loads and its tabs come back; the test opened the menu right after the override rows appeared.
…types The file's envelope and each override it lists are read with Zod schemas in src/shared/overrides (overridesFileSchema, exportedOverrideSchema), bound with z.toZod to the types in src/shared/types/overridesFile.ts, and the envelope goes through parseInput as other files do. MAX_URL_CHARS moves to src/shared/constants.ts, since the schema needs it too.
…-overrides # Conflicts: # CHANGELOG.md # README.md # docs/SPEC.md # src/main/ipc/registerIpc.ts # test/e2e/app.e2e.test.ts
Rules apply oldest first, and two with the same createdAt are ordered by their random ids. An import creates its rules within one millisecond, so they could come out in either order (CI caught it in overridesFile.test). A rule made in the same millisecond as another of its workspace now goes one past the newest instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What and why
Implements U13 (roadmap M2): share a workspace's overrides with a teammate, or copy them to another workspace.
shop.test-overrides.json).How it works:
src/main/overridesFile/):{ format: 'console-editor-overrides', version: 1, overrides, rules }.originalHash, a response override's request and response settings, its content, and its base when that differs. Diffs and Patch live need the base.CreateRuleInputplusenabled.src/shared/overrides, bound withz.toZodto the types insrc/shared/types/overridesFile.ts.overridesFileSchema, throughparseInput, takes the format, aversionthis build reads (a newer one is refused, with a word to update the app), and at most 500 overrides. The file must be at most 200 MB.exportedOverrideSchemachecks each override: a known kind, an http(s) source URL, a usable matcher, a SHA-256 or null. A response override's request and response settings are then checked as the store checks them (responseFieldsOf).ruleInputSchema.sameOverrideTarget); for a rule,sameRuleInput. A file listing one twice adds it once.overrides-changedandrules-changedare sent even when a later entry fails, such as a rule refused because the workspace already holds 200.createdAtwere ordered by their random ids. An import creates its rules within one millisecond, so they could come out in either order (CI caught this).addRulenow puts a rule made in the same millisecond as another of its workspace one past the newest. Otherwise the clock's time stands, as before.MAX_URL_CHARSmoved fromsrc/main/ipc/constants.tstosrc/shared/constants.ts, since the shared schema needs it too.overrideFileItems.ts, to keepAppCommandPaletteunder 150 lines.features/override/share; an ungrouped slice would have gone over steiger's limit of 20.pathFileName(a file path's name, for the toast) lives inshared/lib/url, sinceshared/libis at its module limit.main, with #29 (the external editor), is merged in (not rebased). Only docs,registerIpc.tsand an e2e import line conflicted: both sides added a line, and both are kept.How it was tested
test/unit/overridesFile.test.ts):test/unit/ruleStore.test.ts): rules made in one millisecond keep their order, even when their ids sort the other way.test/renderer/share-overrides.test.ts): the toast texts, the reload after an import, and what happens when the dialog is cancelled or the import fails.test/e2e/app.e2e.test.ts), with the native dialogs stubbed as the HAR test does:Checklist
feature/…,bugfix/…) intomain, and does one thingnpm run typecheck,npm run lint:fsd,npm run lint:structure,npm run lint,npm run lint:unused,npm run lint:duplicates,npm run lint:secrets,npm testandnpm run test:e2epass on the merged tree (1207 unit, 111 e2e)docs/SPEC.mddescribes any behaviour this changes (§2, §5 Sharing, §8, §11)[Unreleased]inCHANGELOG.md