@suss/adapter-typescript 0.35.1 → 0.37.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, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, Expression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Identifier } from 'ts-morph';
1
+ import { Node, SourceFile, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, ConstructorDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, Expression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Identifier } from 'ts-morph';
2
2
  import { PatternPack, TransparentWrapper, ParameterSupplier, VersionPlacement, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, ArgumentParser, StatedSlot, AstCapableOps, CallOps, EffectArg, LanguageAdapter, ExtractorOptions, TimingReport, CacheDiagnostic, ExtractionReport, DeclaredModule, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, ResponsePropertyMapping, RawBranch, KeepsArms, configuredCallOption, RawDeclaredContract, ContractPattern } from '@suss/extractor';
3
3
  export { EmptyStage, ExtractionReport, PackFunnel, Timer, TimingReport, computeContentHash } from '@suss/extractor';
4
4
  import { MessageBusSemantics, DeployableUnit, UnfollowedCall, WrapperReference, Effect, BehavioralSummary, BoundaryBinding, Predicate, TypeShape, ValueRef } from '@suss/behavioral-ir';
@@ -13,6 +13,11 @@ interface RuntimeSpellings {
13
13
  exitCalls: readonly string[];
14
14
  exitCodeWrites: readonly string[];
15
15
  }
16
+ /**
17
+ * The dotted path an expression spells, when every part of it is an
18
+ * identifier or it starts at `import.meta`, as `import.meta.env` does.
19
+ */
20
+ declare function dottedPathOf(expression: Node): string | null;
16
21
 
17
22
  /**
18
23
  * A library's own module, written into the project by that library's
@@ -635,7 +640,12 @@ type AppVersioning = {
635
640
  defaultVersion: StatedVersion;
636
641
  };
637
642
 
638
- type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | MethodDeclaration;
643
+ /**
644
+ * A function a unit is built on. A constructor is one, since `new
645
+ * Client()` runs its body and its parameters' defaults the way a call
646
+ * runs a function's.
647
+ */
648
+ type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | MethodDeclaration | ConstructorDeclaration;
639
649
  /**
640
650
  * Public API: returns RawCondition[] with structured: null.
641
651
  * Use collectAncestorConditionInfos when you need the Expression nodes.
@@ -664,6 +674,34 @@ declare function hasBody(fn: Node): boolean;
664
674
  */
665
675
  declare function declarationsBehind(symbol: Symbol | undefined): Node[];
666
676
 
677
+ /**
678
+ * graphqlCallClient.ts: the client an operation's own call passes, read
679
+ * at that one call.
680
+ *
681
+ * Apollo sends a hook's operation through the client the app provides,
682
+ * unless the call passes a `client` option, and an imperative
683
+ * `client.query` goes through the client it is called on. A project
684
+ * hook that picks the client from an option of its own decides per
685
+ * caller, so the caller's arguments are bound before the choice is
686
+ * read. Each client construction the packs describe is replaced by a
687
+ * token of its own, and the evaluator says which token the choice comes
688
+ * out as. The README beside this file says what becomes of an operation
689
+ * whose choice stays open.
690
+ */
691
+
692
+ /** Where one operation's call takes its client. */
693
+ interface GraphqlCallSite {
694
+ /** The library call that sends the operation. */
695
+ call: CallExpression;
696
+ /** The project's own wrapper calls between the unit and `call`, innermost first. */
697
+ through: CallExpression[];
698
+ /** The client is the receiver of `call`, or an option in one of its arguments. */
699
+ client: "receiver" | {
700
+ argument: number;
701
+ property: string;
702
+ };
703
+ }
704
+
667
705
  interface ClientCallSite {
668
706
  callExpression: CallExpression;
669
707
  /** Method name on the client object (e.g. "getUser"), null for bare calls like fetch() */
@@ -784,6 +822,8 @@ interface DiscoveredUnit {
784
822
  reason: string;
785
823
  };
786
824
  };
825
+ /** Where the operation's call takes its client, read once the pack's client constructions are known. */
826
+ graphqlCall?: GraphqlCallSite;
787
827
  /**
788
828
  * Populated by `packageExports` discovery. Has the package identity
789
829
  * the adapter uses to build a `function-call` binding
@@ -1363,7 +1403,7 @@ interface ResponseHandOffOptions {
1363
1403
  type CallAccountingOutcome = "invocation" | "terminal" | "unreachable" | "unrecorded";
1364
1404
  /** One call the invocation walk visited, and where it ended up. */
