@doist/twist-sdk 2.9.2 → 2.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,7 +121,7 @@ function isNodeEnvironment() {
121
121
  }
122
122
  function createDefaultDispatcher() {
123
123
  return __awaiter(this, void 0, void 0, function () {
124
- var _a, EnvHttpProxyAgent, interceptors, decompress;
124
+ var _a, EnvHttpProxyAgent, interceptors, agent, decompress;
125
125
  return __generator(this, function (_b) {
126
126
  switch (_b.label) {
127
127
  case 0:
@@ -131,8 +131,19 @@ function createDefaultDispatcher() {
131
131
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('undici')); })];
132
132
  case 1:
133
133
  _a = _b.sent(), EnvHttpProxyAgent = _a.EnvHttpProxyAgent, interceptors = _a.interceptors;
134
+ agent = new EnvHttpProxyAgent(keepAliveOptions);
135
+ // Some runtimes report `process.versions.node` (so `isNodeEnvironment()`
136
+ // passes) but ship only a partial undici: `interceptors.decompress` is
137
+ // absent and dispatchers have no `.compose`. Bun is the common case. There
138
+ // the proxy agent alone is enough — Bun's `fetch` decompresses
139
+ // gzip/deflate/br/zstd natively — so skip the interceptor instead of
140
+ // crashing on the missing API. Optional chaining also guards a runtime that
141
+ // omits the `interceptors` export entirely.
142
+ if (typeof (interceptors === null || interceptors === void 0 ? void 0 : interceptors.decompress) !== 'function') {
143
+ return [2 /*return*/, agent];
144
+ }
134
145
  decompress = suppressExperimentalWarningsSync(function () { return interceptors.decompress(); });
135
- return [2 /*return*/, new EnvHttpProxyAgent(keepAliveOptions).compose(decompress)];
146
+ return [2 /*return*/, agent.compose(decompress)];
136
147
  }
137
148
  });
138
149
  });
@@ -83,25 +83,29 @@ function isNodeEnvironment() {
83
83
  }
84
84
  function createDefaultDispatcher() {
85
85
  return __awaiter(this, void 0, void 0, function () {
86
- var _a, EnvHttpProxyAgent, interceptors, decompress;
86
+ var _a, EnvHttpProxyAgent, interceptors, agent, decompress;
87
87
  return __generator(this, function (_b) {
88
88
  switch (_b.label) {
89
89
  case 0:
90
90
  if (!isNodeEnvironment()) {
91
91
  return [2 /*return*/, undefined];
92
92
  }
93
- return [4 /*yield*/, import('undici')
94
- // Compose the response-decompression interceptor so gzip/deflate/br/zstd
95
- // bodies are decoded before consumers parse them. Required on Node 24+:
96
- // attaching any custom dispatcher to the global `fetch` strips the
97
- // `content-encoding` header but does not actually decompress the body,
98
- // so callers receive raw gzipped bytes and `JSON.parse` fails.
99
- // See https://github.com/Doist/todoist-cli/issues/318.
100
- ];
93
+ return [4 /*yield*/, import('undici')];
101
94
  case 1:
102
95
  _a = _b.sent(), EnvHttpProxyAgent = _a.EnvHttpProxyAgent, interceptors = _a.interceptors;
96
+ agent = new EnvHttpProxyAgent(keepAliveOptions);
97
+ // Some runtimes report `process.versions.node` (so `isNodeEnvironment()`
98
+ // passes) but ship only a partial undici: `interceptors.decompress` is
99
+ // absent and dispatchers have no `.compose`. Bun is the common case. There
100
+ // the proxy agent alone is enough — Bun's `fetch` decompresses
101
+ // gzip/deflate/br/zstd natively — so skip the interceptor instead of
102
+ // crashing on the missing API. Optional chaining also guards a runtime that
103
+ // omits the `interceptors` export entirely.
104
+ if (typeof (interceptors === null || interceptors === void 0 ? void 0 : interceptors.decompress) !== 'function') {
105
+ return [2 /*return*/, agent];
106
+ }
103
107
  decompress = suppressExperimentalWarningsSync(function () { return interceptors.decompress(); });
104
- return [2 /*return*/, new EnvHttpProxyAgent(keepAliveOptions).compose(decompress)];
108
+ return [2 /*return*/, agent.compose(decompress)];
105
109
  }
106
110
  });
107
111
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/twist-sdk",
3
- "version": "2.9.2",
3
+ "version": "2.9.3",
4
4
  "description": "A TypeScript wrapper for the Twist REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/twist-sdk-typescript/",