@suss/adapter-typescript 0.22.3 → 0.23.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/dist/index.cjs +638 -397
- package/dist/index.d.cts +65 -3
- package/dist/index.d.ts +65 -3
- package/dist/index.js +323 -86
- package/package.json +11 -9
package/dist/index.d.cts
CHANGED
|
@@ -87,6 +87,15 @@ declare class ResolutionStore {
|
|
|
87
87
|
*/
|
|
88
88
|
explainCallable(value: Node, options?: ExplainCallableOptions): ExplainedResolution | null;
|
|
89
89
|
resolveObject(value: Node): Node | null;
|
|
90
|
+
/**
|
|
91
|
+
* The function a call returns: `app.use(requireCaller(config))`
|
|
92
|
+
* registers what the factory gives back. A separate question from
|
|
93
|
+
* `resolveCallable`, which keeps a call unresolved on purpose so an
|
|
94
|
+
* unwrapping answer wins; this one is asked only after that has
|
|
95
|
+
* declined. Two returned functions give null, like every other
|
|
96
|
+
* single-answer question here.
|
|
97
|
+
*/
|
|
98
|
+
resolveReturnedCallable(call: Node): Node | null;
|
|
90
99
|
/**
|
|
91
100
|
* For a value that is neither a function nor an object, such as a
|
|
92
101
|
* GraphQL document kept in a constant in another file.
|
|
@@ -193,6 +202,7 @@ declare class ResolutionStore {
|
|
|
193
202
|
*/
|
|
194
203
|
private seedValue;
|
|
195
204
|
private lookupObject;
|
|
205
|
+
private lookupReturned;
|
|
196
206
|
/**
|
|
197
207
|
* Two candidates give null, since ambiguity is nothing. The value
|
|
198
208
|
* itself is never a result either, or an identifier whose chain went
|
|
@@ -256,6 +266,21 @@ type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | M
|
|
|
256
266
|
*/
|
|
257
267
|
declare function collectAncestorBranches(terminalNode: Node, functionRoot: FunctionRoot): RawCondition[];
|
|
258
268
|
|
|
269
|
+
/**
|
|
270
|
+
* unfollowedCall.ts: naming the calls the reachable closure stops at.
|
|
271
|
+
*
|
|
272
|
+
* The closure follows a call by resolving its callee to a function with a
|
|
273
|
+
* body. When that fails the edge is dropped, and a unit whose body is full
|
|
274
|
+
* of dropped edges produces the same empty summary as a unit that does
|
|
275
|
+
* nothing. This module says which kind of stop a call site is. The
|
|
276
|
+
* reasons, and the gap each one leaves, are shared with every adapter.
|
|
277
|
+
*
|
|
278
|
+
* The README beside this file explains where that line is drawn, and why
|
|
279
|
+
* a call into a dependency stays on the other side of it.
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
declare function hasBody(fn: FunctionRoot): boolean;
|
|
283
|
+
|
|
259
284
|
interface ClientCallSite {
|
|
260
285
|
callExpression: CallExpression;
|
|
261
286
|
/** Method name on the client object (e.g. "getUser"), null for bare calls like fetch() */
|
|
@@ -487,6 +512,13 @@ declare function discoverUnits(sourceFile: SourceFile, patterns: DiscoveryPatter
|
|
|
487
512
|
* on the parent.
|
|
488
513
|
*/
|
|
489
514
|
type DescentBarriers = ReadonlySet<Node>;
|
|
515
|
+
declare const NO_BARRIERS: DescentBarriers;
|
|
516
|
+
/**
|
|
517
|
+
* Does this node return for itself rather than for whatever encloses
|
|
518
|
+
* it? An accessor and a constructor do, the same way a callback does,
|
|
519
|
+
* so a getter inside a returned object returns for the getter.
|
|
520
|
+
*/
|
|
521
|
+
declare function startsItsOwnScope(node: Node): boolean;
|
|
490
522
|
|
|
491
523
|
/**
|
|
492
524
|
* invocationEffects.ts: capture every call in a unit's body as an
|
|
@@ -715,15 +747,37 @@ declare function findTerminals(func: FunctionRoot, patterns: TerminalPattern[],
|
|
|
715
747
|
* attached to the branch they fire on.
|
|
716
748
|
*/
|
|
717
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Where one call the invocation walk visited ended up. `terminal` is a
|
|
752
|
+
* call folded into a terminal's own shape (`res.json(body)`).
|
|
753
|
+
* `invocation` is a call that fires as an effect on at least one
|
|
754
|
+
* branch. `unreachable` is a call no branch's terminal runs at or
|
|
755
|
+
* after, so nothing on any path can reach it: dead code below a
|
|
756
|
+
* `return`, not a gap. `unrecorded` is everything else: a call the
|
|
757
|
+
* walk saw, that wrote no terminal, and that fires on no branch
|
|
758
|
+
* despite sitting before one. That last case is a call this pass
|
|
759
|
+
* dropped.
|
|
760
|
+
*/
|
|
761
|
+
type CallAccountingOutcome = "invocation" | "terminal" | "unreachable" | "unrecorded";
|
|
762
|
+
/** One call the invocation walk visited, and where it ended up. */
|
|
763
|
+
interface CallAccountingEntry {
|
|
764
|
+
readonly node: CallExpression;
|
|
765
|
+
readonly callee: string;
|
|
766
|
+
readonly line: number;
|
|
767
|
+
readonly outcome: CallAccountingOutcome;
|
|
768
|
+
}
|
|
718
769
|
/**
|
|
719
770
|
* The branches a function produces, alongside the terminals they came
|
|
720
771
|
* from. A caller that wants to know which returns went unclaimed needs
|
|
721
772
|
* the terminals, and searching for them a second time costs about as
|
|
722
|
-
* much as this whole pass.
|
|
773
|
+
* much as this whole pass. `callAccounting` is present only when a
|
|
774
|
+
* caller asked for it: a test wanting to assert that every call the
|
|
775
|
+
* walk visited landed somewhere, rather than a value every run pays for.
|
|
723
776
|
*/
|
|
724
777
|
interface RawBranchResult {
|
|
725
778
|
branches: RawBranch[];
|
|
726
779
|
terminals: FoundTerminal[];
|
|
780
|
+
callAccounting?: CallAccountingEntry[];
|
|
727
781
|
}
|
|
728
782
|
/**
|
|
729
783
|
* Every branch a function produces: one per path that reaches a
|
|
@@ -732,7 +786,7 @@ interface RawBranchResult {
|
|
|
732
786
|
* or when every condition on it came from an early return or throw,
|
|
733
787
|
* since those are the paths that run when no guard fired.
|
|
734
788
|
*/
|
|
735
|
-
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee): RawBranchResult;
|
|
789
|
+
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee, collectCallAccounting?: boolean): RawBranchResult;
|
|
736
790
|
|
|
737
791
|
/**
|
|
738
792
|
* A Project covering `rootDir`, for a codebase with no tsconfig to read.
|
|
@@ -1062,6 +1116,14 @@ declare function functionTargetOf(node: Identifier): {
|
|
|
1062
1116
|
name: string;
|
|
1063
1117
|
} | null;
|
|
1064
1118
|
|
|
1119
|
+
/**
|
|
1120
|
+
* The three terminal shapes any function has, whatever pack discovered
|
|
1121
|
+
* it: a `return`, a `throw`, or falling off the end. The call-accounting
|
|
1122
|
+
* check classifies a call against these, since it reads arbitrary
|
|
1123
|
+
* source with no pack in front of it.
|
|
1124
|
+
*/
|
|
1125
|
+
declare const GENERIC_TERMINALS: TerminalPattern[];
|
|
1126
|
+
|
|
1065
1127
|
/**
|
|
1066
1128
|
* What a name-valued expression says, as fixed text with a hole for
|
|
1067
1129
|
* each part built at run time. A table name, a bucket, a queue URL and
|
|
@@ -1271,4 +1333,4 @@ declare function computeAdapterPacksDigest(packVersions: ReadonlyArray<{
|
|
|
1271
1333
|
version?: string;
|
|
1272
1334
|
}>): string;
|
|
1273
1335
|
|
|
1274
|
-
export { ADAPTER_VERSION, type Accessed, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DiscoveredUnit, type ExplainCallableOptions, type ExplainedResolution, type FoundTerminal, type FunctionRoot, type ImportScanOptions, type ObservedStubCall, type ReadNameOptions, ResolutionStore, type StubCallEvidence, type StubEvidenceOptions, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, buildProjectHelperIndex, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, functionTargetOf, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isImportedFrom, methodDeclaredIn, namedImportsOf, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, stubEvidence, stubEvidenceIn, workspaceRootFor };
|
|
1336
|
+
export { ADAPTER_VERSION, type Accessed, type CallAccountingEntry, type CallAccountingOutcome, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DescentBarriers, type DiscoveredUnit, type ExplainCallableOptions, type ExplainedResolution, type FoundTerminal, type FunctionRoot, GENERIC_TERMINALS, type ImportScanOptions, NO_BARRIERS, type ObservedStubCall, type RawBranchResult, type ReadNameOptions, ResolutionStore, type StubCallEvidence, type StubEvidenceOptions, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, buildProjectHelperIndex, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, functionTargetOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isImportedFrom, methodDeclaredIn, namedImportsOf, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stubEvidence, stubEvidenceIn, workspaceRootFor };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,6 +87,15 @@ declare class ResolutionStore {
|
|
|
87
87
|
*/
|
|
88
88
|
explainCallable(value: Node, options?: ExplainCallableOptions): ExplainedResolution | null;
|
|
89
89
|
resolveObject(value: Node): Node | null;
|
|
90
|
+
/**
|
|
91
|
+
* The function a call returns: `app.use(requireCaller(config))`
|
|
92
|
+
* registers what the factory gives back. A separate question from
|
|
93
|
+
* `resolveCallable`, which keeps a call unresolved on purpose so an
|
|
94
|
+
* unwrapping answer wins; this one is asked only after that has
|
|
95
|
+
* declined. Two returned functions give null, like every other
|
|
96
|
+
* single-answer question here.
|
|
97
|
+
*/
|
|
98
|
+
resolveReturnedCallable(call: Node): Node | null;
|
|
90
99
|
/**
|
|
91
100
|
* For a value that is neither a function nor an object, such as a
|
|
92
101
|
* GraphQL document kept in a constant in another file.
|
|
@@ -193,6 +202,7 @@ declare class ResolutionStore {
|
|
|
193
202
|
*/
|
|
194
203
|
private seedValue;
|
|
195
204
|
private lookupObject;
|
|
205
|
+
private lookupReturned;
|
|
196
206
|
/**
|
|
197
207
|
* Two candidates give null, since ambiguity is nothing. The value
|
|
198
208
|
* itself is never a result either, or an identifier whose chain went
|
|
@@ -256,6 +266,21 @@ type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | M
|
|
|
256
266
|
*/
|
|
257
267
|
declare function collectAncestorBranches(terminalNode: Node, functionRoot: FunctionRoot): RawCondition[];
|
|
258
268
|
|
|
269
|
+
/**
|
|
270
|
+
* unfollowedCall.ts: naming the calls the reachable closure stops at.
|
|
271
|
+
*
|
|
272
|
+
* The closure follows a call by resolving its callee to a function with a
|
|
273
|
+
* body. When that fails the edge is dropped, and a unit whose body is full
|
|
274
|
+
* of dropped edges produces the same empty summary as a unit that does
|
|
275
|
+
* nothing. This module says which kind of stop a call site is. The
|
|
276
|
+
* reasons, and the gap each one leaves, are shared with every adapter.
|
|
277
|
+
*
|
|
278
|
+
* The README beside this file explains where that line is drawn, and why
|
|
279
|
+
* a call into a dependency stays on the other side of it.
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
declare function hasBody(fn: FunctionRoot): boolean;
|
|
283
|
+
|
|
259
284
|
interface ClientCallSite {
|
|
260
285
|
callExpression: CallExpression;
|
|
261
286
|
/** Method name on the client object (e.g. "getUser"), null for bare calls like fetch() */
|
|
@@ -487,6 +512,13 @@ declare function discoverUnits(sourceFile: SourceFile, patterns: DiscoveryPatter
|
|
|
487
512
|
* on the parent.
|
|
488
513
|
*/
|
|
489
514
|
type DescentBarriers = ReadonlySet<Node>;
|
|
515
|
+
declare const NO_BARRIERS: DescentBarriers;
|
|
516
|
+
/**
|
|
517
|
+
* Does this node return for itself rather than for whatever encloses
|
|
518
|
+
* it? An accessor and a constructor do, the same way a callback does,
|
|
519
|
+
* so a getter inside a returned object returns for the getter.
|
|
520
|
+
*/
|
|
521
|
+
declare function startsItsOwnScope(node: Node): boolean;
|
|
490
522
|
|
|
491
523
|
/**
|
|
492
524
|
* invocationEffects.ts: capture every call in a unit's body as an
|
|
@@ -715,15 +747,37 @@ declare function findTerminals(func: FunctionRoot, patterns: TerminalPattern[],
|
|
|
715
747
|
* attached to the branch they fire on.
|
|
716
748
|
*/
|
|
717
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Where one call the invocation walk visited ended up. `terminal` is a
|
|
752
|
+
* call folded into a terminal's own shape (`res.json(body)`).
|
|
753
|
+
* `invocation` is a call that fires as an effect on at least one
|
|
754
|
+
* branch. `unreachable` is a call no branch's terminal runs at or
|
|
755
|
+
* after, so nothing on any path can reach it: dead code below a
|
|
756
|
+
* `return`, not a gap. `unrecorded` is everything else: a call the
|
|
757
|
+
* walk saw, that wrote no terminal, and that fires on no branch
|
|
758
|
+
* despite sitting before one. That last case is a call this pass
|
|
759
|
+
* dropped.
|
|
760
|
+
*/
|
|
761
|
+
type CallAccountingOutcome = "invocation" | "terminal" | "unreachable" | "unrecorded";
|
|
762
|
+
/** One call the invocation walk visited, and where it ended up. */
|
|
763
|
+
interface CallAccountingEntry {
|
|
764
|
+
readonly node: CallExpression;
|
|
765
|
+
readonly callee: string;
|
|
766
|
+
readonly line: number;
|
|
767
|
+
readonly outcome: CallAccountingOutcome;
|
|
768
|
+
}
|
|
718
769
|
/**
|
|
719
770
|
* The branches a function produces, alongside the terminals they came
|
|
720
771
|
* from. A caller that wants to know which returns went unclaimed needs
|
|
721
772
|
* the terminals, and searching for them a second time costs about as
|
|
722
|
-
* much as this whole pass.
|
|
773
|
+
* much as this whole pass. `callAccounting` is present only when a
|
|
774
|
+
* caller asked for it: a test wanting to assert that every call the
|
|
775
|
+
* walk visited landed somewhere, rather than a value every run pays for.
|
|
723
776
|
*/
|
|
724
777
|
interface RawBranchResult {
|
|
725
778
|
branches: RawBranch[];
|
|
726
779
|
terminals: FoundTerminal[];
|
|
780
|
+
callAccounting?: CallAccountingEntry[];
|
|
727
781
|
}
|
|
728
782
|
/**
|
|
729
783
|
* Every branch a function produces: one per path that reaches a
|
|
@@ -732,7 +786,7 @@ interface RawBranchResult {
|
|
|
732
786
|
* or when every condition on it came from an early return or throw,
|
|
733
787
|
* since those are the paths that run when no guard fired.
|
|
734
788
|
*/
|
|
735
|
-
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee): RawBranchResult;
|
|
789
|
+
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee, collectCallAccounting?: boolean): RawBranchResult;
|
|
736
790
|
|
|
737
791
|
/**
|
|
738
792
|
* A Project covering `rootDir`, for a codebase with no tsconfig to read.
|
|
@@ -1062,6 +1116,14 @@ declare function functionTargetOf(node: Identifier): {
|
|
|
1062
1116
|
name: string;
|
|
1063
1117
|
} | null;
|
|
1064
1118
|
|
|
1119
|
+
/**
|
|
1120
|
+
* The three terminal shapes any function has, whatever pack discovered
|
|
1121
|
+
* it: a `return`, a `throw`, or falling off the end. The call-accounting
|
|
1122
|
+
* check classifies a call against these, since it reads arbitrary
|
|
1123
|
+
* source with no pack in front of it.
|
|
1124
|
+
*/
|
|
1125
|
+
declare const GENERIC_TERMINALS: TerminalPattern[];
|
|
1126
|
+
|
|
1065
1127
|
/**
|
|
1066
1128
|
* What a name-valued expression says, as fixed text with a hole for
|
|
1067
1129
|
* each part built at run time. A table name, a bucket, a queue URL and
|
|
@@ -1271,4 +1333,4 @@ declare function computeAdapterPacksDigest(packVersions: ReadonlyArray<{
|
|
|
1271
1333
|
version?: string;
|
|
1272
1334
|
}>): string;
|
|
1273
1335
|
|
|
1274
|
-
export { ADAPTER_VERSION, type Accessed, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DiscoveredUnit, type ExplainCallableOptions, type ExplainedResolution, type FoundTerminal, type FunctionRoot, type ImportScanOptions, type ObservedStubCall, type ReadNameOptions, ResolutionStore, type StubCallEvidence, type StubEvidenceOptions, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, buildProjectHelperIndex, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, functionTargetOf, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isImportedFrom, methodDeclaredIn, namedImportsOf, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, stubEvidence, stubEvidenceIn, workspaceRootFor };
|
|
1336
|
+
export { ADAPTER_VERSION, type Accessed, type CallAccountingEntry, type CallAccountingOutcome, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DescentBarriers, type DiscoveredUnit, type ExplainCallableOptions, type ExplainedResolution, type FoundTerminal, type FunctionRoot, GENERIC_TERMINALS, type ImportScanOptions, NO_BARRIERS, type ObservedStubCall, type RawBranchResult, type ReadNameOptions, ResolutionStore, type StubCallEvidence, type StubEvidenceOptions, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, buildProjectHelperIndex, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, functionTargetOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isImportedFrom, methodDeclaredIn, namedImportsOf, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stubEvidence, stubEvidenceIn, workspaceRootFor };
|