1365
1405
  interface CallAccountingEntry {
1366
- readonly node: CallExpression;
1406
+ readonly node: CallExpression | NewExpression;
1367
1407
  readonly callee: string;
1368
1408
  readonly line: number;
1369
1409
  readonly outcome: CallAccountingOutcome;
@@ -1685,6 +1725,8 @@ declare function writtenNodeOf(value: Node, resolution: ResolutionStore | undefi
1685
1725
  * empty" from "could not read" (#123).
1686
1726
  */
1687
1727
  declare function stringValueOf(value: Node, resolution: ResolutionStore | undefined): string | null;
1728
+ /** The one string, number or boolean this value comes to, or null when it does not settle to one. */
1729
+ declare function scalarValueOf(value: Node, resolution: ResolutionStore | undefined): string | number | boolean | null;
1688
1730
  /** The number this value comes to, or null when it does not settle to one. */
1689
1731
  declare function numberValueOf(value: Node, resolution: ResolutionStore | undefined): number | null;
1690
1732
  /**
@@ -2157,6 +2199,13 @@ declare function computeAdapterPacksDigest(packVersions: ReadonlyArray<{
2157
2199
  * presence test has passed.
2158
2200
  */
2159
2201
  declare function isDefaultedAt(node: Node): boolean;
2202
+ /**
2203
+ * The expression that supplies a value when the read comes back empty:
2204
+ * the right side of the `??` or `||` the read falls back through, or a
2205
+ * destructured read's own default, as in `const { X = "d" } = env`.
2206
+ * Null when nothing falls back from the read itself.
2207
+ */
2208
+ declare function fallbackOf(read: Node): Node | null;
2160
2209
 
2161
2210
  /**
2162
2211
  * The expression inside any type-level wrappers: `as` and
@@ -2181,4 +2230,4 @@ declare function climbSyntax(node: Node): Node;
2181
2230
  */
2182
2231
  declare function peelValue(node: Node): Node;
2183
2232
 
2184
- 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 FilePlace, type FoundTerminal, type FunctionRoot, GENERIC_TERMINALS, type ImportScanOptions, NO_BARRIERS, type ObservedStubCall, type RawBranchResult, type ReadNameOptions, type ReceiverType, type RefreshReport, ResolutionStore, SKIP_DIRECTORIES, SOURCE_SUFFIXES, type StubCallEvidence, type StubEvidenceOptions, TSCONFIG_NAMES, type TsAccessRecognizerContext, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, type WrittenPayload, 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, numberValueOf, objectLiteralOf, parseConditionExpression, pathFromRun, peelSyntax, peelValue, placeOutsideRun, projectPlaceOf, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, readTsconfigFileList, receiverTypesOf, resolveAliasedSymbol, resolveSubject, rootIdentifier, specifierImportedAs, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceNameFor, workspaceRootFor, writtenNodeOf, writtenPayloadOf };
2233
+ 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 FilePlace, type FoundTerminal, type FunctionRoot, GENERIC_TERMINALS, type ImportScanOptions, NO_BARRIERS, type ObservedStubCall, type RawBranchResult, type ReadNameOptions, type ReceiverType, type RefreshReport, ResolutionStore, SKIP_DIRECTORIES, SOURCE_SUFFIXES, type StubCallEvidence, type StubEvidenceOptions, TSCONFIG_NAMES, type TsAccessRecognizerContext, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, type WrittenPayload, accessContextFor, arrayLiteralOf, buildProjectHelperIndex, callOpsFor, climbSyntax, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, couldNameAValue, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, declarationsBehind, discoverUnits, dottedPathOf, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, fallbackOf, findEnclosingFunction, findNearestTsconfig, findTerminals, functionTargetOf, functionValueOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isDefaultedAt, isImportedFrom, methodDeclaredIn, namedImportsOf, numberValueOf, objectLiteralOf, parseConditionExpression, pathFromRun, peelSyntax, peelValue, placeOutsideRun, projectPlaceOf, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, readTsconfigFileList, receiverTypesOf, resolveAliasedSymbol, resolveSubject, rootIdentifier, scalarValueOf, specifierImportedAs, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceNameFor, workspaceRootFor, writtenNodeOf, writtenPayloadOf };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, Expression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Identifier } from 'ts-morph';
1
+ import { Node, SourceFile, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, ConstructorDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, Expression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Identifier } from 'ts-morph';
2
2
  import { PatternPack, TransparentWrapper, ParameterSupplier, VersionPlacement, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, ArgumentParser, StatedSlot, AstCapableOps, CallOps, EffectArg, LanguageAdapter, ExtractorOptions, TimingReport, CacheDiagnostic, ExtractionReport, DeclaredModule, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, ResponsePropertyMapping, RawBranch, KeepsArms, configuredCallOption, RawDeclaredContract, ContractPattern } from '@suss/extractor';
