@flagshark/core 1.5.0 → 2.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.
- package/README.md +8 -6
- package/dist/config/schema.d.ts +112 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +64 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/detection/detectors/typescript.d.ts.map +1 -1
- package/dist/detection/detectors/typescript.js +41 -0
- package/dist/detection/detectors/typescript.js.map +1 -1
- package/dist/detection/feature-flag.d.ts +28 -0
- package/dist/detection/feature-flag.d.ts.map +1 -1
- package/dist/detection/helpers.d.ts +16 -0
- package/dist/detection/helpers.d.ts.map +1 -1
- package/dist/detection/helpers.js +117 -6
- package/dist/detection/helpers.js.map +1 -1
- package/dist/detection/import-graph.d.ts +234 -0
- package/dist/detection/import-graph.d.ts.map +1 -0
- package/dist/detection/import-graph.js +641 -0
- package/dist/detection/import-graph.js.map +1 -0
- package/dist/detection/interface.d.ts +57 -0
- package/dist/detection/interface.d.ts.map +1 -1
- package/dist/detection/interface.js.map +1 -1
- package/dist/detection/polyglot-analyzer.d.ts +8 -0
- package/dist/detection/polyglot-analyzer.d.ts.map +1 -1
- package/dist/detection/polyglot-analyzer.js +2 -0
- package/dist/detection/polyglot-analyzer.js.map +1 -1
- package/dist/detection/tree-sitter/engine.d.ts.map +1 -1
- package/dist/detection/tree-sitter/engine.js +62 -15
- package/dist/detection/tree-sitter/engine.js.map +1 -1
- package/dist/detection/tree-sitter/parser-cache.d.ts +20 -0
- package/dist/detection/tree-sitter/parser-cache.d.ts.map +1 -1
- package/dist/detection/tree-sitter/parser-cache.js +32 -1
- package/dist/detection/tree-sitter/parser-cache.js.map +1 -1
- package/dist/output/json.d.ts.map +1 -1
- package/dist/output/json.js +28 -0
- package/dist/output/json.js.map +1 -1
- package/dist/output/markdown.d.ts.map +1 -1
- package/dist/output/markdown.js +47 -1
- package/dist/output/markdown.js.map +1 -1
- package/dist/output/text.d.ts.map +1 -1
- package/dist/output/text.js +85 -0
- package/dist/output/text.js.map +1 -1
- package/dist/providers/cross-reference.d.ts +24 -2
- package/dist/providers/cross-reference.d.ts.map +1 -1
- package/dist/providers/cross-reference.js +74 -7
- package/dist/providers/cross-reference.js.map +1 -1
- package/dist/providers/interface.d.ts +89 -2
- package/dist/providers/interface.d.ts.map +1 -1
- package/dist/providers/launchdarkly/client.d.ts +12 -0
- package/dist/providers/launchdarkly/client.d.ts.map +1 -1
- package/dist/providers/launchdarkly/client.js +163 -23
- package/dist/providers/launchdarkly/client.js.map +1 -1
- package/dist/providers/launchdarkly/types.d.ts +286 -0
- package/dist/providers/launchdarkly/types.d.ts.map +1 -1
- package/dist/providers/launchdarkly/types.js +56 -0
- package/dist/providers/launchdarkly/types.js.map +1 -1
- package/dist/providers/orchestrate.d.ts +34 -2
- package/dist/providers/orchestrate.d.ts.map +1 -1
- package/dist/providers/orchestrate.js +59 -7
- package/dist/providers/orchestrate.js.map +1 -1
- package/dist/scan-repo.d.ts +30 -2
- package/dist/scan-repo.d.ts.map +1 -1
- package/dist/scan-repo.js +290 -4
- package/dist/scan-repo.js.map +1 -1
- package/dist/staleness.d.ts +33 -3
- package/dist/staleness.d.ts.map +1 -1
- package/dist/staleness.js +60 -13
- package/dist/staleness.js.map +1 -1
- package/package.json +1 -1
|
@@ -155,12 +155,33 @@ export function detectFlagsWithRegex(filename, content, language, providers) {
|
|
|
155
155
|
}
|
|
156
156
|
const providerName = provider.name;
|
|
157
157
|
const importPat = getImportPattern(provider);
|
|
158
|
-
// Import
|
|
159
|
-
//
|
|
158
|
+
// Import gate: skip this provider if the file doesn't import its SDK,
|
|
159
|
+
// UNLESS it carries a runtime-symbol that flags the SDK as present even
|
|
160
|
+
// without a static import. Providers with no importPattern (the legacy
|
|
161
|
+
// "Custom Feature Flags" catch-all) always run.
|
|
162
|
+
//
|
|
163
|
+
// Detected via runtimeSymbols are tagged below with `confidence: 'medium'`
|
|
164
|
+
// so downstream consumers can route them through review rather than
|
|
165
|
+
// auto-merge. See B2 design doc + the provider docstring for the
|
|
166
|
+
// false-positive trade-off.
|
|
167
|
+
let detectionConfidence = 'high';
|
|
160
168
|
if (importPat) {
|
|
161
|
-
|
|
169
|
+
// The import gate passes if EITHER the primary pattern OR any
|
|
170
|
+
// declared alias is present in the file. SDKs republished under a
|
|
171
|
+
// scoped name (e.g. `@launchdarkly/react-client-sdk`) rely on the
|
|
172
|
+
// alias list so the legacy unscoped form
|
|
173
|
+
// (`launchdarkly-react-client-sdk`) still triggers detection.
|
|
174
|
+
const importPatterns = [importPat, ...(provider.importAliases ?? [])];
|
|
175
|
+
const hasImport = importPatterns.some((pat) => content.includes(pat) || lines.some((line) => line.includes(pat)));
|
|
162
176
|
if (!hasImport) {
|
|
163
|
-
|
|
177
|
+
// Check whether the file matches any runtime-symbol pattern.
|
|
178
|
+
const runtimeHit = (provider.runtimeSymbols ?? []).some((sym) => content.includes(sym));
|
|
179
|
+
if (!runtimeHit) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
// Gate passed via runtime symbol — downgrade confidence so the
|
|
183
|
+
// flag's downstream treatment reflects the weaker signal.
|
|
184
|
+
detectionConfidence = 'medium';
|
|
164
185
|
}
|
|
165
186
|
}
|
|
166
187
|
for (const method of provider.methods) {
|
|
@@ -189,20 +210,89 @@ export function detectFlagsWithRegex(filename, content, language, providers) {
|
|
|
189
210
|
}
|
|
190
211
|
const flagKey = extractStringArgument(restOfContent, method.flagKeyIndex);
|
|
191
212
|
if (flagKey && isValidFlagKey(flagKey)) {
|
|
192
|
-
|
|
213
|
+
const flag = {
|
|
193
214
|
name: flagKey,
|
|
194
215
|
filePath: filename,
|
|
195
216
|
lineNumber: lineIdx + 1,
|
|
196
217
|
language,
|
|
197
218
|
provider: importPat || providerName,
|
|
198
|
-
}
|
|
219
|
+
};
|
|
220
|
+
// Only emit `confidence` when it's a non-default value. The
|
|
221
|
+
// FeatureFlag type documents `confidence` as optional with
|
|
222
|
+
// "absent = high", so omitting it for the common case keeps
|
|
223
|
+
// existing JSON consumers + test fixtures stable.
|
|
224
|
+
if (detectionConfidence !== 'high')
|
|
225
|
+
flag.confidence = detectionConfidence;
|
|
226
|
+
flags.push(flag);
|
|
199
227
|
}
|
|
200
228
|
}
|
|
201
229
|
}
|
|
202
230
|
}
|
|
231
|
+
// useFlagsHook: providers like the LaunchDarkly React SDK don't pass
|
|
232
|
+
// flag keys as call-site arguments. Instead, calling `useFlags()` returns
|
|
233
|
+
// an object whose keys ARE the flag names; consumers either destructure
|
|
234
|
+
// them or index into them. The positional-arg pipeline above can't see
|
|
235
|
+
// this shape. When a provider declares `useFlagsHook`, run a second pass
|
|
236
|
+
// that extracts destructured property names from `... = <hook>()` sites
|
|
237
|
+
// and emits each as a detected flag.
|
|
238
|
+
if (provider.useFlagsHook) {
|
|
239
|
+
const hookFlags = detectDestructuredHookFlags(filename, content, language, importPat || providerName, provider.useFlagsHook, detectionConfidence);
|
|
240
|
+
flags.push(...hookFlags);
|
|
241
|
+
}
|
|
203
242
|
}
|
|
204
243
|
return deduplicateFlags(flags);
|
|
205
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Extracts flag keys from destructured property names on a hook's return
|
|
247
|
+
* value. Handles the LaunchDarkly React SDK pattern (and any future hook
|
|
248
|
+
* with the same shape):
|
|
249
|
+
*
|
|
250
|
+
* const { showNewCheckout, oneClickPurchase } = useFlags()
|
|
251
|
+
* let { feature: aliased } = useFlags() // takes `feature`, not `aliased`
|
|
252
|
+
*
|
|
253
|
+
* Multi-line destructures are supported (the regex spans newlines). The
|
|
254
|
+
* line number reported is the line where the destructure begins.
|
|
255
|
+
*
|
|
256
|
+
* Identifiers that fail `isValidFlagKey` (numeric literals, reserved
|
|
257
|
+
* words) are dropped — this is the same gate the positional-arg path
|
|
258
|
+
* applies, kept consistent so downstream consumers see one rule.
|
|
259
|
+
*/
|
|
260
|
+
export function detectDestructuredHookFlags(filename, content, language, provider, hookName, confidence = 'high') {
|
|
261
|
+
const out = [];
|
|
262
|
+
const pattern = new RegExp(`(?:const|let|var)\\s*\\{\\s*([\\s\\S]*?)\\}\\s*=\\s*${escapeRegExp(hookName)}\\s*\\(\\s*\\)`, 'g');
|
|
263
|
+
let m;
|
|
264
|
+
while ((m = pattern.exec(content)) !== null) {
|
|
265
|
+
const lineNumber = content.slice(0, m.index).split('\n').length;
|
|
266
|
+
const inside = m[1];
|
|
267
|
+
// Strip line comments inside the destructure body before splitting on
|
|
268
|
+
// commas — otherwise a trailing `// note` would taint the last name.
|
|
269
|
+
const cleaned = inside
|
|
270
|
+
.split('\n')
|
|
271
|
+
.map((seg) => seg.replace(/\/\/.*$/, ''))
|
|
272
|
+
.join(' ');
|
|
273
|
+
for (const raw of cleaned.split(',')) {
|
|
274
|
+
const trimmed = raw.trim();
|
|
275
|
+
if (!trimmed)
|
|
276
|
+
continue;
|
|
277
|
+
// `originalName: alias` — the flag key is the SOURCE side (the
|
|
278
|
+
// property on the hook's return value), not the local alias.
|
|
279
|
+
const flagKey = trimmed.split(':')[0].trim();
|
|
280
|
+
if (isValidFlagKey(flagKey)) {
|
|
281
|
+
const flag = {
|
|
282
|
+
name: flagKey,
|
|
283
|
+
filePath: filename,
|
|
284
|
+
lineNumber,
|
|
285
|
+
language,
|
|
286
|
+
provider,
|
|
287
|
+
};
|
|
288
|
+
if (confidence !== 'high')
|
|
289
|
+
flag.confidence = confidence;
|
|
290
|
+
out.push(flag);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return out;
|
|
295
|
+
}
|
|
206
296
|
/** Builds a regex for a single method name that matches calls. */
|
|
207
297
|
function buildSingleMethodPattern(methodName) {
|
|
208
298
|
const escaped = escapeRegExp(methodName);
|
|
@@ -249,6 +339,20 @@ function getCallExpression(lines, startLine, startCol) {
|
|
|
249
339
|
/* v8 ignore next -- foundOpen is always true here: the matching regex requires '(' which startCol points to */
|
|
250
340
|
return foundOpen ? result : null;
|
|
251
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Characters that legitimate feature flag keys never contain. Real keys
|
|
344
|
+
* across LaunchDarkly, Unleash, PostHog, Statsig, Split.io, and the
|
|
345
|
+
* shakedown corpus are limited to letters, digits, underscores, dashes,
|
|
346
|
+
* dots, and colons. The chars below appear only when we've accidentally
|
|
347
|
+
* latched onto a regex literal, a URL fragment, or a string with parens.
|
|
348
|
+
*
|
|
349
|
+
* Surfaced by the PostHog shakedown: a TSX file contained the regex
|
|
350
|
+
* fragment `([^/]+)` which slipped through `isValidFlagKey` because the
|
|
351
|
+
* legacy check only rejected URL prefixes. The new key now reports as a
|
|
352
|
+
* false positive in flagshark's output — that's the bug this set guards
|
|
353
|
+
* against. See A2 in the shakedown bug inventory.
|
|
354
|
+
*/
|
|
355
|
+
const INVALID_FLAG_KEY_CHAR = /[()\[\]^$\\\s]/;
|
|
252
356
|
/** Checks whether a string looks like a valid feature flag key. */
|
|
253
357
|
export function isValidFlagKey(key) {
|
|
254
358
|
if (key.length === 0 || key.length > 256) {
|
|
@@ -260,6 +364,13 @@ export function isValidFlagKey(key) {
|
|
|
260
364
|
return false;
|
|
261
365
|
}
|
|
262
366
|
}
|
|
367
|
+
// Reject keys that look like regex literals, character classes, or contain
|
|
368
|
+
// whitespace — none of these are legitimate shapes for a feature flag key
|
|
369
|
+
// and they consistently indicate we've extracted the wrong string from a
|
|
370
|
+
// method call (e.g. `new RegExp('([^/]+)')` getting matched).
|
|
371
|
+
if (INVALID_FLAG_KEY_CHAR.test(key)) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
263
374
|
return true;
|
|
264
375
|
}
|
|
265
376
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/detection/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAKjD,yDAAyD;AACzD,MAAM,UAAU,kBAAkB,CAA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,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAA;QAChD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAClC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YAC3B,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight import-graph builder for TS/JS files.
|
|
3
|
+
*
|
|
4
|
+
* Goal: extend the existing "file imports a known SDK" detection gate to cover
|
|
5
|
+
* the common case where consumer files reach the SDK through a local wrapper —
|
|
6
|
+
* an internal `flag-resolver.ts`, a Pinia store, a custom React hook, a re-export
|
|
7
|
+
* barrel, etc. Without this, real codebases that hide the SDK behind an
|
|
8
|
+
* abstraction silently report 0 flags (see the pre-launch shakedown notes:
|
|
9
|
+
* Unleash at 4 of 62, n8n at 0 of many).
|
|
10
|
+
*
|
|
11
|
+
* Design — three deliberate compromises in service of "ship soon and don't add
|
|
12
|
+
* false positives":
|
|
13
|
+
*
|
|
14
|
+
* 1. **Regex import extraction, not tree-sitter.** The existing analyzer
|
|
15
|
+
* already parses each file once for flag detection; running a second
|
|
16
|
+
* tree-sitter pass for imports would roughly double scan time on a large
|
|
17
|
+
* monorepo. Three regexes cover ESM static imports, CJS require(), and
|
|
18
|
+
* dynamic import() with >95% coverage of real-world syntax. The misses
|
|
19
|
+
* (heavily multi-line imports, computed-string specifiers, etc.) only
|
|
20
|
+
* cost us some recall — they never add false positives because the gate
|
|
21
|
+
* still requires a *real* SDK string match downstream.
|
|
22
|
+
*
|
|
23
|
+
* 2. **Relative-path resolution only.** TypeScript path aliases
|
|
24
|
+
* (`@/foo` via tsconfig.paths), workspace `@scope/pkg` resolution, and
|
|
25
|
+
* package.json `exports` are out of scope. A user with path aliases will
|
|
26
|
+
* hit the same blind spot as today; we document it. The right fix is to
|
|
27
|
+
* read tsconfig.json and apply paths — separate workstream, not a Show HN
|
|
28
|
+
* blocker.
|
|
29
|
+
*
|
|
30
|
+
* 3. **Reverse-reachability BFS from SDK-importing seeds.** We propagate
|
|
31
|
+
* SDK provenance *away* from the SDK importers. A file is "in scope" iff
|
|
32
|
+
* it transitively imports something that imports an SDK. Cycle-safe via
|
|
33
|
+
* a "did the set actually grow?" check before requeueing — bounded
|
|
34
|
+
* O(edges × seeds) in the worst case.
|
|
35
|
+
*
|
|
36
|
+
* The output is consumed by PolyglotAnalyzer, which uses it to mark
|
|
37
|
+
* wrapper-consumer files as SDK-positive *for the gating step only* — actual
|
|
38
|
+
* flag-key extraction still goes through the same per-provider patterns, so
|
|
39
|
+
* precision stays the same as direct-import detection.
|
|
40
|
+
*/
|
|
41
|
+
import { Languages, type Language } from './interface.js';
|
|
42
|
+
/**
|
|
43
|
+
* Extracts every module specifier mentioned in a TS/JS file.
|
|
44
|
+
*
|
|
45
|
+
* @returns a deduplicated array of specifier strings, in the order first seen.
|
|
46
|
+
* Order is not load-bearing for the graph algorithm but makes test fixtures
|
|
47
|
+
* readable.
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractImports(content: string): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Extracts every module specifier mentioned in a Python file. Returns each
|
|
52
|
+
* specifier verbatim (including leading dots for relative imports). The
|
|
53
|
+
* graph's seed-matching logic compares the bare module name (everything
|
|
54
|
+
* before the first dot, e.g. `posthog` from `posthog.client`) against the
|
|
55
|
+
* SDK seed list.
|
|
56
|
+
*
|
|
57
|
+
* Multi-import lines like `import a, b, c` are split into individual
|
|
58
|
+
* specifiers; deduplicated within a file.
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractPythonImports(content: string): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Resolves a Python import specifier to a file path that exists in
|
|
63
|
+
* `fileSet`. Python relative imports use dot notation rather than `./`:
|
|
64
|
+
* - `from . import x` → same package as importer
|
|
65
|
+
* - `from .utils import x` → sibling module `utils` in same package
|
|
66
|
+
* - `from ..lib import x` → parent package's `lib`
|
|
67
|
+
* - `from .. import x` → parent package's `__init__.py`
|
|
68
|
+
*
|
|
69
|
+
* Absolute imports (`from posthog.client import x`) are NOT resolved into
|
|
70
|
+
* the file map — they reference installed packages outside the repo. Those
|
|
71
|
+
* get matched against the SDK seed list separately.
|
|
72
|
+
*
|
|
73
|
+
* Returns null for absolute imports or unresolvable paths.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolvePythonImport(importerPath: string, specifier: string, fileSet: ReadonlySet<string>): string | null;
|
|
76
|
+
/**
|
|
77
|
+
* Resolved tsconfig.json path aliases — `compilerOptions.baseUrl` plus the
|
|
78
|
+
* `compilerOptions.paths` map. Returned by `loadTsconfigAliases` and passed
|
|
79
|
+
* to `resolveImportPath` so transitive wrapper detection follows imports
|
|
80
|
+
* that go through tsconfig path mapping (e.g. `@/lib/featureFlags` →
|
|
81
|
+
* `src/lib/featureFlags`). Pre-fix this was a known recall gap on
|
|
82
|
+
* alias-heavy monorepos.
|
|
83
|
+
*/
|
|
84
|
+
export interface PathAliases {
|
|
85
|
+
/** Absolute path of the directory `paths` resolves against. */
|
|
86
|
+
baseUrl: string;
|
|
87
|
+
/**
|
|
88
|
+
* Each entry maps an alias key (with a trailing `/*` if any) to a list of
|
|
89
|
+
* candidate targets (also with their `/*`). Example tsconfig entry:
|
|
90
|
+
*
|
|
91
|
+
* "paths": { "@/*": ["src/*"], "@lib/*": ["src/lib/*", "vendor/lib/*"] }
|
|
92
|
+
*
|
|
93
|
+
* stores as `{ "@/*": ["src/*"], "@lib/*": ["src/lib/*", "vendor/lib/*"] }`.
|
|
94
|
+
*/
|
|
95
|
+
paths: Map<string, string[]>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Finds the nearest tsconfig.json (or jsconfig.json) at or above `root` and
|
|
99
|
+
* parses `compilerOptions.baseUrl` + `compilerOptions.paths`. Returns null
|
|
100
|
+
* if no config exists, the config has no path aliases, or the file fails
|
|
101
|
+
* to parse.
|
|
102
|
+
*
|
|
103
|
+
* Intentional limitations (documented so the recall ceiling is honest):
|
|
104
|
+
* - We do NOT follow `extends` chains. A tsconfig that inherits aliases
|
|
105
|
+
* from a parent project won't have them resolved here. Real fix would
|
|
106
|
+
* require a recursive resolver matching tsc's actual behaviour.
|
|
107
|
+
* - We only look at the first matching tsconfig walking up from `root`.
|
|
108
|
+
* Nested workspaces with distinct tsconfigs per package aren't handled
|
|
109
|
+
* specially — the outermost one wins. Sufficient for the typical
|
|
110
|
+
* "alias is in repo-root tsconfig" pattern.
|
|
111
|
+
*/
|
|
112
|
+
export declare function loadTsconfigAliases(root: string): PathAliases | null;
|
|
113
|
+
/**
|
|
114
|
+
* Tries to apply tsconfig path aliases to a bare-spec import. Returns the
|
|
115
|
+
* resolved absolute file path (if it exists in `fileSet`) or null.
|
|
116
|
+
*
|
|
117
|
+
* Two alias shapes are supported, matching tsc:
|
|
118
|
+
* - Wildcard: key ends with `/*`, target ends with `/*`. The portion
|
|
119
|
+
* after the alias prefix is substituted into the target wildcard.
|
|
120
|
+
* Example: alias `@/*` → `src/*`; specifier `@/lib/foo` resolves to
|
|
121
|
+
* `<baseUrl>/src/lib/foo`.
|
|
122
|
+
* - Exact: no `*`. The specifier matches the alias exactly and resolves
|
|
123
|
+
* to the literal target.
|
|
124
|
+
*/
|
|
125
|
+
export declare function resolveAliasedImport(specifier: string, aliases: PathAliases, fileSet: ReadonlySet<string>): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Resolves a relative or absolute import specifier to a file path that exists
|
|
128
|
+
* in `fileSet`. Returns null for bare specifiers (unless `aliases` provided
|
|
129
|
+
* and the specifier matches an alias) or unresolvable paths.
|
|
130
|
+
*
|
|
131
|
+
* Resolution order matches Node + TS behavior closely enough for our purposes:
|
|
132
|
+
* 1. Path aliases (when `aliases` provided) — `@/foo` → `src/foo`.
|
|
133
|
+
* 2. Exact match (`./foo.ts`).
|
|
134
|
+
* 3. With each candidate extension (`./foo` → `./foo.ts`).
|
|
135
|
+
* 4. As a directory with `index.<ext>` (`./foo` → `./foo/index.ts`).
|
|
136
|
+
* 5. TS-emitted `.js` rewritten to `.ts` (`./foo.js` → `./foo.ts`), which
|
|
137
|
+
* handles the verbatimModuleSyntax / NodeNext convention where TS source
|
|
138
|
+
* writes `.js` but the actual file is `.ts`. Same for `.jsx`/`.tsx`.
|
|
139
|
+
*/
|
|
140
|
+
export declare function resolveImportPath(importerPath: string, specifier: string, fileSet: ReadonlySet<string>, aliases?: PathAliases): string | null;
|
|
141
|
+
export interface ImportGraphOptions {
|
|
142
|
+
/**
|
|
143
|
+
* SDK package patterns that anchor the graph — typically the union of every
|
|
144
|
+
* provider's `importPattern` field across all enabled detectors
|
|
145
|
+
* (e.g. `['unleash-client', 'posthog-js', 'posthog-node', '@launchdarkly/...']`).
|
|
146
|
+
*
|
|
147
|
+
* A specifier counts as an SDK reference if it equals an entry exactly OR
|
|
148
|
+
* starts with `<entry>/` (handles SDK subpath imports like
|
|
149
|
+
* `launchdarkly-node-server-sdk/lib/foo`).
|
|
150
|
+
*/
|
|
151
|
+
seedSdkPatterns: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Returns whether a file path is a TS/JS source file the graph should walk.
|
|
154
|
+
* Used to skip Python/Go/etc. files in a polyglot file map without forcing
|
|
155
|
+
* callers to pre-filter.
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* Predicate that decides whether a file is in scope for the graph walk.
|
|
159
|
+
* Historically named `isTsJs` because TS/JS was the only supported
|
|
160
|
+
* surface — Python wrapper detection (B4) added .py to the in-scope
|
|
161
|
+
* set, and the implementation now dispatches extraction by extension
|
|
162
|
+
* inside the loop. The name is kept for back-compat; callers can pass
|
|
163
|
+
* `isScannedSourceFile` (which returns true for TS/JS + Python) when
|
|
164
|
+
* they want polyglot coverage, or `isTsJsFile` for TS/JS-only.
|
|
165
|
+
*/
|
|
166
|
+
isTsJs(filePath: string): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Optional tsconfig path aliases (returned by `loadTsconfigAliases`).
|
|
169
|
+
* When provided, `@/foo`-style imports are followed during the
|
|
170
|
+
* transitive expansion; without it, those imports stop at the alias
|
|
171
|
+
* boundary and wrapper detection under-counts. Documented recall
|
|
172
|
+
* limitation pre-fix.
|
|
173
|
+
*
|
|
174
|
+
* Path aliases apply only to TS/JS files; Python imports never route
|
|
175
|
+
* through tsconfig.
|
|
176
|
+
*/
|
|
177
|
+
aliases?: PathAliases;
|
|
178
|
+
}
|
|
179
|
+
export interface ImportGraphResult {
|
|
180
|
+
/**
|
|
181
|
+
* For each file in the input map (TS/JS only), the set of seed SDKs it
|
|
182
|
+
* reaches — directly or transitively through 1-N hops of relative imports.
|
|
183
|
+
* Files with no SDK reach are absent from the map (not present as empty set).
|
|
184
|
+
*/
|
|
185
|
+
transitiveSdks: Map<string, Set<string>>;
|
|
186
|
+
/** Diagnostics — useful for tests and to surface in --verbose output later. */
|
|
187
|
+
stats: {
|
|
188
|
+
/** TS/JS files walked. */
|
|
189
|
+
filesWalked: number;
|
|
190
|
+
/** Files that directly import at least one seed SDK. */
|
|
191
|
+
seedFiles: number;
|
|
192
|
+
/** Files in transitiveSdks (seedFiles + wrappers + transitive consumers). */
|
|
193
|
+
inScopeFiles: number;
|
|
194
|
+
/** Relative-import edges resolved successfully. */
|
|
195
|
+
edgesResolved: number;
|
|
196
|
+
/** Relative-import edges that couldn't be resolved to a file in the input. */
|
|
197
|
+
edgesUnresolved: number;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Builds the transitive SDK-reach map for a set of TS/JS files.
|
|
202
|
+
*
|
|
203
|
+
* Algorithm:
|
|
204
|
+
* 1. Walk every TS/JS file, extract module specifiers.
|
|
205
|
+
* 2. For each specifier: if it's a seed SDK → record direct SDK reach;
|
|
206
|
+
* if it's a relative path that resolves in the file map → add forward edge.
|
|
207
|
+
* 3. Build the reverse adjacency map (target → importers).
|
|
208
|
+
* 4. Seed the worklist with every directly-importing file. BFS outward
|
|
209
|
+
* through the reverse graph, propagating each importer's SDK set
|
|
210
|
+
* (union of all reachable importees). Requeue only when a set actually
|
|
211
|
+
* grew — this terminates on every cyclic import graph.
|
|
212
|
+
*/
|
|
213
|
+
export declare function buildImportGraph(files: ReadonlyMap<string, string>, opts: ImportGraphOptions): ImportGraphResult;
|
|
214
|
+
/**
|
|
215
|
+
* Returns true when the file path is a TS/JS source flagshark would parse.
|
|
216
|
+
* Mirrors the file-extension set used by TypeScriptDetector / JavaScriptDetector.
|
|
217
|
+
*/
|
|
218
|
+
/**
|
|
219
|
+
* True if the file is a Python source file the graph should walk.
|
|
220
|
+
* Mirrors the extension list of the Python detector — keep in sync.
|
|
221
|
+
*/
|
|
222
|
+
export declare function isPythonFile(filePath: string): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Polyglot scope predicate: true for TS/JS *and* Python source files.
|
|
225
|
+
* Pass this as `ImportGraphOptions.isTsJs` when you want the graph to
|
|
226
|
+
* walk Python wrappers too. Replaces the TS/JS-only check incrementally
|
|
227
|
+
* without forcing every caller to update.
|
|
228
|
+
*/
|
|
229
|
+
export declare function isScannedSourceFile(filePath: string): boolean;
|
|
230
|
+
export declare function isTsJsFile(filePath: string): boolean;
|
|
231
|
+
export declare const _TS_JS_EXTENSIONS_FOR_TESTS: string[];
|
|
232
|
+
export type { Language };
|
|
233
|
+
export { Languages };
|
|
234
|
+
//# sourceMappingURL=import-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-graph.d.ts","sourceRoot":"","sources":["../../src/detection/import-graph.ts"],"names":[],"mappings":"AAA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