@doist/todoist-sdk 10.1.1 → 10.1.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.
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getDefaultDispatcher = getDefaultDispatcher;
37
37
  exports.resetDefaultDispatcherForTests = resetDefaultDispatcherForTests;
38
+ exports.suppressExperimentalWarningsSync = suppressExperimentalWarningsSync;
38
39
  // Use effectively-disabled keep-alive so short-lived CLI processes do not stay
39
40
  // open waiting on idle sockets. Undici requires positive values, so we use 1ms.
40
41
  const KEEP_ALIVE_OPTIONS = {
@@ -63,8 +64,53 @@ async function resetDefaultDispatcherForTests() {
63
64
  await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
64
65
  }
65
66
  async function createDefaultDispatcher() {
66
- const { EnvHttpProxyAgent } = await Promise.resolve().then(() => __importStar(require('undici')));
67
- return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
67
+ // Dynamic import so non-Node consumers (browser, edge runtimes) don't pull
68
+ // undici into their bundle. `getDefaultDispatcher` already short-circuits
69
+ // outside Node, so this branch only runs when undici is safe to load.
70
+ const { EnvHttpProxyAgent, interceptors } = await Promise.resolve().then(() => __importStar(require('undici')));
71
+ // Compose the response-decompression interceptor so gzip/deflate/br/zstd
72
+ // bodies are decoded before consumers parse them. Required on Node 24+:
73
+ // attaching any custom dispatcher to the global `fetch` strips the
74
+ // `content-encoding` header but does not actually decompress the body,
75
+ // so callers receive raw gzipped bytes and `JSON.parse` fails.
76
+ // See https://github.com/Doist/todoist-cli/issues/318.
77
+ const decompress = suppressExperimentalWarningsSync(() => interceptors.decompress());
78
+ return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS).compose(decompress);
79
+ }
80
+ // undici emits an `ExperimentalWarning` the first time `interceptors.decompress()`
81
+ // runs. The interceptor is stable for our gzipped-JSON-over-HTTPS use case;
82
+ // silence the warning during dispatcher init only so it does not leak to every
83
+ // consumer's stderr on the first request.
84
+ //
85
+ // `fn` must be synchronous so the override covers a single critical section
86
+ // (microseconds) — no unrelated `ExperimentalWarning` from elsewhere can
87
+ // interleave and be lost. We suppress every `ExperimentalWarning` rather than
88
+ // pattern-matching the message text: the message wording is an undici
89
+ // implementation detail (not a stable API), and the suppression window is
90
+ // narrow enough that a coarse type filter is safe.
91
+ //
92
+ // Exported for direct unit testing — the integration path through
93
+ // `getDefaultDispatcher()` cannot reliably exercise the helper because both
94
+ // the dispatcher singleton and undici's internal `warningEmitted` flag are
95
+ // once-per-process.
96
+ function suppressExperimentalWarningsSync(fn) {
97
+ const originalEmit = process.emitWarning;
98
+ process.emitWarning = ((warning, typeOrOptions, ...rest) => {
99
+ const type = typeof typeOrOptions === 'string'
100
+ ? typeOrOptions
101
+ : typeof typeOrOptions === 'object' && typeOrOptions !== null
102
+ ? typeOrOptions.type
103
+ : undefined;
104
+ if (type === 'ExperimentalWarning')
105
+ return;
106
+ originalEmit.call(process, warning, typeOrOptions, ...rest);
107
+ });
108
+ try {
109
+ return fn();
110
+ }
111
+ finally {
112
+ process.emitWarning = originalEmit;
113
+ }
68
114
  }
69
115
  function isNodeEnvironment() {
70
116
  var _a;
@@ -26,8 +26,53 @@ export async function resetDefaultDispatcherForTests() {
26
26
  await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
27
27
  }
28
28
  async function createDefaultDispatcher() {
29
- const { EnvHttpProxyAgent } = await import('undici');
30
- return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
29
+ // Dynamic import so non-Node consumers (browser, edge runtimes) don't pull
30
+ // undici into their bundle. `getDefaultDispatcher` already short-circuits
31
+ // outside Node, so this branch only runs when undici is safe to load.
32
+ const { EnvHttpProxyAgent, interceptors } = await import('undici');
33
+ // Compose the response-decompression interceptor so gzip/deflate/br/zstd
34
+ // bodies are decoded before consumers parse them. Required on Node 24+:
35
+ // attaching any custom dispatcher to the global `fetch` strips the
36
+ // `content-encoding` header but does not actually decompress the body,
37
+ // so callers receive raw gzipped bytes and `JSON.parse` fails.
38
+ // See https://github.com/Doist/todoist-cli/issues/318.
39
+ const decompress = suppressExperimentalWarningsSync(() => interceptors.decompress());
40
+ return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS).compose(decompress);
41
+ }
42
+ // undici emits an `ExperimentalWarning` the first time `interceptors.decompress()`
43
+ // runs. The interceptor is stable for our gzipped-JSON-over-HTTPS use case;
44
+ // silence the warning during dispatcher init only so it does not leak to every
45
+ // consumer's stderr on the first request.
46
+ //
47
+ // `fn` must be synchronous so the override covers a single critical section
48
+ // (microseconds) — no unrelated `ExperimentalWarning` from elsewhere can
49
+ // interleave and be lost. We suppress every `ExperimentalWarning` rather than
50
+ // pattern-matching the message text: the message wording is an undici
51
+ // implementation detail (not a stable API), and the suppression window is
52
+ // narrow enough that a coarse type filter is safe.
53
+ //
54
+ // Exported for direct unit testing — the integration path through
55
+ // `getDefaultDispatcher()` cannot reliably exercise the helper because both
56
+ // the dispatcher singleton and undici's internal `warningEmitted` flag are
57
+ // once-per-process.
58
+ export function suppressExperimentalWarningsSync(fn) {
59
+ const originalEmit = process.emitWarning;
60
+ process.emitWarning = ((warning, typeOrOptions, ...rest) => {
61
+ const type = typeof typeOrOptions === 'string'
62
+ ? typeOrOptions
63
+ : typeof typeOrOptions === 'object' && typeOrOptions !== null
64
+ ? typeOrOptions.type
65
+ : undefined;
66
+ if (type === 'ExperimentalWarning')
67
+ return;
68
+ originalEmit.call(process, warning, typeOrOptions, ...rest);
69
+ });
70
+ try {
71
+ return fn();
72
+ }
73
+ finally {
74
+ process.emitWarning = originalEmit;
75
+ }
31
76
  }
32
77
  function isNodeEnvironment() {
33
78
  var _a;
@@ -1,3 +1,4 @@
1
1
  import type { Dispatcher } from 'undici';
2
2
  export declare function getDefaultDispatcher(): Promise<Dispatcher | undefined>;
3
3
  export declare function resetDefaultDispatcherForTests(): Promise<void>;
4
+ export declare function suppressExperimentalWarningsSync<T>(fn: () => T): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "10.1.1",
3
+ "version": "10.1.3",
4
4
  "description": "The official TypeScript SDK for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "https://github.com/Doist/todoist-sdk-typescript",
@@ -52,7 +52,7 @@
52
52
  "form-data": "4.0.5",
53
53
  "ts-custom-error": "^3.2.0",
54
54
  "undici": "^7.16.0",
55
- "uuid": "11.1.0",
55
+ "uuid": "11.1.1",
56
56
  "zod": "4.3.6"
57
57
  },
58
58
  "devDependencies": {