@doist/twist-sdk 2.5.0 → 2.5.1
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.
|
@@ -68,9 +68,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
68
68
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
72
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
73
|
+
if (ar || !(i in from)) {
|
|
74
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
75
|
+
ar[i] = from[i];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
79
|
+
};
|
|
71
80
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
81
|
exports.getDefaultDispatcher = getDefaultDispatcher;
|
|
73
82
|
exports.resetDefaultDispatcherForTests = resetDefaultDispatcherForTests;
|
|
83
|
+
exports.suppressExperimentalWarningsSync = suppressExperimentalWarningsSync;
|
|
74
84
|
// Use effectively-disabled keep-alive so short-lived CLI processes do not stay
|
|
75
85
|
// open waiting on idle sockets. Undici requires positive values, so we use 1ms.
|
|
76
86
|
var keepAliveOptions = {
|
|
@@ -111,18 +121,61 @@ function isNodeEnvironment() {
|
|
|
111
121
|
}
|
|
112
122
|
function createDefaultDispatcher() {
|
|
113
123
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var EnvHttpProxyAgent;
|
|
115
|
-
return __generator(this, function (
|
|
116
|
-
switch (
|
|
124
|
+
var _a, EnvHttpProxyAgent, interceptors, decompress;
|
|
125
|
+
return __generator(this, function (_b) {
|
|
126
|
+
switch (_b.label) {
|
|
117
127
|
case 0:
|
|
118
128
|
if (!isNodeEnvironment()) {
|
|
119
129
|
return [2 /*return*/, undefined];
|
|
120
130
|
}
|
|
121
131
|
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('undici')); })];
|
|
122
132
|
case 1:
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
_a = _b.sent(), EnvHttpProxyAgent = _a.EnvHttpProxyAgent, interceptors = _a.interceptors;
|
|
134
|
+
decompress = suppressExperimentalWarningsSync(function () { return interceptors.decompress(); });
|
|
135
|
+
return [2 /*return*/, new EnvHttpProxyAgent(keepAliveOptions).compose(decompress)];
|
|
125
136
|
}
|
|
126
137
|
});
|
|
127
138
|
});
|
|
128
139
|
}
|
|
140
|
+
// undici emits an `ExperimentalWarning` the first time `interceptors.decompress()`
|
|
141
|
+
// runs. The interceptor is stable for our gzipped-JSON-over-HTTPS use case;
|
|
142
|
+
// silence the warning during dispatcher init only so it does not leak to every
|
|
143
|
+
// consumer's stderr on the first request.
|
|
144
|
+
//
|
|
145
|
+
// `fn` must be synchronous so the override covers a single critical section
|
|
146
|
+
// (microseconds) — no unrelated `ExperimentalWarning` from elsewhere can
|
|
147
|
+
// interleave and be lost. We suppress every `ExperimentalWarning` rather than
|
|
148
|
+
// pattern-matching the message text: the message wording is an undici
|
|
149
|
+
// implementation detail (not a stable API), and the suppression window is
|
|
150
|
+
// narrow enough that a coarse type filter is safe.
|
|
151
|
+
//
|
|
152
|
+
// Exported for direct unit testing — the integration path through
|
|
153
|
+
// `getDefaultDispatcher()` cannot reliably exercise the helper because both
|
|
154
|
+
// the dispatcher singleton and undici's internal `warningEmitted` flag are
|
|
155
|
+
// once-per-process.
|
|
156
|
+
function suppressExperimentalWarningsSync(fn) {
|
|
157
|
+
var originalEmit = process.emitWarning;
|
|
158
|
+
process.emitWarning = (function (warning, typeOrOptions) {
|
|
159
|
+
var _a;
|
|
160
|
+
var rest = [];
|
|
161
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
162
|
+
rest[_i - 2] = arguments[_i];
|
|
163
|
+
}
|
|
164
|
+
var type = typeof typeOrOptions === 'string'
|
|
165
|
+
? typeOrOptions
|
|
166
|
+
: typeof typeOrOptions === 'object' && typeOrOptions !== null
|
|
167
|
+
? typeOrOptions.type
|
|
168
|
+
: undefined;
|
|
169
|
+
if (type === 'ExperimentalWarning')
|
|
170
|
+
return;
|
|
171
|
+
(_a = originalEmit).call.apply(_a, __spreadArray([process,
|
|
172
|
+
warning,
|
|
173
|
+
typeOrOptions], rest, false));
|
|
174
|
+
});
|
|
175
|
+
try {
|
|
176
|
+
return fn();
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
process.emitWarning = originalEmit;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -34,6 +34,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
37
46
|
// Use effectively-disabled keep-alive so short-lived CLI processes do not stay
|
|
38
47
|
// open waiting on idle sockets. Undici requires positive values, so we use 1ms.
|
|
39
48
|
var keepAliveOptions = {
|
|
@@ -74,18 +83,68 @@ function isNodeEnvironment() {
|
|
|
74
83
|
}
|
|
75
84
|
function createDefaultDispatcher() {
|
|
76
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
-
var EnvHttpProxyAgent;
|
|
78
|
-
return __generator(this, function (
|
|
79
|
-
switch (
|
|
86
|
+
var _a, EnvHttpProxyAgent, interceptors, decompress;
|
|
87
|
+
return __generator(this, function (_b) {
|
|
88
|
+
switch (_b.label) {
|
|
80
89
|
case 0:
|
|
81
90
|
if (!isNodeEnvironment()) {
|
|
82
91
|
return [2 /*return*/, undefined];
|
|
83
92
|
}
|
|
84
|
-
return [4 /*yield*/, import('undici')
|
|
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
|
+
];
|
|
85
101
|
case 1:
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
_a = _b.sent(), EnvHttpProxyAgent = _a.EnvHttpProxyAgent, interceptors = _a.interceptors;
|
|
103
|
+
decompress = suppressExperimentalWarningsSync(function () { return interceptors.decompress(); });
|
|
104
|
+
return [2 /*return*/, new EnvHttpProxyAgent(keepAliveOptions).compose(decompress)];
|
|
88
105
|
}
|
|
89
106
|
});
|
|
90
107
|
});
|
|
91
108
|
}
|
|
109
|
+
// undici emits an `ExperimentalWarning` the first time `interceptors.decompress()`
|
|
110
|
+
// runs. The interceptor is stable for our gzipped-JSON-over-HTTPS use case;
|
|
111
|
+
// silence the warning during dispatcher init only so it does not leak to every
|
|
112
|
+
// consumer's stderr on the first request.
|
|
113
|
+
//
|
|
114
|
+
// `fn` must be synchronous so the override covers a single critical section
|
|
115
|
+
// (microseconds) — no unrelated `ExperimentalWarning` from elsewhere can
|
|
116
|
+
// interleave and be lost. We suppress every `ExperimentalWarning` rather than
|
|
117
|
+
// pattern-matching the message text: the message wording is an undici
|
|
118
|
+
// implementation detail (not a stable API), and the suppression window is
|
|
119
|
+
// narrow enough that a coarse type filter is safe.
|
|
120
|
+
//
|
|
121
|
+
// Exported for direct unit testing — the integration path through
|
|
122
|
+
// `getDefaultDispatcher()` cannot reliably exercise the helper because both
|
|
123
|
+
// the dispatcher singleton and undici's internal `warningEmitted` flag are
|
|
124
|
+
// once-per-process.
|
|
125
|
+
export function suppressExperimentalWarningsSync(fn) {
|
|
126
|
+
var originalEmit = process.emitWarning;
|
|
127
|
+
process.emitWarning = (function (warning, typeOrOptions) {
|
|
128
|
+
var _a;
|
|
129
|
+
var rest = [];
|
|
130
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
131
|
+
rest[_i - 2] = arguments[_i];
|
|
132
|
+
}
|
|
133
|
+
var type = typeof typeOrOptions === 'string'
|
|
134
|
+
? typeOrOptions
|
|
135
|
+
: typeof typeOrOptions === 'object' && typeOrOptions !== null
|
|
136
|
+
? typeOrOptions.type
|
|
137
|
+
: undefined;
|
|
138
|
+
if (type === 'ExperimentalWarning')
|
|
139
|
+
return;
|
|
140
|
+
(_a = originalEmit).call.apply(_a, __spreadArray([process,
|
|
141
|
+
warning,
|
|
142
|
+
typeOrOptions], rest, false));
|
|
143
|
+
});
|
|
144
|
+
try {
|
|
145
|
+
return fn();
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
process.emitWarning = originalEmit;
|
|
149
|
+
}
|
|
150
|
+
}
|