@suss/adapter-typescript 0.12.0 → 0.13.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 +674 -469
- package/dist/index.d.cts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/index.js +641 -436
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceFile, Node, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, CallExpression, Project, Symbol, Expression } from 'ts-morph';
|
|
1
|
+
import { SourceFile, Node, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, CallExpression, Project, Symbol, Expression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression } from 'ts-morph';
|
|
2
2
|
import { PackDeclarations, TransparentWrapper, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, LanguageAdapter, PatternPack, ExtractorOptions, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, RawBranch, EffectArg, RawDeclaredContract, ContractPattern, ResponsePropertyMapping } from '@suss/extractor';
|
|
3
3
|
import { BehavioralSummary, MessageBusSemantics, DeployableUnit, BoundaryBinding, Predicate, TypeShape, ValueRef } from '@suss/behavioral-ir';
|
|
4
4
|
import { Proof, Atom } from '@suss/datalog';
|
|
@@ -307,6 +307,9 @@ declare class ResolutionStore {
|
|
|
307
307
|
* Two candidates give null, since ambiguity is nothing. The value
|
|
308
308
|
* itself is never a result either, or an identifier whose chain went
|
|
309
309
|
* nowhere would come back as itself.
|
|
310
|
+
*
|
|
311
|
+
* An answer has to be an expression, which leaves out the class a
|
|
312
|
+
* construction makes an instance of. The README says why.
|
|
310
313
|
*/
|
|
311
314
|
private lookupWritten;
|
|
312
315
|
/**
|
|
@@ -1019,11 +1022,43 @@ declare function parseConditionExpression(expr: Expression, depth?: number): Pre
|
|
|
1019
1022
|
* the union member it matches.
|
|
1020
1023
|
*/
|
|
1021
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* A call, a construction, or a tagged template, which all ask the same
|
|
1027
|
+
* questions. A tagged template is a call the source wrote without
|
|
1028
|
+
* parentheses: the tag is the callee and the template is the one
|
|
1029
|
+
* argument, which is how a pack reaches a statement written that way
|
|
1030
|
+
* without a second grammar for it.
|
|
1031
|
+
*/
|
|
1032
|
+
type Called = CallExpression | NewExpression | TaggedTemplateExpression;
|
|
1022
1033
|
/** One-hop lookup from a written name to the value it was bound to. */
|
|
1023
1034
|
type Resolve = (value: Node) => Node | null;
|
|
1024
1035
|
/** What a declared pack can ask about one TypeScript call. */
|
|
1025
|
-
declare function callOpsFor(call:
|
|
1036
|
+
declare function callOpsFor(call: Called, resolveWrittenValue?: Resolve): AstCapableOps;
|
|
1026
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* Context handed to TypeScript-adapter access recognizers: sister
|
|
1040
|
+
* to TsInvocationRecognizerContext but for property-access nodes.
|
|
1041
|
+
* No `extractArgs` since property accesses don't take arguments.
|
|
1042
|
+
*/
|
|
1043
|
+
interface TsAccessRecognizerContext {
|
|
1044
|
+
/** The property-access expression itself. */
|
|
1045
|
+
access: Node;
|
|
1046
|
+
/** Source file the access lives in. */
|
|
1047
|
+
sourceFile: SourceFile;
|
|
1048
|
+
/**
|
|
1049
|
+
* One-hop lookup from a written name to the value it was bound to,
|
|
1050
|
+
* from the run's facts (#300). Gives null when the run has no store,
|
|
1051
|
+
* and the recognizer's own pattern match runs on the raw node.
|
|
1052
|
+
*/
|
|
1053
|
+
resolveWrittenValue: (value: Node) => Node | null;
|
|
1054
|
+
/**
|
|
1055
|
+
* What a declared pack asks about this node, when the node is a call
|
|
1056
|
+
* or a tagged template. This walk visits property accesses as well,
|
|
1057
|
+
* and there is no call there to ask about, so a declared pack
|
|
1058
|
+
* standing on one is handed nothing and matches nothing.
|
|
1059
|
+
*/
|
|
1060
|
+
ops?: CallOps;
|
|
1061
|
+
}
|
|
1027
1062
|
/**
|
|
1028
1063
|
* Context handed to TypeScript-adapter recognizers. Recognizers in
|
|
1029
1064
|
* `@suss/framework-prisma` (and other packs) receive this and use
|
|
@@ -1077,6 +1112,13 @@ interface TsInvocationRecognizerContext {
|
|
|
1077
1112
|
*/
|
|
1078
1113
|
ops: CallOps;
|
|
1079
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Everything a recognizer may ask about one call site.
|
|
1117
|
+
*
|
|
1118
|
+
* A pack's tests build it here too, so a pack that passes them has run
|
|
1119
|
+
* against the context extraction gives it.
|
|
1120
|
+
*/
|
|
1121
|
+
declare function invocationContextFor(call: CallExpression, resolveWrittenValue?: (value: Node) => Node | null): TsInvocationRecognizerContext;
|
|
1080
1122
|
declare function isImportedFrom(identifier: Node, expectedModule: string): boolean;
|
|
1081
1123
|
/**
|
|
1082
1124
|
* Whether `expectedModule` declares the method a call goes to. A pack
|
|
@@ -1091,6 +1133,17 @@ declare function isImportedFrom(identifier: Node, expectedModule: string): boole
|
|
|
1091
1133
|
* from it.
|
|
1092
1134
|
*/
|
|
1093
1135
|
declare function methodDeclaredIn(callee: Node, expectedModule: string, resolve?: (value: Node) => Node | null): boolean;
|
|
1136
|
+
/** The nodes this walk stops at, which is every shape a pack can guard. */
|
|
1137
|
+
type Accessed = PropertyAccessExpression | CallExpression | TaggedTemplateExpression;
|
|
1138
|
+
/**
|
|
1139
|
+
* What one node is handed. The ops are built on the first read rather
|
|
1140
|
+
* than up front, the way the invocation walk builds them: most nodes
|
|
1141
|
+
* reach no declared pack, and a pack written as code never asks.
|
|
1142
|
+
*
|
|
1143
|
+
* A pack's tests build it here too, so a pack that passes them has run
|
|
1144
|
+
* against the context extraction gives it.
|
|
1145
|
+
*/
|
|
1146
|
+
declare function accessContextFor(node: Accessed, sourceFile: SourceFile, resolveWrittenValue?: (value: Node) => Node | null): TsAccessRecognizerContext;
|
|
1094
1147
|
|
|
1095
1148
|
/**
|
|
1096
1149
|
* What a name-valued expression says, as fixed text with a hole for
|
|
@@ -1279,4 +1332,4 @@ declare function computeAdapterPacksDigest(packVersions: ReadonlyArray<{
|
|
|
1279
1332
|
version?: string;
|
|
1280
1333
|
}>): string;
|
|
1281
1334
|
|
|
1282
|
-
export { ADAPTER_VERSION, type CacheDiagnostic, type CacheLookup, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DiscoveredUnit, type EmptyStage, type ExplainCallableOptions, type ExplainStats, type ExplainedResolution, type ExtractionReport, type FoundTerminal, type FunctionRoot, type HealthCheck, type HealthViolation, type PackFunnel, type PackGradient, type ReadNameOptions, ResolutionStore, type Timer, type TimingReport, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, type ValueLocation, type WhyExplained, WhySession, type WhySessionOptions, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, computeContentHash, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, evaluatePackHealth, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, formatPackHealth, isImportedFrom, methodDeclaredIn, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, workspaceRootFor };
|
|
1335
|
+
export { ADAPTER_VERSION, type Accessed, type CacheDiagnostic, type CacheLookup, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DiscoveredUnit, type EmptyStage, type ExplainCallableOptions, type ExplainStats, type ExplainedResolution, type ExtractionReport, type FoundTerminal, type FunctionRoot, type HealthCheck, type HealthViolation, type PackFunnel, type PackGradient, type ReadNameOptions, ResolutionStore, type Timer, type TimingReport, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, type ValueLocation, type WhyExplained, WhySession, type WhySessionOptions, accessContextFor, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, computeContentHash, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, evaluatePackHealth, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, formatPackHealth, invocationContextFor, isImportedFrom, methodDeclaredIn, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, workspaceRootFor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceFile, Node, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, CallExpression, Project, Symbol, Expression } from 'ts-morph';
|
|
1
|
+
import { SourceFile, Node, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, CallExpression, Project, Symbol, Expression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression } from 'ts-morph';
|
|
2
2
|
import { PackDeclarations, TransparentWrapper, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, LanguageAdapter, PatternPack, ExtractorOptions, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, RawBranch, EffectArg, RawDeclaredContract, ContractPattern, ResponsePropertyMapping } from '@suss/extractor';
|
|
3
3
|
import { BehavioralSummary, MessageBusSemantics, DeployableUnit, BoundaryBinding, Predicate, TypeShape, ValueRef } from '@suss/behavioral-ir';
|
|
4
4
|
import { Proof, Atom } from '@suss/datalog';
|
|
@@ -307,6 +307,9 @@ declare class ResolutionStore {
|
|
|
307
307
|
* Two candidates give null, since ambiguity is nothing. The value
|
|
308
308
|
* itself is never a result either, or an identifier whose chain went
|
|
309
309
|
* nowhere would come back as itself.
|
|
310
|
+
*
|
|
311
|
+
* An answer has to be an expression, which leaves out the class a
|
|
312
|
+
* construction makes an instance of. The README says why.
|
|
310
313
|
*/
|
|
311
314
|
private lookupWritten;
|
|
312
315
|
/**
|
|
@@ -1019,11 +1022,43 @@ declare function parseConditionExpression(expr: Expression, depth?: number): Pre
|
|
|
1019
1022
|
* the union member it matches.
|
|
1020
1023
|
*/
|
|
1021
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* A call, a construction, or a tagged template, which all ask the same
|
|
1027
|
+
* questions. A tagged template is a call the source wrote without
|
|
1028
|
+
* parentheses: the tag is the callee and the template is the one
|
|
1029
|
+
* argument, which is how a pack reaches a statement written that way
|
|
1030
|
+
* without a second grammar for it.
|
|
1031
|
+
*/
|
|
1032
|
+
type Called = CallExpression | NewExpression | TaggedTemplateExpression;
|
|
1022
1033
|
/** One-hop lookup from a written name to the value it was bound to. */
|
|
1023
1034
|
type Resolve = (value: Node) => Node | null;
|
|
1024
1035
|
/** What a declared pack can ask about one TypeScript call. */
|
|
1025
|
-
declare function callOpsFor(call:
|
|
1036
|
+
declare function callOpsFor(call: Called, resolveWrittenValue?: Resolve): AstCapableOps;
|
|
1026
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* Context handed to TypeScript-adapter access recognizers: sister
|
|
1040
|
+
* to TsInvocationRecognizerContext but for property-access nodes.
|
|
1041
|
+
* No `extractArgs` since property accesses don't take arguments.
|
|
1042
|
+
*/
|
|
1043
|
+
interface TsAccessRecognizerContext {
|
|
1044
|
+
/** The property-access expression itself. */
|
|
1045
|
+
access: Node;
|
|
1046
|
+
/** Source file the access lives in. */
|
|
1047
|
+
sourceFile: SourceFile;
|
|
1048
|
+
/**
|
|
1049
|
+
* One-hop lookup from a written name to the value it was bound to,
|
|
1050
|
+
* from the run's facts (#300). Gives null when the run has no store,
|
|
1051
|
+
* and the recognizer's own pattern match runs on the raw node.
|
|
1052
|
+
*/
|
|
1053
|
+
resolveWrittenValue: (value: Node) => Node | null;
|
|
1054
|
+
/**
|
|
1055
|
+
* What a declared pack asks about this node, when the node is a call
|
|
1056
|
+
* or a tagged template. This walk visits property accesses as well,
|
|
1057
|
+
* and there is no call there to ask about, so a declared pack
|
|
1058
|
+
* standing on one is handed nothing and matches nothing.
|
|
1059
|
+
*/
|
|
1060
|
+
ops?: CallOps;
|
|
1061
|
+
}
|
|
1027
1062
|
/**
|
|
1028
1063
|
* Context handed to TypeScript-adapter recognizers. Recognizers in
|
|
1029
1064
|
* `@suss/framework-prisma` (and other packs) receive this and use
|
|
@@ -1077,6 +1112,13 @@ interface TsInvocationRecognizerContext {
|
|
|
1077
1112
|
*/
|
|
1078
1113
|
ops: CallOps;
|
|
1079
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Everything a recognizer may ask about one call site.
|
|
1117
|
+
*
|
|
1118
|
+
* A pack's tests build it here too, so a pack that passes them has run
|
|
1119
|
+
* against the context extraction gives it.
|
|
1120
|
+
*/
|
|
1121
|
+
declare function invocationContextFor(call: CallExpression, resolveWrittenValue?: (value: Node) => Node | null): TsInvocationRecognizerContext;
|
|
1080
1122
|
declare function isImportedFrom(identifier: Node, expectedModule: string): boolean;
|
|
1081
1123
|
/**
|
|
1082
1124
|
* Whether `expectedModule` declares the method a call goes to. A pack
|
|
@@ -1091,6 +1133,17 @@ declare function isImportedFrom(identifier: Node, expectedModule: string): boole
|
|
|
1091
1133
|
* from it.
|
|
1092
1134
|
*/
|
|
1093
1135
|
declare function methodDeclaredIn(callee: Node, expectedModule: string, resolve?: (value: Node) => Node | null): boolean;
|
|
1136
|
+
/** The nodes this walk stops at, which is every shape a pack can guard. */
|
|
1137
|
+
type Accessed = PropertyAccessExpression | CallExpression | TaggedTemplateExpression;
|
|
1138
|
+
/**
|
|
1139
|
+
* What one node is handed. The ops are built on the first read rather
|
|
1140
|
+
* than up front, the way the invocation walk builds them: most nodes
|
|
1141
|
+
* reach no declared pack, and a pack written as code never asks.
|
|
1142
|
+
*
|
|
1143
|
+
* A pack's tests build it here too, so a pack that passes them has run
|
|
1144
|
+
* against the context extraction gives it.
|
|
1145
|
+
*/
|
|
1146
|
+
declare function accessContextFor(node: Accessed, sourceFile: SourceFile, resolveWrittenValue?: (value: Node) => Node | null): TsAccessRecognizerContext;
|
|
1094
1147
|
|
|
1095
1148
|
/**
|
|
1096
1149
|
* What a name-valued expression says, as fixed text with a hole for
|
|
@@ -1279,4 +1332,4 @@ declare function computeAdapterPacksDigest(packVersions: ReadonlyArray<{
|
|
|
1279
1332
|
version?: string;
|
|
1280
1333
|
}>): string;
|
|
1281
1334
|
|
|
1282
|
-
export { ADAPTER_VERSION, type CacheDiagnostic, type CacheLookup, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DiscoveredUnit, type EmptyStage, type ExplainCallableOptions, type ExplainStats, type ExplainedResolution, type ExtractionReport, type FoundTerminal, type FunctionRoot, type HealthCheck, type HealthViolation, type PackFunnel, type PackGradient, type ReadNameOptions, ResolutionStore, type Timer, type TimingReport, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, type ValueLocation, type WhyExplained, WhySession, type WhySessionOptions, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, computeContentHash, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, evaluatePackHealth, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, formatPackHealth, isImportedFrom, methodDeclaredIn, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, workspaceRootFor };
|
|
1335
|
+
export { ADAPTER_VERSION, type Accessed, type CacheDiagnostic, type CacheLookup, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DiscoveredUnit, type EmptyStage, type ExplainCallableOptions, type ExplainStats, type ExplainedResolution, type ExtractionReport, type FoundTerminal, type FunctionRoot, type HealthCheck, type HealthViolation, type PackFunnel, type PackGradient, type ReadNameOptions, ResolutionStore, type Timer, type TimingReport, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, type ValueLocation, type WhyExplained, WhySession, type WhySessionOptions, accessContextFor, callOpsFor, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, computeContentHash, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, evaluatePackHealth, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findNearestTsconfig, findTerminals, formatPackHealth, invocationContextFor, isImportedFrom, methodDeclaredIn, parseConditionExpression, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, workspaceRootFor };
|