@sentry/api 1.0.0 → 1.1.0

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.
@@ -1,324 +1,5 @@
1
- // node:path
2
- function assertPath(path) {
3
- if (typeof path !== "string")
4
- throw TypeError("Path must be a string. Received " + JSON.stringify(path));
5
- }
6
- function normalizeStringPosix(path, allowAboveRoot) {
7
- var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
8
- for (var i = 0;i <= path.length; ++i) {
9
- if (i < path.length)
10
- code = path.charCodeAt(i);
11
- else if (code === 47)
12
- break;
13
- else
14
- code = 47;
15
- if (code === 47) {
16
- if (lastSlash === i - 1 || dots === 1)
17
- ;
18
- else if (lastSlash !== i - 1 && dots === 2) {
19
- if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
20
- if (res.length > 2) {
21
- var lastSlashIndex = res.lastIndexOf("/");
22
- if (lastSlashIndex !== res.length - 1) {
23
- if (lastSlashIndex === -1)
24
- res = "", lastSegmentLength = 0;
25
- else
26
- res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
27
- lastSlash = i, dots = 0;
28
- continue;
29
- }
30
- } else if (res.length === 2 || res.length === 1) {
31
- res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
32
- continue;
33
- }
34
- }
35
- if (allowAboveRoot) {
36
- if (res.length > 0)
37
- res += "/..";
38
- else
39
- res = "..";
40
- lastSegmentLength = 2;
41
- }
42
- } else {
43
- if (res.length > 0)
44
- res += "/" + path.slice(lastSlash + 1, i);
45
- else
46
- res = path.slice(lastSlash + 1, i);
47
- lastSegmentLength = i - lastSlash - 1;
48
- }
49
- lastSlash = i, dots = 0;
50
- } else if (code === 46 && dots !== -1)
51
- ++dots;
52
- else
53
- dots = -1;
54
- }
55
- return res;
56
- }
57
- function _format(sep, pathObject) {
58
- var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
59
- if (!dir)
60
- return base;
61
- if (dir === pathObject.root)
62
- return dir + base;
63
- return dir + sep + base;
64
- }
65
- function resolve() {
66
- var resolvedPath = "", resolvedAbsolute = false, cwd;
67
- for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
68
- var path;
69
- if (i >= 0)
70
- path = arguments[i];
71
- else {
72
- if (cwd === undefined)
73
- cwd = process.cwd();
74
- path = cwd;
75
- }
76
- if (assertPath(path), path.length === 0)
77
- continue;
78
- resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
79
- }
80
- if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
81
- if (resolvedPath.length > 0)
82
- return "/" + resolvedPath;
83
- else
84
- return "/";
85
- else if (resolvedPath.length > 0)
86
- return resolvedPath;
87
- else
88
- return ".";
89
- }
90
- function normalize(path) {
91
- if (assertPath(path), path.length === 0)
92
- return ".";
93
- var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
94
- if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
95
- path = ".";
96
- if (path.length > 0 && trailingSeparator)
97
- path += "/";
98
- if (isAbsolute)
99
- return "/" + path;
100
- return path;
101
- }
102
- function isAbsolute(path) {
103
- return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
104
- }
105
- function join() {
106
- if (arguments.length === 0)
107
- return ".";
108
- var joined;
109
- for (var i = 0;i < arguments.length; ++i) {
110
- var arg = arguments[i];
111
- if (assertPath(arg), arg.length > 0)
112
- if (joined === undefined)
113
- joined = arg;
114
- else
115
- joined += "/" + arg;
116
- }
117
- if (joined === undefined)
118
- return ".";
119
- return normalize(joined);
120
- }
121
- function relative(from, to) {
122
- if (assertPath(from), assertPath(to), from === to)
123
- return "";
124
- if (from = resolve(from), to = resolve(to), from === to)
125
- return "";
126
- var fromStart = 1;
127
- for (;fromStart < from.length; ++fromStart)
128
- if (from.charCodeAt(fromStart) !== 47)
129
- break;
130
- var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
131
- for (;toStart < to.length; ++toStart)
132
- if (to.charCodeAt(toStart) !== 47)
133
- break;
134
- var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
135
- for (;i <= length; ++i) {
136
- if (i === length) {
137
- if (toLen > length) {
138
- if (to.charCodeAt(toStart + i) === 47)
139
- return to.slice(toStart + i + 1);
140
- else if (i === 0)
141
- return to.slice(toStart + i);
142
- } else if (fromLen > length) {
143
- if (from.charCodeAt(fromStart + i) === 47)
144
- lastCommonSep = i;
145
- else if (i === 0)
146
- lastCommonSep = 0;
147
- }
148
- break;
149
- }
150
- var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
151
- if (fromCode !== toCode)
152
- break;
153
- else if (fromCode === 47)
154
- lastCommonSep = i;
155
- }
156
- var out = "";
157
- for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
158
- if (i === fromEnd || from.charCodeAt(i) === 47)
159
- if (out.length === 0)
160
- out += "..";
161
- else
162
- out += "/..";
163
- if (out.length > 0)
164
- return out + to.slice(toStart + lastCommonSep);
165
- else {
166
- if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
167
- ++toStart;
168
- return to.slice(toStart);
169
- }
170
- }
171
- function _makeLong(path) {
172
- return path;
173
- }
174
- function dirname(path) {
175
- if (assertPath(path), path.length === 0)
176
- return ".";
177
- var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
178
- for (var i = path.length - 1;i >= 1; --i)
179
- if (code = path.charCodeAt(i), code === 47) {
180
- if (!matchedSlash) {
181
- end = i;
182
- break;
183
- }
184
- } else
185
- matchedSlash = false;
186
- if (end === -1)
187
- return hasRoot ? "/" : ".";
188
- if (hasRoot && end === 1)
189
- return "//";
190
- return path.slice(0, end);
191
- }
192
- function basename(path, ext) {
193
- if (ext !== undefined && typeof ext !== "string")
194
- throw TypeError('"ext" argument must be a string');
195
- assertPath(path);
196
- var start = 0, end = -1, matchedSlash = true, i;
197
- if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
198
- if (ext.length === path.length && ext === path)
199
- return "";
200
- var extIdx = ext.length - 1, firstNonSlashEnd = -1;
201
- for (i = path.length - 1;i >= 0; --i) {
202
- var code = path.charCodeAt(i);
203
- if (code === 47) {
204
- if (!matchedSlash) {
205
- start = i + 1;
206
- break;
207
- }
208
- } else {
209
- if (firstNonSlashEnd === -1)
210
- matchedSlash = false, firstNonSlashEnd = i + 1;
211
- if (extIdx >= 0)
212
- if (code === ext.charCodeAt(extIdx)) {
213
- if (--extIdx === -1)
214
- end = i;
215
- } else
216
- extIdx = -1, end = firstNonSlashEnd;
217
- }
218
- }
219
- if (start === end)
220
- end = firstNonSlashEnd;
221
- else if (end === -1)
222
- end = path.length;
223
- return path.slice(start, end);
224
- } else {
225
- for (i = path.length - 1;i >= 0; --i)
226
- if (path.charCodeAt(i) === 47) {
227
- if (!matchedSlash) {
228
- start = i + 1;
229
- break;
230
- }
231
- } else if (end === -1)
232
- matchedSlash = false, end = i + 1;
233
- if (end === -1)
234
- return "";
235
- return path.slice(start, end);
236
- }
237
- }
238
- function extname(path) {
239
- assertPath(path);
240
- var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
241
- for (var i = path.length - 1;i >= 0; --i) {
242
- var code = path.charCodeAt(i);
243
- if (code === 47) {
244
- if (!matchedSlash) {
245
- startPart = i + 1;
246
- break;
247
- }
248
- continue;
249
- }
250
- if (end === -1)
251
- matchedSlash = false, end = i + 1;
252
- if (code === 46) {
253
- if (startDot === -1)
254
- startDot = i;
255
- else if (preDotState !== 1)
256
- preDotState = 1;
257
- } else if (startDot !== -1)
258
- preDotState = -1;
259
- }
260
- if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
261
- return "";
262
- return path.slice(startDot, end);
263
- }
264
- function format(pathObject) {
265
- if (pathObject === null || typeof pathObject !== "object")
266
- throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
267
- return _format("/", pathObject);
268
- }
269
- function parse(path) {
270
- assertPath(path);
271
- var ret = { root: "", dir: "", base: "", ext: "", name: "" };
272
- if (path.length === 0)
273
- return ret;
274
- var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
275
- if (isAbsolute2)
276
- ret.root = "/", start = 1;
277
- else
278
- start = 0;
279
- var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
280
- for (;i >= start; --i) {
281
- if (code = path.charCodeAt(i), code === 47) {
282
- if (!matchedSlash) {
283
- startPart = i + 1;
284
- break;
285
- }
286
- continue;
287
- }
288
- if (end === -1)
289
- matchedSlash = false, end = i + 1;
290
- if (code === 46) {
291
- if (startDot === -1)
292
- startDot = i;
293
- else if (preDotState !== 1)
294
- preDotState = 1;
295
- } else if (startDot !== -1)
296
- preDotState = -1;
297
- }
298
- if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
299
- if (end !== -1)
300
- if (startPart === 0 && isAbsolute2)
301
- ret.base = ret.name = path.slice(1, end);
302
- else
303
- ret.base = ret.name = path.slice(startPart, end);
304
- } else {
305
- if (startPart === 0 && isAbsolute2)
306
- ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
307
- else
308
- ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
309
- ret.ext = path.slice(startDot, end);
310
- }
311
- if (startPart > 0)
312
- ret.dir = path.slice(0, startPart - 1);
313
- else if (isAbsolute2)
314
- ret.dir = "/";
315
- return ret;
316
- }
317
- var sep = "/";
318
- var delimiter = ":";
319
- var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
320
-
321
1
  // src/source-analysis.ts
