@suss/adapter-typescript 0.32.0 → 0.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { SourceFile, Node, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, CallExpression, PropertyAccessExpression, TaggedTemplateExpression, Project, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Symbol, Expression, NewExpression, Identifier } from 'ts-morph';
1
+ import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, PropertyAccessExpression, TaggedTemplateExpression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Expression, NewExpression, Identifier } from 'ts-morph';
2
2
  import { TransparentWrapper, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, EffectArg, CallOps, LanguageAdapter, PatternPack, ExtractorOptions, TimingReport, CacheDiagnostic, ExtractionReport, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, RawBranch, configuredCallOption, RawDeclaredContract, ContractPattern, AstCapableOps, ResponsePropertyMapping } from '@suss/extractor';
3
3
  export { EmptyStage, ExtractionReport, PackFunnel, Timer, TimingReport, computeContentHash } from '@suss/extractor';
4
4
  import { MessageBusSemantics, DeployableUnit, UnfollowedCall, WrapperReference, BehavioralSummary, BoundaryBinding, Predicate, TypeShape, ValueRef } from '@suss/behavioral-ir';
@@ -11,6 +11,12 @@ import { z } from 'zod';
11
11
  interface FileSetQuery {
12
12
  sourceFiles: ReadonlyArray<SourceFile>;
13
13
  packages: ReadonlyArray<string>;
14
+ /**
15
+ * Files the asking pack's code generator leaves beside a module it
16
+ * wrote into the project. A relative import into such a directory
17
+ * counts as an import of the package.
18
+ */
19
+ generatedMarkers?: ReadonlyArray<string>;
14
20
  }
15
21
 
16
22
  /**
@@ -80,8 +86,8 @@ declare class ResolutionStore {
80
86
  private lastQueryWalked;
81
87
  /** See `environmentSiteFiles`; null until the first env question. */
82
88
  private envSiteFiles;
83
- private envNamersAnswer;
84
- private envNamersExtractedAt;
89
+ /** See `environmentAnswers`; null until the first env question. */
90
+ private envAnswers;
85
91
  private readonly declarations;
86
92
  private readonly graph;
87
93
  /** See `notePossibleCallers`. */