3
3
  export { EmptyStage, ExtractionReport, PackFunnel, Timer, TimingReport, computeContentHash } from '@suss/extractor';
4
4
  import { MessageBusSemantics, DeployableUnit, UnfollowedCall, WrapperReference, Effect, BehavioralSummary, BoundaryBinding, Predicate, TypeShape, ValueRef } from '@suss/behavioral-ir';
@@ -13,6 +13,11 @@ interface RuntimeSpellings {
13
13
  exitCalls: readonly string[];
14
14
  exitCodeWrites: readonly string[];
15
15
  }
16
+ /**
17
+ * The dotted path an expression spells, when every part of it is an
18
+ * identifier or it starts at `import.meta`, as `import.meta.env` does.
19
+ */
20
+ declare function dottedPathOf(expression: Node): string | null;
16
21
 
17
22
  /**
18
23
  * A library's own module, written into the project by that library's
@@ -635,7 +640,12 @@ type AppVersioning = {
635
640
  defaultVersion: StatedVersion;
636
641
  };
637
642
 
638
- type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | MethodDeclaration;
643
+ /**
644
+ * A function a unit is built on. A constructor is one, since `new
645
+ * Client()` runs its body and its parameters' defaults the way a call
646
+ * runs a function's.
647
+ */
648
+ type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | MethodDeclaration | ConstructorDeclaration;
639
649
  /**
640
650
  * Public API: returns RawCondition[] with structured: null.
641
651
  * Use collectAncestorConditionInfos when you need the Expression nodes.
@@ -664,6 +674,34 @@ declare function hasBody(fn: Node): boolean;
664
674
  */
665
675
  declare function declarationsBehind(symbol: Symbol | undefined): Node[];
666
676
 
677
+ /**
678
+ * graphqlCallClient.ts: the client an operation's own call passes, read
679
+ * at that one call.
680
+ *
681
+ * Apollo sends a hook's operation through the client the app provides,
682
+ * unless the call passes a `client` option, and an imperative
683
+ * `client.query` goes through the client it is called on. A project
684
+ * hook that picks the client from an option of its own decides per
685
+ * caller, so the caller's arguments are bound before the choice is
686
+ * read. Each client construction the packs describe is replaced by a
687
+ * token of its own, and the evaluator says which token the choice comes
688
+ * out as. The README beside this file says what becomes of an operation
689
+ * whose choice stays open.
690
+ */
691
+
692
+ /** Where one operation's call takes its client. */
693
+ interface GraphqlCallSite {
694
+ /** The library call that sends the operation. */
695
+ call: CallExpression;
696
+ /** The project's own wrapper calls between the unit and `call`, innermost first. */
697
+ through: CallExpression[];
698
+ /** The client is the receiver of `call`, or an option in one of its arguments. */
699
+ client: "receiver" | {
700
+ argument: number;
701
+ property: string;
702
+ };
703
+ }
704
+
667
705
  interface ClientCallSite {
668
706
  callExpression: CallExpression;
669
707
  /** Method name on the client object (e.g. "getUser"), null for bare calls like fetch() */
@@ -784,6 +822,8 @@ interface DiscoveredUnit {
784
822
  reason: string;
785
823
  };
786
824
  };
825
+ /** Where the operation's call takes its client, read once the pack's client constructions are known. */
826
+ graphqlCall?: GraphqlCallSite;
787
827
  /**
788
828
  * Populated by `packageExports` discovery. Has the package identity
789
829
  * the adapter uses to build a `function-call` binding
@@ -1363,7 +1403,7 @@ interface ResponseHandOffOptions {
1363
1403
  type CallAccountingOutcome = "invocation" | "terminal" | "unreachable" | "unrecorded";
1364
1404
  /** One call the invocation walk visited, and where it ended up. */
