feat(api): make `Proxy` and `Toxic` classes immutable
Make Proxy and Toxic classes immutable and remove cyclic dependencies.
Removing the cyclic dependencies between the objects has many benefits, for example JSON (de-)serialization of Axios errors now just works.
BREAKING CHANGE: Proxy and Toxic objects are now updated by posting an update to the server with the attributes to be updated. This is a breaking change because the update methods return a new instance of a Proxy or Toxic object instead of returning the mutated object.
Sorry for making this a breaking change but I think the improvements justify the trouble :)
Tests are green:
docker run --rm -p 8474:8474 ghcr.io/shopify/toxiproxy:latest
npm run test
> [email protected] test
> jest --runInBand
PASS src/tests/ToxicTypes.spec.ts
PASS src/tests/Toxiproxy.spec.ts
PASS src/tests/Toxic.spec.ts
PASS src/tests/Proxy.spec.ts
Test Suites: 4 passed, 4 total
Tests: 18 passed, 18 total
Snapshots: 0 total
Time: 1.173 s, estimated 3 s
@ihsw thanks a lot for merging the previous change. If we get this one merged I can close a dark fork of this very helpful project and we should be ready for the next years of maintenance work (happy to help) :)
@dvag-gloeckner-daniel it is merged and published as [email protected]