@suss/adapter-typescript 0.34.0 → 0.34.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/README.md +1 -1
- package/dist/index.cjs +6731 -5642
- package/dist/index.d.cts +122 -5
- package/dist/index.d.ts +122 -5
- package/dist/index.js +6654 -5551
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike,
|
|
2
|
-
import { PatternPack, TransparentWrapper, ParameterSupplier, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, ArgumentParser, StatedSlot, AstCapableOps, CallOps, EffectArg, LanguageAdapter, ExtractorOptions, TimingReport, CacheDiagnostic, ExtractionReport, DeclaredModule, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, RawBranch, configuredCallOption, RawDeclaredContract, ContractPattern
|
|
1
|
+
import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, Expression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Identifier } from 'ts-morph';
|
|
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';
|
|
5
5
|
import { ExplainStats, SourceLeaf, ValueUses, WhyExplained, ValueLocation } from '@suss/resolution';
|
|
@@ -556,6 +556,45 @@ interface GlobalPrefix {
|
|
|
556
556
|
excluded: ExcludedRoute[];
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
+
/**
|
|
560
|
+
* The API versions a decorated route serves, and the paths they put it at.
|
|
561
|
+
*
|
|
562
|
+
* NestJS reads `@Controller({ version })` and `@Version()` only after the
|
|
563
|
+
* bootstrap calls `app.enableVersioning()`, usually in a file with no
|
|
564
|
+
* controller in it. URI versioning puts `v1` in the path after the global
|
|
565
|
+
* prefix and before the controller's path. Header, media type and custom
|
|
566
|
+
* versioning leave the path alone, so every version of a route shares it.
|
|
567
|
+
*
|
|
568
|
+
* When the run cannot read how the application serves versions, a route
|
|
569
|
+
* that states a version claims no path. Any path it claimed could pair it
|
|
570
|
+
* with a client or a document for another version.
|
|
571
|
+
*/
|
|
572
|
+
|
|
573
|
+
/** The versions a route or an application states. Null in the list means every version. */
|
|
574
|
+
type StatedVersion = {
|
|
575
|
+
kind: "unstated";
|
|
576
|
+
} | {
|
|
577
|
+
kind: "unread";
|
|
578
|
+
} | {
|
|
579
|
+
kind: "listed";
|
|
580
|
+
versions: ReadonlyArray<string | null>;
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* How an application serves versions. `off` means the run read the
|
|
584
|
+
* application and nothing turns versioning on, so Nest ignores every
|
|
585
|
+
* version a route states.
|
|
586
|
+
*/
|
|
587
|
+
type AppVersioning = {
|
|
588
|
+
kind: "off";
|
|
589
|
+
} | {
|
|
590
|
+
kind: "unread";
|
|
591
|
+
} | {
|
|
592
|
+
kind: "on";
|
|
593
|
+
placement: VersionPlacement;
|
|
594
|
+
pathPrefix: string;
|
|
595
|
+
defaultVersion: StatedVersion;
|
|
596
|
+
};
|
|
597
|
+
|
|
559
598
|
type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | MethodDeclaration;
|
|
560
599
|
/**
|
|
561
600
|
* Public API: returns RawCondition[] with structured: null.
|
|
@@ -732,6 +771,12 @@ interface DiscoveredUnit {
|
|
|
732
771
|
method: string | null;
|
|
733
772
|
path: string | null;
|
|
734
773
|
};
|
|
774
|
+
/**
|
|
775
|
+
* The file a file convention found this unit in. Its path and export
|
|
776
|
+
* name decide the route, even when the function it exports was written
|
|
777
|
+
* in another module or returned by a factory.
|
|
778
|
+
*/
|
|
779
|
+
routeFile?: SourceFile;
|
|
735
780
|
/**
|
|
736
781
|
* The status the framework sends for a response this unit's body
|
|
737
782
|
* states none for, when the route declares one: `@HttpCode(204)`, or
|
|
@@ -739,6 +784,8 @@ interface DiscoveredUnit {
|
|
|
739
784
|
* pack's response terminals for this unit alone.
|
|
740
785
|
*/
|
|
741
786
|
defaultStatusCode?: number;
|
|
787
|
+
/** Statuses the route's own decorators list as possible responses. */
|
|
788
|
+
declaredStatuses?: number[];
|
|
742
789
|
/**
|
|
743
790
|
* Populated by a pack's `discoverUnits` callback for a message-bus
|
|
744
791
|
* consumer whose channel the code gives (a handler factory whose
|
|
@@ -831,6 +878,8 @@ interface MountPrefixIndex {
|
|
|
831
878
|
* puts in front of its routes. A key with no entry has none.
|
|
832
879
|
*/
|
|
833
880
|
globalPrefixes?: ReadonlyMap<string, GlobalPrefix>;
|
|
881
|
+
/** How the run's applications serve API versions, keyed by `routeVersioningKey`. */
|
|
882
|
+
versionings?: ReadonlyMap<string, AppVersioning>;
|
|
834
883
|
}
|
|
835
884
|
/**
|
|
836
885
|
* What the project helper index says it has already expanded, which the
|
|
@@ -1137,10 +1186,18 @@ interface TypeScriptAdapterConfig {
|
|
|
1137
1186
|
onCacheDiagnostic?: (diagnostic: CacheDiagnostic) => void;
|
|
1138
1187
|
/** Not called on a cache hit, where no stage ran. */
|
|
1139
1188
|
onExtractionReport?: (report: ExtractionReport) => void;
|
|
1140
|
-
/**
|
|
1189
|
+
/**
|
|
1190
|
+
* Absolute. `.suss/cache/` in `walkedDirectory` when set, otherwise
|
|
1191
|
+
* beside the tsconfig; `null` turns it off.
|
|
1192
|
+
*/
|
|
1141
1193
|
cacheDir?: string | null;
|
|
1142
1194
|
/** The modules the project lists in `suss.json`, with absolute paths. */
|
|
1143
1195
|
modules?: readonly DeclaredModule[];
|
|
1196
|
+
/**
|
|
1197
|
+
* Absolute. Walks only the tsconfig's files under this directory, for a
|
|
1198
|
+
* tsconfig found above the directory a run was pointed at.
|
|
1199
|
+
*/
|
|
1200
|
+
walkedDirectory?: string;
|
|
1144
1201
|
}
|
|
1145
1202
|
interface TypeScriptAdapter extends LanguageAdapter {
|
|
1146
1203
|
/** Kept off `LanguageAdapter`, so a caller needing ts-morph asks for it. */
|
|
@@ -1208,6 +1265,31 @@ interface FoundTerminal {
|
|
|
1208
1265
|
*/
|
|
1209
1266
|
declare function findTerminals(func: FunctionRoot, patterns: TerminalPattern[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, resolveCallee?: ResolveCallee): FoundTerminal[];
|
|
1210
1267
|
|
|
1268
|
+
/**
|
|
1269
|
+
* Reads a project function a client caller hands its response to as part
|
|
1270
|
+
* of the caller.
|
|
1271
|
+
*
|
|
1272
|
+
* const response = await fetch(`/api/orders/${id}`);
|
|
1273
|
+
* return readOrder(response);
|
|
1274
|
+
*
|
|
1275
|
+
* `readOrder` throws on `!response.ok`. Read alone, the caller tests
|
|
1276
|
+
* nothing, so every failure looks unhandled. The helper's paths are read
|
|
1277
|
+
* the way the caller's were, with each parameter replaced by what the
|
|
1278
|
+
* caller passed, and each becomes a path of the caller. A helper is
|
|
1279
|
+
* followed only when one of its paths tests the response or its parsed
|
|
1280
|
+
* body, so a call that logs the response leaves the caller as it was.
|
|
1281
|
+
*/
|
|
1282
|
+
|
|
1283
|
+
interface ResponseHandOffOptions {
|
|
1284
|
+
/** The callee text the caller's own conditions use for the response. */
|
|
1285
|
+
responseCallee: string;
|
|
1286
|
+
/** The callee texts they use for its parsed body, such as `res.json`. */
|
|
1287
|
+
bodyCallees: readonly string[];
|
|
1288
|
+
/** The pack's response members, to tell a body field from a status read. */
|
|
1289
|
+
responseSemantics: ResponsePropertyMapping[] | undefined;
|
|
1290
|
+
resolution: ResolutionStore;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1211
1293
|
/**
|
|
1212
1294
|
* Turns one function into the list of branches a summary is built from.
|
|
1213
1295
|
*
|
|
@@ -1257,8 +1339,29 @@ interface RawBranchResult {
|
|
|
1257
1339
|
* or when every condition on it came from an early return or throw,
|
|
1258
1340
|
* since those are the paths that run when no guard fired.
|
|
1259
1341
|
*/
|
|
1260
|
-
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee, collectCallAccounting?: boolean): RawBranchResult;
|
|
1342
|
+
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee, collectCallAccounting?: boolean, keepsArms?: KeepsArms<Expression>, handOff?: ResponseHandOffOptions): RawBranchResult;
|
|
1261
1343
|
|
|
1344
|
+
/**
|
|
1345
|
+
* Picks the files a run walks, and gets the compiler ahead of the
|
|
1346
|
+
* import graph before anything asks it a question.
|
|
1347
|
+
*
|
|
1348
|
+
* `createLazyProject` reads the tsconfig's file list and keeps the
|
|
1349
|
+
* files whose imports match some active pack's `requiresImport` gate.
|
|
1350
|
+
* Those candidates are what the run walks; everything else is loaded
|
|
1351
|
+
* later, one file at a time, by `lazyAddSourceFile` when symbol
|
|
1352
|
+
* resolution points at it.
|
|
1353
|
+
*
|
|
1354
|
+
* The rest of the module is about load order. TypeScript follows a
|
|
1355
|
+
* re-export chain by recursing, so a barrel chain a few hundred files
|
|
1356
|
+
* deep runs the call stack out. `loadImportGraphsDepthFirst` loads each
|
|
1357
|
+
* file after everything it imports. The README says why that matters.
|
|
1358
|
+
*/
|
|
1359
|
+
|
|
1360
|
+
/** Reads no source, so a cache hit never pays for the bootstrap. */
|
|
1361
|
+
declare function readTsconfigFileList(tsConfigFilePath: string): string[];
|
|
1362
|
+
|
|
1363
|
+
/** The suffixes this adapter reads, JavaScript included. */
|
|
1364
|
+
declare const SOURCE_SUFFIXES: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
1262
1365
|
/**
|
|
1263
1366
|
* A Project covering `rootDir`, for a codebase with no tsconfig to read.
|
|
1264
1367
|
* Returns the project and the files it loaded.
|
|
@@ -1434,6 +1537,12 @@ declare function namedImportsOf(sourceFile: SourceFile, modules: readonly string
|
|
|
1434
1537
|
declare function importedNamesOf(sourceFile: SourceFile, modules: readonly string[], options?: ImportScanOptions): Map<string, string>;
|
|
1435
1538
|
/** The local spellings of default and namespace imports of these modules. */
|
|
1436
1539
|
declare function importedRootsOf(sourceFile: SourceFile, modules: readonly string[], options?: ImportScanOptions): Set<string>;
|
|
1540
|
+
/**
|
|
1541
|
+
* The specifier, as written, of the import that binds this local name,
|
|
1542
|
+
* whether as a named, default or namespace import. Null when no import
|
|
1543
|
+
* in the file binds it.
|
|
1544
|
+
*/
|
|
1545
|
+
declare function specifierImportedAs(sourceFile: SourceFile, local: string): string | null;
|
|
1437
1546
|
/** Every import declaration in the file that names one of `modules`. */
|
|
1438
1547
|
declare function importDeclarationsOf(sourceFile: SourceFile, modules: readonly string[], options?: ImportScanOptions): ImportDeclaration[];
|
|
1439
1548
|
|
|
@@ -1866,6 +1975,14 @@ declare function createTsSubUnitContext(): TsSubUnitContext;
|
|
|
1866
1975
|
* way twice.
|
|
1867
1976
|
*/
|
|
1868
1977
|
declare function workspaceRootFor(anchor: string): string;
|
|
1978
|
+
/**
|
|
1979
|
+
* What a project calls itself.
|
|
1980
|
+
*
|
|
1981
|
+
* Its package.json name is what a person would say and what a sibling
|
|
1982
|
+
* package already imports it by. A project without one falls back to
|
|
1983
|
+
* the folder, which is at least what somebody typed.
|
|
1984
|
+
*/
|
|
1985
|
+
declare function workspaceNameFor(root: string | undefined): string | null;
|
|
1869
1986
|
|
|
1870
1987
|
/** What a call writes out, and whether it was serialized as JSON first. */
|
|
1871
1988
|
interface WrittenPayload {
|
|
@@ -1982,4 +2099,4 @@ declare function climbSyntax(node: Node): Node;
|
|
|
1982
2099
|
*/
|
|
1983
2100
|
declare function peelValue(node: Node): Node;
|
|
1984
2101
|
|
|
1985
|
-
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, type ReceiverType, type RefreshReport, ResolutionStore, 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, peelSyntax, peelValue, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, receiverTypesOf, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceRootFor, writtenNodeOf, writtenPayloadOf };
|
|
2102
|
+
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, type ReceiverType, type RefreshReport, ResolutionStore, 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, peelSyntax, peelValue, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike,
|
|
2
|
-
import { PatternPack, TransparentWrapper, ParameterSupplier, RawCondition, DiscoveryPattern, TerminalPattern, InputMappingPattern, ArgumentParser, StatedSlot, AstCapableOps, CallOps, EffectArg, LanguageAdapter, ExtractorOptions, TimingReport, CacheDiagnostic, ExtractionReport, DeclaredModule, InvocationRecognizer, AccessRecognizer, RawCodeStructure, RawTerminal, RawBranch, configuredCallOption, RawDeclaredContract, ContractPattern
|
|
1
|
+
import { SourceFile, Node, Project, FunctionDeclaration, FunctionExpression, ArrowFunction, MethodDeclaration, Symbol, CallExpression, NewExpression, TaggedTemplateExpression, PropertyAccessExpression, Expression, ImportDeclaration, ArrayLiteralExpression, ObjectLiteralExpression, ObjectLiteralElementLike, Identifier } from 'ts-morph';
|
|
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';
|
|
5
5
|
import { ExplainStats, SourceLeaf, ValueUses, WhyExplained, ValueLocation } from '@suss/resolution';
|
|
@@ -556,6 +556,45 @@ interface GlobalPrefix {
|
|
|
556
556
|
excluded: ExcludedRoute[];
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
+
/**
|
|
560
|
+
* The API versions a decorated route serves, and the paths they put it at.
|
|
561
|
+
*
|
|
562
|
+
* NestJS reads `@Controller({ version })` and `@Version()` only after the
|
|
563
|
+
* bootstrap calls `app.enableVersioning()`, usually in a file with no
|
|
564
|
+
* controller in it. URI versioning puts `v1` in the path after the global
|
|
565
|
+
* prefix and before the controller's path. Header, media type and custom
|
|
566
|
+
* versioning leave the path alone, so every version of a route shares it.
|
|
567
|
+
*
|
|
568
|
+
* When the run cannot read how the application serves versions, a route
|
|
569
|
+
* that states a version claims no path. Any path it claimed could pair it
|
|
570
|
+
* with a client or a document for another version.
|
|
571
|
+
*/
|
|
572
|
+
|
|
573
|
+
/** The versions a route or an application states. Null in the list means every version. */
|
|
574
|
+
type StatedVersion = {
|
|
575
|
+
kind: "unstated";
|
|
576
|
+
} | {
|
|
577
|
+
kind: "unread";
|
|
578
|
+
} | {
|
|
579
|
+
kind: "listed";
|
|
580
|
+
versions: ReadonlyArray<string | null>;
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* How an application serves versions. `off` means the run read the
|
|
584
|
+
* application and nothing turns versioning on, so Nest ignores every
|
|
585
|
+
* version a route states.
|
|
586
|
+
*/
|
|
587
|
+
type AppVersioning = {
|
|
588
|
+
kind: "off";
|
|
589
|
+
} | {
|
|
590
|
+
kind: "unread";
|
|
591
|
+
} | {
|
|
592
|
+
kind: "on";
|
|
593
|
+
placement: VersionPlacement;
|
|
594
|
+
pathPrefix: string;
|
|
595
|
+
defaultVersion: StatedVersion;
|
|
596
|
+
};
|
|
597
|
+
|
|
559
598
|
type FunctionRoot = FunctionDeclaration | FunctionExpression | ArrowFunction | MethodDeclaration;
|
|
560
599
|
/**
|
|
561
600
|
* Public API: returns RawCondition[] with structured: null.
|
|
@@ -732,6 +771,12 @@ interface DiscoveredUnit {
|
|
|
732
771
|
method: string | null;
|
|
733
772
|
path: string | null;
|
|
734
773
|
};
|
|
774
|
+
/**
|
|
775
|
+
* The file a file convention found this unit in. Its path and export
|
|
776
|
+
* name decide the route, even when the function it exports was written
|
|
777
|
+
* in another module or returned by a factory.
|
|
778
|
+
*/
|
|
779
|
+
routeFile?: SourceFile;
|
|
735
780
|
/**
|
|
736
781
|
* The status the framework sends for a response this unit's body
|
|
737
782
|
* states none for, when the route declares one: `@HttpCode(204)`, or
|
|
@@ -739,6 +784,8 @@ interface DiscoveredUnit {
|
|
|
739
784
|
* pack's response terminals for this unit alone.
|
|
740
785
|
*/
|
|
741
786
|
defaultStatusCode?: number;
|
|
787
|
+
/** Statuses the route's own decorators list as possible responses. */
|
|
788
|
+
declaredStatuses?: number[];
|
|
742
789
|
/**
|
|
743
790
|
* Populated by a pack's `discoverUnits` callback for a message-bus
|
|
744
791
|
* consumer whose channel the code gives (a handler factory whose
|
|
@@ -831,6 +878,8 @@ interface MountPrefixIndex {
|
|
|
831
878
|
* puts in front of its routes. A key with no entry has none.
|
|
832
879
|
*/
|
|
833
880
|
globalPrefixes?: ReadonlyMap<string, GlobalPrefix>;
|
|
881
|
+
/** How the run's applications serve API versions, keyed by `routeVersioningKey`. */
|
|
882
|
+
versionings?: ReadonlyMap<string, AppVersioning>;
|
|
834
883
|
}
|
|
835
884
|
/**
|
|
836
885
|
* What the project helper index says it has already expanded, which the
|
|
@@ -1137,10 +1186,18 @@ interface TypeScriptAdapterConfig {
|
|
|
1137
1186
|
onCacheDiagnostic?: (diagnostic: CacheDiagnostic) => void;
|
|
1138
1187
|
/** Not called on a cache hit, where no stage ran. */
|
|
1139
1188
|
onExtractionReport?: (report: ExtractionReport) => void;
|
|
1140
|
-
/**
|
|
1189
|
+
/**
|
|
1190
|
+
* Absolute. `.suss/cache/` in `walkedDirectory` when set, otherwise
|
|
1191
|
+
* beside the tsconfig; `null` turns it off.
|
|
1192
|
+
*/
|
|
1141
1193
|
cacheDir?: string | null;
|
|
1142
1194
|
/** The modules the project lists in `suss.json`, with absolute paths. */
|
|
1143
1195
|
modules?: readonly DeclaredModule[];
|
|
1196
|
+
/**
|
|
1197
|
+
* Absolute. Walks only the tsconfig's files under this directory, for a
|
|
1198
|
+
* tsconfig found above the directory a run was pointed at.
|
|
1199
|
+
*/
|
|
1200
|
+
walkedDirectory?: string;
|
|
1144
1201
|
}
|
|
1145
1202
|
interface TypeScriptAdapter extends LanguageAdapter {
|
|
1146
1203
|
/** Kept off `LanguageAdapter`, so a caller needing ts-morph asks for it. */
|
|
@@ -1208,6 +1265,31 @@ interface FoundTerminal {
|
|
|
1208
1265
|
*/
|
|
1209
1266
|
declare function findTerminals(func: FunctionRoot, patterns: TerminalPattern[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, resolveCallee?: ResolveCallee): FoundTerminal[];
|
|
1210
1267
|
|
|
1268
|
+
/**
|
|
1269
|
+
* Reads a project function a client caller hands its response to as part
|
|
1270
|
+
* of the caller.
|
|
1271
|
+
*
|
|
1272
|
+
* const response = await fetch(`/api/orders/${id}`);
|
|
1273
|
+
* return readOrder(response);
|
|
1274
|
+
*
|
|
1275
|
+
* `readOrder` throws on `!response.ok`. Read alone, the caller tests
|
|
1276
|
+
* nothing, so every failure looks unhandled. The helper's paths are read
|
|
1277
|
+
* the way the caller's were, with each parameter replaced by what the
|
|
1278
|
+
* caller passed, and each becomes a path of the caller. A helper is
|
|
1279
|
+
* followed only when one of its paths tests the response or its parsed
|
|
1280
|
+
* body, so a call that logs the response leaves the caller as it was.
|
|
1281
|
+
*/
|
|
1282
|
+
|
|
1283
|
+
interface ResponseHandOffOptions {
|
|
1284
|
+
/** The callee text the caller's own conditions use for the response. */
|
|
1285
|
+
responseCallee: string;
|
|
1286
|
+
/** The callee texts they use for its parsed body, such as `res.json`. */
|
|
1287
|
+
bodyCallees: readonly string[];
|
|
1288
|
+
/** The pack's response members, to tell a body field from a status read. */
|
|
1289
|
+
responseSemantics: ResponsePropertyMapping[] | undefined;
|
|
1290
|
+
resolution: ResolutionStore;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1211
1293
|
/**
|
|
1212
1294
|
* Turns one function into the list of branches a summary is built from.
|
|
1213
1295
|
*
|
|
@@ -1257,8 +1339,29 @@ interface RawBranchResult {
|
|
|
1257
1339
|
* or when every condition on it came from an early return or throw,
|
|
1258
1340
|
* since those are the paths that run when no guard fired.
|
|
1259
1341
|
*/
|
|
1260
|
-
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee, collectCallAccounting?: boolean): RawBranchResult;
|
|
1342
|
+
declare function extractRawBranches(func: FunctionRoot, terminalPatterns: TerminalPattern[], invocationRecognizers?: InvocationRecognizer[], accessRecognizers?: AccessRecognizer[], barriers?: DescentBarriers, resolution?: ResolutionStore, originatesFrom?: OriginatesFrom, anchorCallsOf?: AnchorCallsOf, resolveCallee?: ResolveCallee, collectCallAccounting?: boolean, keepsArms?: KeepsArms<Expression>, handOff?: ResponseHandOffOptions): RawBranchResult;
|
|
1261
1343
|
|
|
1344
|
+
/**
|
|
1345
|
+
* Picks the files a run walks, and gets the compiler ahead of the
|
|
1346
|
+
* import graph before anything asks it a question.
|
|
1347
|
+
*
|
|
1348
|
+
* `createLazyProject` reads the tsconfig's file list and keeps the
|
|
1349
|
+
* files whose imports match some active pack's `requiresImport` gate.
|
|
1350
|
+
* Those candidates are what the run walks; everything else is loaded
|
|
1351
|
+
* later, one file at a time, by `lazyAddSourceFile` when symbol
|
|
1352
|
+
* resolution points at it.
|
|
1353
|
+
*
|
|
1354
|
+
* The rest of the module is about load order. TypeScript follows a
|
|
1355
|
+
* re-export chain by recursing, so a barrel chain a few hundred files
|
|
1356
|
+
* deep runs the call stack out. `loadImportGraphsDepthFirst` loads each
|
|
1357
|
+
* file after everything it imports. The README says why that matters.
|
|
1358
|
+
*/
|
|
1359
|
+
|
|
1360
|
+
/** Reads no source, so a cache hit never pays for the bootstrap. */
|
|
1361
|
+
declare function readTsconfigFileList(tsConfigFilePath: string): string[];
|
|
1362
|
+
|
|
1363
|
+
/** The suffixes this adapter reads, JavaScript included. */
|
|
1364
|
+
declare const SOURCE_SUFFIXES: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
1262
1365
|
/**
|
|
1263
1366
|
* A Project covering `rootDir`, for a codebase with no tsconfig to read.
|
|
1264
1367
|
* Returns the project and the files it loaded.
|
|
@@ -1434,6 +1537,12 @@ declare function namedImportsOf(sourceFile: SourceFile, modules: readonly string
|
|
|
1434
1537
|
declare function importedNamesOf(sourceFile: SourceFile, modules: readonly string[], options?: ImportScanOptions): Map<string, string>;
|
|
1435
1538
|
/** The local spellings of default and namespace imports of these modules. */
|
|
1436
1539
|
declare function importedRootsOf(sourceFile: SourceFile, modules: readonly string[], options?: ImportScanOptions): Set<string>;
|
|
1540
|
+
/**
|
|
1541
|
+
* The specifier, as written, of the import that binds this local name,
|
|
1542
|
+
* whether as a named, default or namespace import. Null when no import
|
|
1543
|
+
* in the file binds it.
|
|
1544
|
+
*/
|
|
1545
|
+
declare function specifierImportedAs(sourceFile: SourceFile, local: string): string | null;
|
|
1437
1546
|
/** Every import declaration in the file that names one of `modules`. */
|
|
1438
1547
|
declare function importDeclarationsOf(sourceFile: SourceFile, modules: readonly string[], options?: ImportScanOptions): ImportDeclaration[];
|
|
1439
1548
|
|
|
@@ -1866,6 +1975,14 @@ declare function createTsSubUnitContext(): TsSubUnitContext;
|
|
|
1866
1975
|
* way twice.
|
|
1867
1976
|
*/
|
|
1868
1977
|
declare function workspaceRootFor(anchor: string): string;
|
|
1978
|
+
/**
|
|
1979
|
+
* What a project calls itself.
|
|
1980
|
+
*
|
|
1981
|
+
* Its package.json name is what a person would say and what a sibling
|
|
1982
|
+
* package already imports it by. A project without one falls back to
|
|
1983
|
+
* the folder, which is at least what somebody typed.
|
|
1984
|
+
*/
|
|
1985
|
+
declare function workspaceNameFor(root: string | undefined): string | null;
|
|
1869
1986
|
|
|
1870
1987
|
/** What a call writes out, and whether it was serialized as JSON first. */
|
|
1871
1988
|
interface WrittenPayload {
|
|
@@ -1982,4 +2099,4 @@ declare function climbSyntax(node: Node): Node;
|
|
|
1982
2099
|
*/
|
|
1983
2100
|
declare function peelValue(node: Node): Node;
|
|
1984
2101
|
|
|
1985
|
-
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, type ReceiverType, type RefreshReport, ResolutionStore, 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, peelSyntax, peelValue, propertiesOf, propertyFunctionOf, propertyNameOf, propertyOf, propertyValueOf, readConfiguredCall, readContract, readContractForClientCall, readName, receiverTypesOf, resolveAliasedSymbol, resolveSubject, rootIdentifier, startsItsOwnScope, stringPropertyOf, stringValueOf, stubEvidence, stubEvidenceIn, symbolBehind, toFunctionRoot, workspaceRootFor, writtenNodeOf, writtenPayloadOf };
|
|
2102
|
+
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, type ReceiverType, type RefreshReport, ResolutionStore, 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, peelSyntax, peelValue, 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 };
|