2
+ import { posix } from "node:path";
322
3
  import ts from "typescript";
323
4
  var SDK = "@sentry/api";
324
5
  var API_PREFIX = /^\/api\/\d+(?=\/)/;
@@ -327,30 +8,35 @@ function unwrap(node) {
327
8
  return ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node) || ts.isNonNullExpression(node) ? unwrap(node.expression) : node;
328
9
  }
329
10
  function bindsName(binding, name) {
330
- return ts.isIdentifier(binding) ? binding.text === name : binding.elements.some((element) => ts.isBindingElement(element) && bindsName(element.name, name));
11
+ return ts.isIdentifier(binding) ? binding.text === name : binding.elements.some(
12
+ (element) => ts.isBindingElement(element) && bindsName(element.name, name)
13
+ );
331
14
  }
332
15
  function lexicalDeclaration(node, includeSource = false) {
333
- for (let parent = node.parent;parent && (includeSource || !ts.isSourceFile(parent)); parent = parent.parent) {
16
+ for (let parent = node.parent; parent && (includeSource || !ts.isSourceFile(parent)); parent = parent.parent) {
334
17
  if (ts.isFunctionLike(parent)) {
335
- const parameter = parent.parameters.find((parameter2) => bindsName(parameter2.name, node.text));
336
- if (parameter)
337
- return parameter;
18
+ const parameter = parent.parameters.find(
19
+ (parameter2) => bindsName(parameter2.name, node.text)
20
+ );
21
+ if (parameter) return parameter;
338
22
  }
339
23
  if ((ts.isFunctionExpression(parent) || ts.isClassExpression(parent)) && parent.name?.text === node.text)
340
24
  return parent;
341
25
  if (ts.isCatchClause(parent) && parent.variableDeclaration && bindsName(parent.variableDeclaration.name, node.text))
342
26
  return parent.variableDeclaration;
343
27
  if ((ts.isForStatement(parent) || ts.isForOfStatement(parent) || ts.isForInStatement(parent)) && parent.initializer && ts.isVariableDeclarationList(parent.initializer)) {
344
- const declaration = parent.initializer.declarations.find((declaration2) => bindsName(declaration2.name, node.text));
345
- if (declaration)
346
- return declaration;
28
+ const declaration = parent.initializer.declarations.find(
29
+ (declaration2) => bindsName(declaration2.name, node.text)
30
+ );
31
+ if (declaration) return declaration;
347
32
  }
348
33
  if (ts.isBlock(parent) || ts.isSourceFile(parent)) {
349
34
  for (const statement of parent.statements) {
350
35
  if (ts.isVariableStatement(statement)) {
351
- const declaration = statement.declarationList.declarations.find((declaration2) => bindsName(declaration2.name, node.text));
352
- if (declaration)
353
- return declaration;
36
+ const declaration = statement.declarationList.declarations.find(
37
+ (declaration2) => bindsName(declaration2.name, node.text)
38
+ );
39
+ if (declaration) return declaration;
354
40
  }
355
41
  if ((ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === node.text)
356
42
  return statement;
@@ -360,9 +46,8 @@ function lexicalDeclaration(node, includeSource = false) {
360
46
  return;
361
47
  }
362
48
  function sourceModule(file, specifier, sources) {
363
- if (!specifier.startsWith("."))
364
- return specifier;
365
- const target = posix.normalize(posix.join(dirname(file), specifier));
49
+ if (!specifier.startsWith(".")) return specifier;
50
+ const target = posix.normalize(posix.join(posix.dirname(file), specifier));
366
51
  const extension = posix.extname(target);
367
52
  const candidates = extension === ".js" ? [target.replace(/\.js$/, ".ts"), target.replace(/\.js$/, ".tsx"), target] : extension ? [target] : [target, `${target}.ts`, `${target}.tsx`, posix.join(target, "index.ts"), posix.join(target, "index.tsx")];
368
53
  return candidates.find((candidate) => sources.has(candidate)) ?? target;
@@ -371,16 +56,19 @@ function parseModule(file, text, sources) {
371
56
  const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true);
372
57
  const mod = {
373
58
  source,
374
- imports: new Map,
375
- exports: new Map,
59
+ imports: /* @__PURE__ */ new Map(),
60
+ exports: /* @__PURE__ */ new Map(),
376
61
  stars: [],
377
- declarations: new Map
62
+ declarations: /* @__PURE__ */ new Map()
378
63
  };
379
64
  for (const statement of source.statements) {
380
65
  if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
381
- if (statement.importClause?.isTypeOnly)
382
- continue;
383
- const target = sourceModule(file, statement.moduleSpecifier.text, sources);
66
+ if (statement.importClause?.isTypeOnly) continue;
67
+ const target = sourceModule(
68
+ file,
69
+ statement.moduleSpecifier.text,
70
+ sources
71
+ );
384
72
  const defaultImport = statement.importClause?.name;
385
73
  if (defaultImport)
386
74
  mod.imports.set(defaultImport.text, { file: target, name: "default" });
@@ -400,8 +88,7 @@ function parseModule(file, text, sources) {
400
88
  }
401
89
  if (ts.isExportDeclaration(statement) && !statement.isTypeOnly) {
402
90
  const target = statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier) ? sourceModule(file, statement.moduleSpecifier.text, sources) : file;
403
- if (!statement.exportClause)
404
- mod.stars.push(target);
91
+ if (!statement.exportClause) mod.stars.push(target);
405
92
  else if (ts.isNamedExports(statement.exportClause)) {
406
93
  for (const binding of statement.exportClause.elements) {
407
94
  if (!binding.isTypeOnly)
@@ -413,7 +100,7 @@ function parseModule(file, text, sources) {
413
100
  }
414
101
  continue;
415
102
  }
416
- const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;
103
+ const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : void 0;
417
104
  const isDefault = modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword) || ts.isExportAssignment(statement) && !statement.isExportEquals;
418
105
  const nodes = [];
419
106
  if (ts.isFunctionDeclaration(statement) && statement.body && (statement.name || isDefault))
@@ -429,12 +116,12 @@ function parseModule(file, text, sources) {
429
116
  for (const [name, node] of nodes) {
430
117
  mod.declarations.set(name, {
431
118
  node,
432
- refs: new Set,
433
- calls: new Set,
119
+ refs: /* @__PURE__ */ new Set(),
120
+ calls: /* @__PURE__ */ new Set(),
434
121
  usage: { operations: [], unresolvedRequests: [], methods: [] },
435
122
  boundary: false,
436
- factories: new Set,
437
- flags: new Set
123
+ factories: /* @__PURE__ */ new Set(),
124
+ flags: /* @__PURE__ */ new Set()
438
125
  });
439
126
  if (isDefault)
440
127
  mod.exports.set("default", { file, name });
@@ -448,150 +135,130 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
448
135
  const boundaries = new Set(options.boundaries);
449
136
  const requests = new Map(options.requests?.map((request) => [request.functionName, request]));
450
137
  const declarationFlags = new Set(options.declarationFlags);
451
- const modules = new Map([...sources].map(([file, text]) => [
452
- file,
453
- parseModule(file, text, sources)
454
- ]));
455
- const sdk = new Map(operations.map((operation) => [operation.functionName, operation]));
456
- const identities = new Map;
457
- const pathKey = (path) => `/${path.replace(API_PREFIX, "").split("/").filter(Boolean).join("/")}/`.replace(PATH_PARAMETER, "{}");
138
+ const modules = new Map(
139
+ [...sources].map(([file, text]) => [
140
+ file,
141
+ parseModule(file, text, sources)
142
+ ])
143
+ );
144
+ const sdk = new Map(
145
+ operations.map((operation) => [operation.functionName, operation])
146
+ );
147
+ const identities = /* @__PURE__ */ new Map();
148
+ const pathKey = (path) => `/${path.replace(API_PREFIX, "").split("/").filter(Boolean).join("/")}/`.replace(
149
+ PATH_PARAMETER,
150
+ "{}"
151
+ );
458
152
  for (const operation of operations) {
459
153
  const key = `${operation.method}:${pathKey(operation.path)}`;
460
154
  identities.set(key, [...identities.get(key) ?? [], operation]);
461
155
  }
462
- function resolve2(binding, exported = false, seen = new Set) {
463
- if (binding.file === SDK)
464
- return binding;
156
+ function resolve(binding, exported = false, seen = /* @__PURE__ */ new Set()) {
157
+ if (binding.file === SDK) return binding;
465
158
  const key = `${binding.file}#${binding.name}#${exported}`;
466
- if (seen.has(key))
467
- return;
159
+ if (seen.has(key)) return;
468
160
  seen.add(key);
469
161
  const mod = modules.get(binding.file);
470
- if (!mod)
471
- return;
162
+ if (!mod) return;
472
163
  if (!exported) {
473
- if (mod.declarations.has(binding.name))
474
- return binding;
164
+ if (mod.declarations.has(binding.name)) return binding;
475
165
  const imported = mod.imports.get(binding.name);
476
- return imported ? resolve2(imported, true, seen) : undefined;
166
+ return imported ? resolve(imported, true, seen) : void 0;
477
167
  }
478
168
  const next = mod.exports.get(binding.name);
479
- if (next)
480
- return resolve2(next, next.file !== binding.file, seen);
481
- if (binding.name === "default")
482
- return;
169
+ if (next) return resolve(next, next.file !== binding.file, seen);
170
+ if (binding.name === "default") return;
483
171
  for (const target of mod.stars) {
484
- const found = resolve2({ file: target, name: binding.name }, true, seen);
485
- if (found)
486
- return found;
172
+ const found = resolve({ file: target, name: binding.name }, true, seen);
173
+ if (found) return found;
487
174
  }
488
175
  return;
489
176
  }
490
177
  function bindingFor(file, node) {
491
178
  const mod = modules.get(file);
492
179
  if (ts.isIdentifier(node)) {
493
- if (lexicalDeclaration(node))
494
- return;
180
+ if (lexicalDeclaration(node)) return;
495
181
  const imported = mod.imports.get(node.text);
496
- return imported ? resolve2(imported, true) ?? (!modules.has(imported.file) ? imported : undefined) : resolve2({ file, name: node.text });
182
+ return imported ? resolve(imported, true) ?? (!modules.has(imported.file) ? imported : void 0) : resolve({ file, name: node.text });
497
183
  }
498
184
  if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && !lexicalDeclaration(node.expression)) {
499
185
  const namespace = mod.imports.get(node.expression.text);
500
186
  if (namespace?.name === "*")
501
- return resolve2({ file: namespace.file, name: node.name.text }, true);
187
+ return resolve({ file: namespace.file, name: node.name.text }, true);
502
188
  }
503
189
  return;
504
190
  }
505
191
  function callableBinding(binding) {
506
- const seen = new Set;
192
+ const seen = /* @__PURE__ */ new Set();
507
193
  while (binding?.name === "default") {
508
194
  const key = `${binding.file}#${binding.name}`;
509
- if (seen.has(key))
510
- break;
195
+ if (seen.has(key)) break;
511
196
  seen.add(key);
512
197
  const declaration = modules.get(binding.file)?.declarations.get(binding.name);
513
- if (!declaration)
514
- break;
198
+ if (!declaration) break;
515
199
  const node = unwrap(declaration.node);
516
- if (!ts.isIdentifier(node))
517
- break;
200
+ if (!ts.isIdentifier(node)) break;
518
201
  const target = bindingFor(binding.file, node);
519
- if (!target)
520
- break;
202
+ if (!target) break;
521
203
  binding = target;
522
204
  }
523
205
  return binding;
524
206
  }
525
207
  function initializer(node) {
526
- if (!ts.isIdentifier(node))
527
- return;
208
+ if (!ts.isIdentifier(node)) return;
528
209
  const declaration = lexicalDeclaration(node, true);
529
- return declaration && ts.isVariableDeclaration(declaration) && ts.isIdentifier(declaration.name) && ts.isVariableDeclarationList(declaration.parent) && declaration.parent.flags & ts.NodeFlags.Const ? declaration.initializer : undefined;
210
+ return declaration && ts.isVariableDeclaration(declaration) && ts.isIdentifier(declaration.name) && ts.isVariableDeclarationList(declaration.parent) && declaration.parent.flags & ts.NodeFlags.Const ? declaration.initializer : void 0;
530
211
  }
531
- function value(node, template = false, seen = new Set) {
532
- if (!node || seen.has(node))
533
- return;
212
+ function value(node, template = false, seen = /* @__PURE__ */ new Set()) {
213
+ if (!node || seen.has(node)) return;
534
214
  seen.add(node);
535
215
  node = unwrap(node);
536
216
  if (ts.isStringLiteralLike(node) || ts.isNumericLiteral(node))
537
217
  return node.text;
538
- if (node.kind === ts.SyntaxKind.TrueKeyword)
539
- return "true";
540
- if (node.kind === ts.SyntaxKind.FalseKeyword)
541
- return "false";
218
+ if (node.kind === ts.SyntaxKind.TrueKeyword) return "true";
219
+ if (node.kind === ts.SyntaxKind.FalseKeyword) return "false";
542
220
  if (ts.isIdentifier(node))
543
221
  return value(initializer(node), template, seen);
544
222
  if (ts.isTemplateExpression(node)) {
545
223
  let result2 = node.head.text;
546
224
  for (const span of node.templateSpans) {
547
225
  const part = value(span.expression, false, new Set(seen));
548
- if (part === undefined && !template)
549
- return;
226
+ if (part === void 0 && !template) return;
550
227
  result2 += (part ?? "{}") + span.literal.text;
551
228
  }
552
229
  return result2;
553
230
  }
554
231
  return;
555
232
  }
556
- function property(node, name, seen = new Set) {
557
- if (node == null)
558
- return node;
559
- if (seen.has(node))
560
- return null;
233
+ function property(node, name, seen = /* @__PURE__ */ new Set()) {
234
+ if (node == null) return node;
235
+ if (seen.has(node)) return null;
561
236
  seen.add(node);
562
237
  node = unwrap(node);
563
238
  if (ts.isIdentifier(node)) {
564
239
  const initial = initializer(node);
565
240
  return initial ? property(initial, name, seen) : null;
566
241
  }
567
- if (!ts.isObjectLiteralExpression(node))
568
- return null;
242
+ if (!ts.isObjectLiteralExpression(node)) return null;
569
243
  for (const member of [...node.properties].reverse()) {
570
244
  if (ts.isSpreadAssignment(member)) {
571
245
  const found = property(member.expression, name, new Set(seen));
572
- if (found !== undefined)
573
- return found;
246
+ if (found !== void 0) return found;
574
247
  continue;
575
248
  }
576
249
  const key = ts.isComputedPropertyName(member.name) ? value(member.name.expression) : member.name.text;
577
- if (key === undefined)
578
- return null;
579
- if (key !== name)
580
- continue;
581
- if (ts.isPropertyAssignment(member))
582
- return member.initializer;
583
- if (ts.isShorthandPropertyAssignment(member))
584
- return member.name;
250
+ if (key === void 0) return null;
251
+ if (key !== name) continue;
252
+ if (ts.isPropertyAssignment(member)) return member.initializer;
253
+ if (ts.isShorthandPropertyAssignment(member)) return member.name;
585
254
  return null;
586
255
  }
587
256
  return;
588
257
  }
589
- function queryTerms(node, seen = new Set) {
590
- if (!node || seen.has(node))
591
- return;
258
+ function queryTerms(node, seen = /* @__PURE__ */ new Set()) {
259
+ if (!node || seen.has(node)) return;
592
260
  const exact = value(node);
593
- if (exact !== undefined)
594
- return exact;
261
+ if (exact !== void 0) return exact;
595
262
  seen.add(node);
596
263
  node = unwrap(node);
597
264
  if (ts.isIdentifier(node))
@@ -603,10 +270,9 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
603
270
  let array = node.expression.expression;
604
271
  if (ts.isCallExpression(array) && ts.isPropertyAccessExpression(array.expression) && array.expression.name.text === "filter" && array.arguments[0]?.getText() === "Boolean")
605
272
  array = array.expression.expression;
606
- if (!ts.isArrayLiteralExpression(array))
607
- return;
273
+ if (!ts.isArrayLiteralExpression(array)) return;
608
274
  const terms = array.elements.map((item) => value(item)).filter((term) => !!term);
609
- return terms.length ? terms.join(" ") : undefined;
275
+ return terms.length ? terms.join(" ") : void 0;
610
276
  }
611
277
  function queryContext(requestOptions, key) {
612
278
  const query = property(requestOptions, key);
@@ -614,56 +280,49 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
614
280
  for (const name of options.queryParameters ?? []) {
615
281
  const expression = property(query, name);
616
282
  const text = name === "query" ? queryTerms(expression) : value(expression);
617
- if (text)
618
- result2[name] = text;
283
+ if (text) result2[name] = text;
619
284
  }
620
- return Object.keys(result2).length ? result2 : undefined;
285
+ return Object.keys(result2).length ? result2 : void 0;
621
286
  }
622
287
  for (const [file, mod] of modules) {
623
288
  for (const declaration of mod.declarations.values()) {
624
- let visit = function(node) {
625
- if (ts.isTypeNode(node))
626
- return;
289
+ let visit2 = function(node) {
290
+ if (ts.isTypeNode(node)) return;
627
291
  if (ts.isPropertyAssignment(node) && declarationFlags.has(node.name.getText()) && node.initializer.kind === ts.SyntaxKind.TrueKeyword && property(node.parent, node.name.getText()) === node.initializer)
628
292
  declaration.flags.add(node.name.getText());
629
293
  if (ts.isPropertyAssignment(node) && node.name.getText() === "method") {
630
294
  const method = value(node.initializer);
631
- if (method)
632
- declaration.usage.methods.push(method.toUpperCase());
295
+ if (method) declaration.usage.methods.push(method.toUpperCase());
633
296
  }
634
297
  if (ts.isCallExpression(node)) {
635
298
  const reference = bindingFor(file, node.expression);
636
- if (reference)
637
- declaration.calls.add(`${reference.file}#${reference.name}`);
299
+ if (reference) declaration.calls.add(`${reference.file}#${reference.name}`);
638
300
  const binding = callableBinding(reference);
639
301
  const name = binding?.name ?? (ts.isIdentifier(node.expression) && !lexicalDeclaration(node.expression) ? node.expression.text : "");
640
302
  if (boundaries.has(name)) {
641
303
  declaration.boundary = true;
642
304
  declaration.factories.add(name);
643
- for (const argument of node.arguments)
644
- visit(argument);
305
+ for (const argument of node.arguments) visit2(argument);
645
306
  return;
646
307
  }
647
- const operation = binding?.file === SDK ? sdk.get(name) : undefined;
308
+ const operation = binding?.file === SDK ? sdk.get(name) : void 0;
648
309
  if (operation) {
649
310
  declaration.usage.operations.push({
650
311
  ...operation,
651
312
  query: queryContext(node.arguments[0], "query")
652
313
  });
653
314
  declaration.usage.methods.push(operation.method);
654
- for (const argument of node.arguments)
655
- visit(argument);
315
+ for (const argument of node.arguments) visit2(argument);
656
316
  return;
657
317
  }
658
318
  const request = requests.get(name);
659
319
  if (request) {
660
320
  const requestOptions = node.arguments[request.optionsArgument];
661
321
  const methodExpression = property(requestOptions, "method");
662
- const method = methodExpression === undefined ? (request.defaultMethod ?? "GET").toUpperCase() : value(methodExpression)?.toUpperCase();
322
+ const method = methodExpression === void 0 ? (request.defaultMethod ?? "GET").toUpperCase() : value(methodExpression)?.toUpperCase();
663
323
  const path = value(node.arguments[request.pathArgument], true);
664
324
  const matches = method && path ? identities.get(`${method}:${pathKey(path)}`) ?? [] : [];
665
- if (method)
666
- declaration.usage.methods.push(method);
325
+ if (method) declaration.usage.methods.push(method);
667
326
  if (matches.length === 1)
668
327
  declaration.usage.operations.push({
669
328
  ...matches[0],
@@ -677,8 +336,7 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
677
336
  path,
678
337
  reason: !method || !path ? "Dynamic request identity" : matches.length ? "Ambiguous catalog path" : "Request is not in the public catalog"
679
338
  });
680
- for (const argument of node.arguments)
681
- visit(argument);
339
+ for (const argument of node.arguments) visit2(argument);
682
340
  return;
683
341
  }
684
342
  }
@@ -688,21 +346,27 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
688
346
  if (!isName) {
689
347
  const binding = bindingFor(file, node);
690
348
  if (binding && !boundaries.has(binding.name)) {
691
- const operation = binding.file === SDK ? sdk.get(binding.name) : undefined;
349
+ const operation = binding.file === SDK ? sdk.get(binding.name) : void 0;
692
350
  if (operation) {
693
351
  declaration.usage.operations.push(operation);
694
352
  declaration.usage.methods.push(operation.method);
695
- } else
696
- declaration.refs.add(`${binding.file}#${binding.name}`);
353
+ } else declaration.refs.add(`${binding.file}#${binding.name}`);
697
354
  }
698
355
  }
699
356
  }
700
- node.forEachChild(visit);
357
+ node.forEachChild(visit2);
701
358
  };
702
- visit(declaration.node);
359
+ var visit = visit2;
360
+ visit2(declaration.node);
703
361
  }
704
362
  }
705
- const declarations = new Map([...modules].flatMap(([file, mod]) => [...mod.declarations].map(([name, declaration]) => [`${file}#${name}`, declaration])));
363
+ const declarations = new Map(
364
+ [...modules].flatMap(
365
+ ([file, mod]) => [...mod.declarations].map(
366
+ ([name, declaration]) => [`${file}#${name}`, declaration]
367
+ )
368
+ )
369
+ );
706
370
  function unique(items) {
707
371
  return [
708
372
  ...new Map(items.map((item) => [JSON.stringify(item), item])).values()
@@ -723,17 +387,14 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
723
387
  const child = declarations.get(ref);
724
388
  if (!child?.boundary || !declaration.calls.has(ref) && !isAlias(declaration, ref))
725
389
  continue;
726
- if (!declaration.boundary)
727
- changed = true;
390
+ if (!declaration.boundary) changed = true;
728
391
  declaration.boundary = true;
729
392
  for (const factory of child.factories) {
730
- if (!declaration.factories.has(factory))
731
- changed = true;
393
+ if (!declaration.factories.has(factory)) changed = true;
732
394
  declaration.factories.add(factory);
733
395
  }
734
396
  for (const flag of child.flags) {
735
- if (!declaration.flags.has(flag))
736
- changed = true;
397
+ if (!declaration.flags.has(flag)) changed = true;
737
398
  declaration.flags.add(flag);
738
399
  }
739
400
  }
@@ -746,24 +407,26 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
746
407
  const before = JSON.stringify(declaration.usage);
747
408
  for (const ref of declaration.refs) {
748
409
  const child = declarations.get(ref);
749
- if (!child)
750
- continue;
410
+ if (!child) continue;
751
411
  if (child.boundary && !ts.isFunctionLike(unwrap(child.node)) && !isAlias(declaration, ref))
752
412
  continue;
753
413
  declaration.usage.operations.push(...child.usage.operations);
754
- declaration.usage.unresolvedRequests.push(...child.usage.unresolvedRequests);
414
+ declaration.usage.unresolvedRequests.push(
415
+ ...child.usage.unresolvedRequests
416
+ );
755
417
  declaration.usage.methods.push(...child.usage.methods);
756
418
  }
757
419
  declaration.usage.operations = unique(declaration.usage.operations);
758
- declaration.usage.unresolvedRequests = unique(declaration.usage.unresolvedRequests);
420
+ declaration.usage.unresolvedRequests = unique(
421
+ declaration.usage.unresolvedRequests
422
+ );
759
423
  declaration.usage.methods = unique(declaration.usage.methods);
760
424
  changed ||= before !== JSON.stringify(declaration.usage);
761
425
  }
762
426
  }
763
- const result = { exports: new Map, boundaries: [] };
764
- function exportNames(file, seen = new Set) {
765
- if (seen.has(file))
766
- return [];
427
+ const result = { exports: /* @__PURE__ */ new Map(), boundaries: [] };
428
+ function exportNames(file, seen = /* @__PURE__ */ new Set()) {
429
+ if (seen.has(file)) return [];
767
430
  seen.add(file);
768
431
  const mod = modules.get(file);
769
432
  return mod ? [
@@ -772,12 +435,11 @@ function analyzeSourceApiUsage(sources, operations, options = {}) {
772
435
  ] : [];
773
436
  }
774
437
  for (const file of modules.keys()) {
775
- const exported = new Map;
438
+ const exported = /* @__PURE__ */ new Map();
776
439
  for (const name of new Set(exportNames(file))) {
777
- const binding = resolve2({ file, name }, true);
440
+ const binding = resolve({ file, name }, true);
778
441
  const declaration = binding && declarations.get(`${binding.file}#${binding.name}`);
779
- if (!declaration)
780
- continue;
442
+ if (!declaration) continue;
781
443
  exported.set(name, declaration.usage);
782
444
  if (declaration.boundary)
783
445
  result.boundaries.push({