1365
1405
  interface CallAccountingEntry {
1366
- readonly node: CallExpression;
1406
+ readonly node: CallExpression | NewExpression;
1367
1407
  readonly callee: string;
1368
1408
  readonly line: number;
1369
1409
  readonly outcome: CallAccountingOutcome;
@@ -1685,6 +1725,8 @@ declare function writtenNodeOf(value: Node, resolution: ResolutionStore | undefi
1685
1725
  * empty" from "could not read" (#123).
1686
1726
  */
1687
1727
  declare function stringValueOf(value: Node, resolution: ResolutionStore | undefined): string | null;
1728
+ /** The one string, number or boolean this value comes to, or null when it does not settle to one. */
1729
+ declare function scalarValueOf(value: Node, resolution: ResolutionStore | undefined): string | number | boolean | null;
1688
1730
  /** The number this value comes to, or null when it does not settle to one. */
1689
1731
  declare function numberValueOf(value: Node, resolution: ResolutionStore | undefined): number | null;
1690
1732
  /**
@@ -2157,6 +2199,13 @@ declare function computeAdapterPacksDigest(packVersions: ReadonlyArray<{
2157
2199
  * presence test has passed.
2158
2200
  */
2159
2201
  declare function isDefaultedAt(node: Node): boolean;
2202
+ /**
2203
+ * The expression that supplies a value when the read comes back empty:
2204
+ * the right side of the `??` or `||` the read falls back through, or a
2205
+ * destructured read's own default, as in `const { X = "d" } = env`.
2206
+ * Null when nothing falls back from the read itself.
2207
+ */
2208
+ declare function fallbackOf(read: Node): Node | null;
2160
2209
 
2161
2210
  /**
2162
2211
  * The expression inside any type-level wrappers: `as` and
@@ -2181,4 +2230,4 @@ declare function climbSyntax(node: Node): Node;
2181
2230
  */
2182
2231
  declare function peelValue(node: Node): Node;
2183
2232
 
2184
- 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 FilePlace, type FoundTerminal, type FunctionRoot, GENERIC_TERMINALS, type ImportScanOptions, NO_BARRIERS, type ObservedStubCall, type RawBranchResult, type ReadNameOptions, type ReceiverType, type RefreshReport, ResolutionStore, SKIP_DIRECTORIES, SOURCE_SUFFIXES, type StubCallEvidence, type StubEvidenceOptions, TSCONFIG_NAMES, type TsAccessRecognizerContext, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, type WrittenPayload, 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, numberValueOf, objectLiteralOf, parseConditionExpression, pathFromRun, peelSyntax, peelValue, placeOutsideRun, projectPlaceOf, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, readTsconfigFileList, receiverTypesOf, resolveAliasedSymbol, resolveSubject, rootIdentifier, specifierImportedAs, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceNameFor, workspaceRootFor, writtenNodeOf, writtenPayloadOf };
2233
+ 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 FilePlace, type FoundTerminal, type FunctionRoot, GENERIC_TERMINALS, type ImportScanOptions, NO_BARRIERS, type ObservedStubCall, type RawBranchResult, type ReadNameOptions, type ReceiverType, type RefreshReport, ResolutionStore, SKIP_DIRECTORIES, SOURCE_SUFFIXES, type StubCallEvidence, type StubEvidenceOptions, TSCONFIG_NAMES, type TsAccessRecognizerContext, type TsDiscoveryContext, type TsInvocationRecognizerContext, type TsJsxAttributeLocation, type TsSubUnitContext, type TypeScriptAdapter, type TypeScriptAdapterConfig, TypeScriptWhySession, type WhySessionOptions, type WrittenPayload, accessContextFor, arrayLiteralOf, buildProjectHelperIndex, callOpsFor, climbSyntax, collectAncestorBranches, collectClientFieldAccesses, computeAdapterPacksDigest, couldNameAValue, createProjectWithoutTsconfig, createTsDiscoveryContext, createTsSubUnitContext, createTypeScriptAdapter, declarationsBehind, discoverUnits, dottedPathOf, exportedDeclarationsOf, extractCodeStructure, extractRawBranches, fallbackOf, findEnclosingFunction, findNearestTsconfig, findTerminals, functionTargetOf, functionValueOf, hasBody, importDeclarationsOf, importedNamesOf, importedRootsOf, invocationContextFor, isDefaultedAt, isImportedFrom, methodDeclaredIn, namedImportsOf, numberValueOf, objectLiteralOf, parseConditionExpression, pathFromRun, peelSyntax, peelValue, placeOutsideRun, projectPlaceOf, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, readTsconfigFileList, receiverTypesOf, resolveAliasedSymbol, resolveSubject, rootIdentifier, scalarValueOf, specifierImportedAs, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceNameFor, workspaceRootFor, writtenNodeOf, writtenPayloadOf };