From ab4b5f479bbd3bb93c32d6f46851a89bf89fa4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Garc=C3=ADa?= Date: Wed, 4 Sep 2024 08:09:30 +0200 Subject: [PATCH 1/5] feat: Method to clear all defined interceptors in client-fetch. --- packages/client-fetch/src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/client-fetch/src/utils.ts b/packages/client-fetch/src/utils.ts index d5ae551d8..a1cbdabd3 100644 --- a/packages/client-fetch/src/utils.ts +++ b/packages/client-fetch/src/utils.ts @@ -440,6 +440,10 @@ class Interceptors { this._fns = []; } + clear() { + this._fns = []; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) { From 4d525a4ba2e72118c514ac6652a9210fda34d05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Garc=C3=ADa?= Date: Wed, 4 Sep 2024 08:10:21 +0200 Subject: [PATCH 2/5] feat: Method to check if and interceptor function exist in client-fetch. --- packages/client-fetch/src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/client-fetch/src/utils.ts b/packages/client-fetch/src/utils.ts index a1cbdabd3..32f5cd688 100644 --- a/packages/client-fetch/src/utils.ts +++ b/packages/client-fetch/src/utils.ts @@ -444,6 +444,10 @@ class Interceptors { this._fns = []; } + exist(fn: Interceptor) { + return this._fns.indexOf(fn) !== -1; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) { From 7ebc1d44af74db2522219d71d240325f6bc5689d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Garc=C3=ADa?= Date: Thu, 5 Sep 2024 07:23:33 +0200 Subject: [PATCH 3/5] add changeset --- .changeset/tall-bees-cheer.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tall-bees-cheer.md diff --git a/.changeset/tall-bees-cheer.md b/.changeset/tall-bees-cheer.md new file mode 100644 index 000000000..82610c181 --- /dev/null +++ b/.changeset/tall-bees-cheer.md @@ -0,0 +1,5 @@ +--- +'@hey-api/client-fetch': minor +--- + +feat: Function to clear and check if exist an interceptor in client-fetch From 6b64718aadab6a1abe350fc37c65febbc4a5b05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Garc=C3=ADa?= Date: Thu, 5 Sep 2024 08:50:40 +0200 Subject: [PATCH 4/5] fix: typographical error --- packages/client-fetch/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client-fetch/src/utils.ts b/packages/client-fetch/src/utils.ts index 32f5cd688..3fbc16855 100644 --- a/packages/client-fetch/src/utils.ts +++ b/packages/client-fetch/src/utils.ts @@ -444,7 +444,7 @@ class Interceptors { this._fns = []; } - exist(fn: Interceptor) { + exists(fn: Interceptor) { return this._fns.indexOf(fn) !== -1; } From deaf901bb7bc3301eed7e5bf2596e367cad03bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Garc=C3=ADa?= Date: Wed, 11 Sep 2024 07:22:04 +0200 Subject: [PATCH 5/5] update snapshot test --- .../v3-hey-api-client-fetch-bundle/core/utils.ts.snap | 8 ++++++++ .../core/utils.ts.snap | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap index d5ae551d8..3fbc16855 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap @@ -440,6 +440,14 @@ class Interceptors { this._fns = []; } + clear() { + this._fns = []; + } + + exists(fn: Interceptor) { + return this._fns.indexOf(fn) !== -1; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap index d5ae551d8..3fbc16855 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap @@ -440,6 +440,14 @@ class Interceptors { this._fns = []; } + clear() { + this._fns = []; + } + + exists(fn: Interceptor) { + return this._fns.indexOf(fn) !== -1; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) {