@@ -160,29 +166,50 @@ declare class ResolutionStore {
160
166
  * parameter's own function with no join against `bodyCalls` needed.
161
167
  */
162
168
  callsPassing(parameter: Node): PassedArgument[];
169
+ /**
170
+ * Whether this expression's value is the environment object: the way
171
+ * a pack spells it, a name declared as that, or a parameter some
172
+ * caller hands one to, however many calls deep.
173
+ *
174
+ * A parameter's answer depends on its callers, so it comes from the
175
+ * parameters the environment reaches, worked out once per run.
176
+ */
177
+ isEnvironmentValue(value: Node): boolean;
178
+ private hasAnswer;
163
179
  /**
164
180
  * Which parameters an environment read takes its variable's name
165
181
  * from, for a reader standing at a call. One question covers the
166
182
  * whole project: a project has a handful of environment reads and
167
183
  * thousands of parameters, and with the read bound the rules run from
168
- * each callee to its callers.
169
- *
170
- * `definedIn` is the callee's own file, read into the store before
171
- * the question so a helper nothing had extracted yet is among the
172
- * facts the rules run over.
184
+ * each callee to its callers. The facts README says which files that
185
+ * reads and why it is asked once.
173
186
  */
174
- envNamers(definedIn: SourceFile): EnvironmentNamers;
187
+ envNamers(project: Project): EnvironmentNamers;
188
+ private environmentAnswers;
189
+ /**
190
+ * Ask until every call handing the environment on has had its callee
191
+ * read, one hop a round, so the answer covers each parameter it lands in.
192
+ */
193
+ private followEnvironment;
194
+ private readCalleeOf;
195
+ /** The files the parameters an answer is keyed by are declared in. */
196
+ private filesOf;
175
197
  private sitesNamedBy;
176
198
  /**
177
- * Seed every read the store knows of, derive, and take the sites back
178
- * per parameter. The question is dropped afterwards, so a later ask
179
- * over a larger fact set derives it again.
199
+ * Seed every expression that spells the environment, derive, and take
200
+ * back the read sites per parameter and the parameters the object is
201
+ * handed to. The question is dropped afterwards, so a later ask over a
202
+ * larger fact set derives it again.
203
+ *
204
+ * The reads themselves cannot be the seed: one written through a
205
+ * parameter is off an object a scan of the source has no way to pick
206
+ * out, and the whole point of asking is to find those.
180
207
  */
181
- private askEnvNamers;
208
+ private askEnvironment;
182
209
  /**
183
- * The project's files that spell an environment read with a computed
184
- * index, read into the store. Which files those are cannot depend on
185
- * what a reader happened to ask about first, so the scan is over the
210
+ * The project's files that hand the environment object somewhere,
211
+ * read into the store. Which files those are cannot depend on what a
212
+ * reader happened to ask about first, so the scan is over the
186
213
  * project's own sources and it happens once.
187
214
  */
188
215
  private environmentSiteFiles;
@@ -381,7 +408,14 @@ declare function collectAncestorBranches(terminalNode: Node, functionRoot: Funct
381
408
  * a call into a dependency stays on the other side of it.
382
409
  */
383
410
 
384
- declare function hasBody(fn: FunctionRoot): boolean;
411
+ declare function hasBody(fn: Node): boolean;
412
+ /**
413
+ * Every declaration behind a callee, with an imported or re-exported
414
+ * name followed through to its last one. A barrel that forwards a
415
+ * dependency's function would otherwise look like project code, because
416
+ * the only declaration in sight is the import in the calling file.
417
+ */
418
+ declare function declarationsBehind(symbol: Symbol | undefined): Node[];
385
419
 
386
420
  interface ClientCallSite {
387
421
  callExpression: CallExpression;
@@ -592,6 +626,7 @@ interface DiscoveredUnit {
592
626
  */
593
627
  routeUnfollowed?: UnfollowedCall[];
594
628
  }
629
+ declare function toFunctionRoot(node: Node): FunctionRoot | null;
595
630
  /** Walk to the nearest enclosing function-shaped node, or null if none. */
596
631
  declare function findEnclosingFunction(node: Node): FunctionRoot | null;
597
632
 
@@ -1623,4 +1658,4 @@ declare function climbSyntax(node: Node): Node;
1623
1658
  */
1624
1659
  declare function peelValue(node: Node): Node;
1625
1660
 
1626
- export { ADAPTER_VERSION, type Accessed, type CallAccountingEntry, type CallAccountingOutcome, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DescentBarriers, type DiscoveredUnit, type EnvironmentNamers, 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, TSCONFIG_NAMES, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, arrayLiteralOf, buildProjectHelperIndex, callOpsFor, climbSyntax, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, couldNameAValue, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findEnclosingFunction, findNearestTsconfig, findTerminals, functionTargetOf, functionValueOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isDefaultedAt, isImportedFrom, methodDeclaredIn, namedImportsOf, objectLiteralOf, parseConditionExpression, peelSyntax, peelValue, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, workspaceRootFor, writtenNodeOf };
1661
+ export { ADAPTER_VERSION, type Accessed, type CallAccountingEntry, type CallAccountingOutcome, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DescentBarriers, type DiscoveredUnit, type EnvironmentNamers, 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, TSCONFIG_NAMES, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, arrayLiteralOf, buildProjectHelperIndex, callOpsFor, climbSyntax, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, couldNameAValue, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, declarationsBehind, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findEnclosingFunction, findNearestTsconfig, findTerminals, functionTargetOf, functionValueOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isDefaultedAt, isImportedFrom, methodDeclaredIn, namedImportsOf, objectLiteralOf, parseConditionExpression, peelSyntax, peelValue, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceRootFor, writtenNodeOf };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SourceFile, Node, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, CallExpression, PropertyAccessExpression, TaggedTemplateExpression, Project, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Symbol, Expression, NewExpression, Identifier } from 'ts-morph';
1
+ import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, PropertyAccessExpression, TaggedTemplateExpression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Expression, NewExpression, Identifier } from 'ts-morph';
2
2
  import { TransparentWrapper, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, EffectArg, CallOps, LanguageAdapter, PatternPack, ExtractorOptions, TimingReport, CacheDiagnostic, ExtractionReport, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, RawBranch, configuredCallOption, RawDeclaredContract, ContractPattern, AstCapableOps, ResponsePropertyMapping } from '@suss/extractor';
3
3
  export { EmptyStage, ExtractionReport, PackFunnel, Timer, TimingReport, computeContentHash } from '@suss/extractor';
4
4
  import { MessageBusSemantics, DeployableUnit, UnfollowedCall, WrapperReference, BehavioralSummary, BoundaryBinding, Predicate, TypeShape, ValueRef } from '@suss/behavioral-ir';
@@ -11,6 +11,12 @@ import { z } from 'zod';
11
11
  interface FileSetQuery {
12
12
  sourceFiles: ReadonlyArray<SourceFile>;
13
13
  packages: ReadonlyArray<string>;
14
+ /**
15
+ * Files the asking pack's code generator leaves beside a module it
16
+ * wrote into the project. A relative import into such a directory
17
+ * counts as an import of the package.
18
+ */
19
+ generatedMarkers?: ReadonlyArray<string>;
14
20
  }
15
21
 
16
22
  /**
@@ -80,8 +86,8 @@ declare class ResolutionStore {
80
86
  private lastQueryWalked;
81
87
  /** See `environmentSiteFiles`; null until the first env question. */
82
88
  private envSiteFiles;
83
- private envNamersAnswer;
84
- private envNamersExtractedAt;
89
+ /** See `environmentAnswers`; null until the first env question. */
90
+ private envAnswers;
85
91
  private readonly declarations;
86
92
  private readonly graph;
87
93
  /** See `notePossibleCallers`. */
@@ -160,29 +166,50 @@ declare class ResolutionStore {
160
166
  * parameter's own function with no join against `bodyCalls` needed.
161
167
  */
162
168
  callsPassing(parameter: Node): PassedArgument[];
169
+ /**
170
+ * Whether this expression's value is the environment object: the way
171
+ * a pack spells it, a name declared as that, or a parameter some
172
+ * caller hands one to, however many calls deep.
173
+ *
174
+ * A parameter's answer depends on its callers, so it comes from the
175
+ * parameters the environment reaches, worked out once per run.
176
+ */
177
+ isEnvironmentValue(value: Node): boolean;
178
+ private hasAnswer;
163
179
  /**
164
180
  * Which parameters an environment read takes its variable's name
165
181
  * from, for a reader standing at a call. One question covers the
166
182
  * whole project: a project has a handful of environment reads and
167
183
  * thousands of parameters, and with the read bound the rules run from
168
- * each callee to its callers.
169
- *
170
- * `definedIn` is the callee's own file, read into the store before
171
- * the question so a helper nothing had extracted yet is among the
172
- * facts the rules run over.
184
+ * each callee to its callers. The facts README says which files that
185
+ * reads and why it is asked once.
173
186
  */
174
- envNamers(definedIn: SourceFile): EnvironmentNamers;
187
+ envNamers(project: Project): EnvironmentNamers;
188
+ private environmentAnswers;
189
+ /**
190
+ * Ask until every call handing the environment on has had its callee
191
+ * read, one hop a round, so the answer covers each parameter it lands in.
192
+ */
193
+ private followEnvironment;
194
+ private readCalleeOf;
195
+ /** The files the parameters an answer is keyed by are declared in. */
196
+ private filesOf;
175
197
  private sitesNamedBy;
176
198
  /**
177
- * Seed every read the store knows of, derive, and take the sites back
178
- * per parameter. The question is dropped afterwards, so a later ask
179
- * over a larger fact set derives it again.
199
+ * Seed every expression that spells the environment, derive, and take
200
+ * back the read sites per parameter and the parameters the object is
201
+ * handed to. The question is dropped afterwards, so a later ask over a
202
+ * larger fact set derives it again.
203
+ *
204
+ * The reads themselves cannot be the seed: one written through a
205
+ * parameter is off an object a scan of the source has no way to pick
206
+ * out, and the whole point of asking is to find those.
180
207
  */
181
- private askEnvNamers;
208
+ private askEnvironment;
182
209
  /**
183
- * The project's files that spell an environment read with a computed
184
- * index, read into the store. Which files those are cannot depend on
185
- * what a reader happened to ask about first, so the scan is over the
210
+ * The project's files that hand the environment object somewhere,
211
+ * read into the store. Which files those are cannot depend on what a
212
+ * reader happened to ask about first, so the scan is over the
186
213
  * project's own sources and it happens once.
187
214
  */
188
215
  private environmentSiteFiles;
@@ -381,7 +408,14 @@ declare function collectAncestorBranches(terminalNode: Node, functionRoot: Funct
381
408
  * a call into a dependency stays on the other side of it.
382
409
  */
383
410
 
384
- declare function hasBody(fn: FunctionRoot): boolean;
411
+ declare function hasBody(fn: Node): boolean;
412
+ /**
413
+ * Every declaration behind a callee, with an imported or re-exported
414
+ * name followed through to its last one. A barrel that forwards a
415
+ * dependency's function would otherwise look like project code, because
416
+ * the only declaration in sight is the import in the calling file.
417
+ */
418
+ declare function declarationsBehind(symbol: Symbol | undefined): Node[];
385
419
 
386
420
  interface ClientCallSite {
387
421
  callExpression: CallExpression;
@@ -592,6 +626,7 @@ interface DiscoveredUnit {
592
626
  */
593
627
  routeUnfollowed?: UnfollowedCall[];
594
628
  }
629
+ declare function toFunctionRoot(node: Node): FunctionRoot | null;
595
630
  /** Walk to the nearest enclosing function-shaped node, or null if none. */
596
631
  declare function findEnclosingFunction(node: Node): FunctionRoot | null;
597
632
 
@@ -1623,4 +1658,4 @@ declare function climbSyntax(node: Node): Node;
1623
1658
  */
1624
1659
  declare function peelValue(node: Node): Node;
1625
1660
 
1626
- export { ADAPTER_VERSION, type Accessed, type CallAccountingEntry, type CallAccountingOutcome, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DescentBarriers, type DiscoveredUnit, type EnvironmentNamers, 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, TSCONFIG_NAMES, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, arrayLiteralOf, buildProjectHelperIndex, callOpsFor, climbSyntax, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, couldNameAValue, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findEnclosingFunction, findNearestTsconfig, findTerminals, functionTargetOf, functionValueOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isDefaultedAt, isImportedFrom, methodDeclaredIn, namedImportsOf, objectLiteralOf, parseConditionExpression, peelSyntax, peelValue, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, workspaceRootFor, writtenNodeOf };
1661
+ export { ADAPTER_VERSION, type Accessed, type CallAccountingEntry, type CallAccountingOutcome, type ClientCallSite, type ConfiguredCallContext, type ConfiguredCallRead, type ConfiguredCallSpec, type ContractReadResult, type DescentBarriers, type DiscoveredUnit, type EnvironmentNamers, 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, TSCONFIG_NAMES, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, accessContextFor, arrayLiteralOf, buildProjectHelperIndex, callOpsFor, climbSyntax, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, couldNameAValue, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, declarationsBehind, discoverUnits, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, findEnclosingFunction, findNearestTsconfig, findTerminals, functionTargetOf, functionValueOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isDefaultedAt, isImportedFrom, methodDeclaredIn, namedImportsOf, objectLiteralOf, parseConditionExpression, peelSyntax, peelValue, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceRootFor, writtenNodeOf };