@suss/adapter-typescript 0.31.2 → 0.33.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.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, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, PropertyAccessExpression, TaggedTemplateExpression, Project, 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
  /**
@@ -46,6 +52,18 @@ interface PassedArgument {
46
52
  call: Node;
47
53
  argument: Node;
48
54
  }
55
+ /** See `ResolutionStore.envNamers`. */
56
+ interface EnvironmentNamers {
57
+ /**
58
+ * The environment reads that take their variable's name from this
59
+ * parameter, however many helpers forward it along the way. Empty for
60
+ * a parameter no read ever takes a name from, and null where the
61
+ * rules had nothing to go on: a file that exports nothing states no
62
+ * facts, so their silence about its parameters means neither yes nor
63
+ * no, and the asker settles what it can by reading the syntax.
64
+ */
65
+ sitesNaming(parameter: Node): readonly Node[] | null;
66
+ }
49
67
  declare class ResolutionStore {
50
68
  private readonly db;
51
69
  private readonly table;
@@ -66,13 +84,17 @@ declare class ResolutionStore {
66
84
  private readonly constructionSites;
67
85
  /** Files the most recent query read, for the memo to keep. */
68
86
  private lastQueryWalked;
87
+ /** See `environmentSiteFiles`; null until the first env question. */
88
+ private envSiteFiles;
89
+ private envNamersAnswer;
90
+ private envNamersExtractedAt;
69
91
  private readonly declarations;
70
92
  private readonly graph;
71
93
  /** See `notePossibleCallers`. */
72
94
  private readonly possibleCallers;
73
95
  private readonly callerFilesRead;
74
96
  private stale;
75
- constructor(wrappers?: TransparentWrapper[]);
97
+ constructor(wrappers?: TransparentWrapper[], environmentObjects?: readonly string[]);
76
98
  /**
77
99
  * `alsoFrom` is a second file to walk out from, for a caller that
78
100
  * knows where the value it is asking about was set up. The walk
@@ -144,6 +166,48 @@ declare class ResolutionStore {
144
166
  * parameter's own function with no join against `bodyCalls` needed.
145
167
  */
146
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 is the only shape whose answer can change once its
175
+ * callers are in, and reading those means reading every file that
176
+ * imports this one, so a value that is not one is answered from what
177
+ * the store already has.
178
+ */
179
+ isEnvironmentValue(value: Node): boolean;
180
+ private hasAnswer;
181
+ /**
182
+ * Which parameters an environment read takes its variable's name
183
+ * from, for a reader standing at a call. One question covers the
184
+ * whole project: a project has a handful of environment reads and
185
+ * thousands of parameters, and with the read bound the rules run from
186
+ * each callee to its callers.
187
+ *
188
+ * `definedIn` is the callee's own file, read into the store before
189
+ * the question so a helper nothing had extracted yet is among the
190
+ * facts the rules run over.
191
+ */
192
+ envNamers(definedIn: SourceFile): EnvironmentNamers;
193
+ private sitesNamedBy;
194
+ /**
195
+ * Seed every expression that spells the environment, derive, and take
196
+ * the sites back per parameter. The question is dropped afterwards, so
197
+ * a later ask over a larger fact set derives it again.
198
+ *
199
+ * The reads themselves cannot be the seed: one written through a
200
+ * parameter is off an object a scan of the source has no way to pick
201
+ * out, and the whole point of asking is to find those.
202
+ */
203
+ private askEnvNamers;
204
+ /**
205
+ * The project's files that hand the environment object somewhere,
206
+ * read into the store. Which files those are cannot depend on what a
207
+ * reader happened to ask about first, so the scan is over the
208
+ * project's own sources and it happens once.
209
+ */
210
+ private environmentSiteFiles;
147
211
  /**
148
212
  * Whether running this function hands back that call: returned
149
213
  * outright, written into a name and returned, or a shorthand body.
@@ -247,6 +311,8 @@ declare class ResolutionStore {
247
311
  */
248
312
  private forgetQuery;
249
313
  private wantValue;
314
+ /** For a question seeded with a fact key the store read out of the database. */
315
+ private wantKey;
250
316
  private wantExportsOf;
251
317
  /**
252
318
  * Discovery walks the table in order, and the rounds derive it in
@@ -337,7 +403,14 @@ declare function collectAncestorBranches(terminalNode: Node, functionRoot: Funct
337
403
  * a call into a dependency stays on the other side of it.
338
404
  */
339
405
 
340
- declare function hasBody(fn: FunctionRoot): boolean;
406
+ declare function hasBody(fn: Node): boolean;
407
+ /**
408
+ * Every declaration behind a callee, with an imported or re-exported
409
+ * name followed through to its last one. A barrel that forwards a
410
+ * dependency's function would otherwise look like project code, because
411
+ * the only declaration in sight is the import in the calling file.
412
+ */
413
+ declare function declarationsBehind(symbol: Symbol | undefined): Node[];
341
414
 
342
415
  interface ClientCallSite {
343
416
  callExpression: CallExpression;
@@ -548,6 +621,7 @@ interface DiscoveredUnit {
548
621
  */
549
622
  routeUnfollowed?: UnfollowedCall[];
550
623
  }
624
+ declare function toFunctionRoot(node: Node): FunctionRoot | null;
551
625
  /** Walk to the nearest enclosing function-shaped node, or null if none. */
552
626
  declare function findEnclosingFunction(node: Node): FunctionRoot | null;
553
627
 
@@ -1579,4 +1653,4 @@ declare function climbSyntax(node: Node): Node;
1579
1653
  */
1580
1654
  declare function peelValue(node: Node): Node;
1581
1655
 
1582
- 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, 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 };
1656
+ 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, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, PropertyAccessExpression, TaggedTemplateExpression, Project, 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
  /**
@@ -46,6 +52,18 @@ interface PassedArgument {
46
52
  call: Node;
47
53
  argument: Node;
48
54
  }
55
+ /** See `ResolutionStore.envNamers`. */
56
+ interface EnvironmentNamers {
57
+ /**
58
+ * The environment reads that take their variable's name from this
59
+ * parameter, however many helpers forward it along the way. Empty for
60
+ * a parameter no read ever takes a name from, and null where the
61
+ * rules had nothing to go on: a file that exports nothing states no
62
+ * facts, so their silence about its parameters means neither yes nor
63
+ * no, and the asker settles what it can by reading the syntax.
64
+ */
65
+ sitesNaming(parameter: Node): readonly Node[] | null;
66
+ }
49
67
  declare class ResolutionStore {
50
68
  private readonly db;
51
69
  private readonly table;
@@ -66,13 +84,17 @@ declare class ResolutionStore {
66
84
  private readonly constructionSites;
67
85
  /** Files the most recent query read, for the memo to keep. */
68
86
  private lastQueryWalked;
87
+ /** See `environmentSiteFiles`; null until the first env question. */
88
+ private envSiteFiles;
89
+ private envNamersAnswer;
90
+ private envNamersExtractedAt;
69
91
  private readonly declarations;
70
92
  private readonly graph;
71
93
  /** See `notePossibleCallers`. */
72
94
  private readonly possibleCallers;
73
95
  private readonly callerFilesRead;
74
96
  private stale;
75
- constructor(wrappers?: TransparentWrapper[]);
97
+ constructor(wrappers?: TransparentWrapper[], environmentObjects?: readonly string[]);
76
98
  /**
77
99
  * `alsoFrom` is a second file to walk out from, for a caller that
78
100
  * knows where the value it is asking about was set up. The walk
@@ -144,6 +166,48 @@ declare class ResolutionStore {
144
166
  * parameter's own function with no join against `bodyCalls` needed.
145
167
  */
146
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 is the only shape whose answer can change once its
175
+ * callers are in, and reading those means reading every file that
176
+ * imports this one, so a value that is not one is answered from what
177
+ * the store already has.
178
+ */
179
+ isEnvironmentValue(value: Node): boolean;
180
+ private hasAnswer;
181
+ /**
182
+ * Which parameters an environment read takes its variable's name
183
+ * from, for a reader standing at a call. One question covers the
184
+ * whole project: a project has a handful of environment reads and
185
+ * thousands of parameters, and with the read bound the rules run from
186
+ * each callee to its callers.
187
+ *
188
+ * `definedIn` is the callee's own file, read into the store before
189
+ * the question so a helper nothing had extracted yet is among the
190
+ * facts the rules run over.
191
+ */
192
+ envNamers(definedIn: SourceFile): EnvironmentNamers;
193
+ private sitesNamedBy;
194
+ /**
195
+ * Seed every expression that spells the environment, derive, and take
196
+ * the sites back per parameter. The question is dropped afterwards, so
197
+ * a later ask over a larger fact set derives it again.
198
+ *
199
+ * The reads themselves cannot be the seed: one written through a
200
+ * parameter is off an object a scan of the source has no way to pick
201
+ * out, and the whole point of asking is to find those.
202
+ */
203
+ private askEnvNamers;
204
+ /**
205
+ * The project's files that hand the environment object somewhere,
206
+ * read into the store. Which files those are cannot depend on what a
207
+ * reader happened to ask about first, so the scan is over the
208
+ * project's own sources and it happens once.
209
+ */
210
+ private environmentSiteFiles;
147
211
  /**
148
212
  * Whether running this function hands back that call: returned
149
213
  * outright, written into a name and returned, or a shorthand body.
@@ -247,6 +311,8 @@ declare class ResolutionStore {
247
311
  */
248
312
  private forgetQuery;
249
313
  private wantValue;
314
+ /** For a question seeded with a fact key the store read out of the database. */
315
+ private wantKey;
250
316
  private wantExportsOf;
251
317
  /**
252
318
  * Discovery walks the table in order, and the rounds derive it in
@@ -337,7 +403,14 @@ declare function collectAncestorBranches(terminalNode: Node, functionRoot: Funct
337
403
  * a call into a dependency stays on the other side of it.
338
404
  */
339
405
 
340
- declare function hasBody(fn: FunctionRoot): boolean;
406
+ declare function hasBody(fn: Node): boolean;
407
+ /**
408
+ * Every declaration behind a callee, with an imported or re-exported
409
+ * name followed through to its last one. A barrel that forwards a
410
+ * dependency's function would otherwise look like project code, because
411
+ * the only declaration in sight is the import in the calling file.
412
+ */
413
+ declare function declarationsBehind(symbol: Symbol | undefined): Node[];
341
414
 
342
415
  interface ClientCallSite {
343
416
  callExpression: CallExpression;
@@ -548,6 +621,7 @@ interface DiscoveredUnit {
548
621
  */
549
622
  routeUnfollowed?: UnfollowedCall[];
550
623
  }
624
+ declare function toFunctionRoot(node: Node): FunctionRoot | null;
551
625
  /** Walk to the nearest enclosing function-shaped node, or null if none. */
552
626
  declare function findEnclosingFunction(node: Node): FunctionRoot | null;
553
627
 
@@ -1579,4 +1653,4 @@ declare function climbSyntax(node: Node): Node;
1579
1653
  */
1580
1654
  declare function peelValue(node: Node): Node;
1581
1655
 
1582
- 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, 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 };
1656
+ 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 };