@suss/adapter-python 0.29.0 → 0.31.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/README.md +4 -0
- package/dist/index.cjs +5853 -5617
- package/dist/index.d.cts +57 -21
- package/dist/index.d.ts +57 -21
- package/dist/index.js +5891 -5653
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -111,6 +111,8 @@ interface PythonPack {
|
|
|
111
111
|
storage?: StoragePattern[];
|
|
112
112
|
/** Which of the library's calls give back one of a model class. The README says what a chain of them composes into. */
|
|
113
113
|
models?: PyModelQueries[];
|
|
114
|
+
/** Which of the library's classes return themselves from `__enter__`, so a `with` block gets the object itself. */
|
|
115
|
+
contextManagers?: PyContextManager[];
|
|
114
116
|
/** How the library lets a project hand the database SQL it wrote itself. */
|
|
115
117
|
rawSql?: RawSqlPattern[];
|
|
116
118
|
}
|
|
@@ -170,6 +172,20 @@ interface PyModelQueries {
|
|
|
170
172
|
entryMethods: PyModelEntryMethod[];
|
|
171
173
|
/** Functions the library exports that do the same, called on their own rather than read off a session. */
|
|
172
174
|
entryFunctions: PyModelEntryFunction[];
|
|
175
|
+
/** The library's own constructors for a field that reaches another model. */
|
|
176
|
+
relationships?: PyRelationshipConstructor[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* `items: list[Item] = Relationship(...)`: the callable a model's field
|
|
180
|
+
* is given to say it reaches another model, and where it comes from. A
|
|
181
|
+
* project function spelled the same way is somebody else's, so the
|
|
182
|
+
* import is what settles a match.
|
|
183
|
+
*/
|
|
184
|
+
interface PyRelationshipConstructor {
|
|
185
|
+
/** The module it is imported from, `sqlmodel` or `sqlalchemy.orm`. */
|
|
186
|
+
module: string;
|
|
187
|
+
/** Its name, `Relationship` or `relationship`. */
|
|
188
|
+
name: string;
|
|
173
189
|
}
|
|
174
190
|
/** `session.get(User, id)`: the method, and where the class is written. */
|
|
175
191
|
interface PyModelEntryMethod {
|
|
@@ -197,6 +213,18 @@ interface RawSqlPattern {
|
|
|
197
213
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
198
214
|
}
|
|
199
215
|
type PythonDiscoveryPattern = DecoratedClassRoute | DecoratedFunctionRoute;
|
|
216
|
+
/**
|
|
217
|
+
* A class whose `__enter__` gives back the object it was called on, so
|
|
218
|
+
* `with X() as y` makes y the `X()` the block opened. Python
|
|
219
|
+
* lets `__enter__` return anything, so only the library that wrote the
|
|
220
|
+
* class can say this, and a pack declares it for its own classes alone.
|
|
221
|
+
*/
|
|
222
|
+
interface PyContextManager {
|
|
223
|
+
/** The module the classes come from, `httpx`. */
|
|
224
|
+
module: string;
|
|
225
|
+
/** The class names the library documents as returning self. */
|
|
226
|
+
returnsSelf: string[];
|
|
227
|
+
}
|
|
200
228
|
/**
|
|
201
229
|
* The callables a library gives a project for making a request. A
|
|
202
230
|
* function that calls one of them is a client of the boundary that call
|
|
@@ -516,6 +544,11 @@ type Binding = {
|
|
|
516
544
|
module: string;
|
|
517
545
|
relativeLevel: number;
|
|
518
546
|
localName: string;
|
|
547
|
+
/**
|
|
548
|
+
* False for `import a.b.c`, where the name binds the package `a`
|
|
549
|
+
* and a member read off it lands somewhere other than `module`.
|
|
550
|
+
*/
|
|
551
|
+
bindsWholeModule: boolean;
|
|
519
552
|
} | {
|
|
520
553
|
kind: "importFrom";
|
|
521
554
|
module: string;
|
|
@@ -595,23 +628,11 @@ type RoutePrefixResolution = {
|
|
|
595
628
|
interface RouterIndex {
|
|
596
629
|
resolve(pattern: PythonDiscoveryPattern, module: ModuleBinding, objectName: string): RoutePrefixResolution;
|
|
597
630
|
/**
|
|
598
|
-
* The same
|
|
599
|
-
*
|
|
600
|
-
*
|
|
631
|
+
* The same for a decorator whose object has no variable name to look up,
|
|
632
|
+
* such as one written on `self.router`. The rules give the call that
|
|
633
|
+
* built it, and every construction is already keyed by its call.
|
|
601
634
|
*/
|
|
602
635
|
resolveConstruction(pattern: PythonDiscoveryPattern, module: ModuleBinding, constructorName: string, constructionKey: string): RoutePrefixResolution;
|
|
603
|
-
/**
|
|
604
|
-
* The module-level def a name in another module refers to, with that
|
|
605
|
-
* module's own bindings, so a decorator written through a project wrapper
|
|
606
|
-
* can be read where the wrapper is written.
|
|
607
|
-
*/
|
|
608
|
-
moduleDef(fromFile: string, spec: {
|
|
609
|
-
module: string;
|
|
610
|
-
relativeLevel: number;
|
|
611
|
-
}, name: string): {
|
|
612
|
-
node: Node;
|
|
613
|
-
module: ModuleBinding;
|
|
614
|
-
} | null;
|
|
615
636
|
}
|
|
616
637
|
interface RouterIndexOptions extends ModuleResolverOptions {
|
|
617
638
|
/** The project's facts, so a loop over a call can be settled by the rules. */
|
|
@@ -713,7 +734,6 @@ interface DecoratorClassification {
|
|
|
713
734
|
module: string | null;
|
|
714
735
|
/** The local variable an attribute decorator hangs on, `app` in `@app.get(...)`. */
|
|
715
736
|
objectName: string | null;
|
|
716
|
-
relativeLevel: number;
|
|
717
737
|
args: DecoratorArg[];
|
|
718
738
|
keywordArgs: Record<string, DecoratorArg>;
|
|
719
739
|
/** Where the decorator is written. Anything we read out of its arguments uses this as its provenance. */
|
|
@@ -725,16 +745,16 @@ interface DecoratorClassification {
|
|
|
725
745
|
*/
|
|
726
746
|
objectModule?: ModuleBinding;
|
|
727
747
|
/**
|
|
728
|
-
* The call the rules say built the object this decorator hangs on
|
|
729
|
-
* the
|
|
730
|
-
*
|
|
748
|
+
* The call the rules say built the object this decorator hangs on. A
|
|
749
|
+
* router the index never saw under a name is looked up by this call
|
|
750
|
+
* instead, and a decorator on `self.router` has no name to look up.
|
|
731
751
|
*/
|
|
732
752
|
subjectConstruction?: {
|
|
733
753
|
key: string;
|
|
734
754
|
constructorName: string;
|
|
735
755
|
};
|
|
736
756
|
}
|
|
737
|
-
declare function classifyDecorator(decoratorNode: Node,
|
|
757
|
+
declare function classifyDecorator(decoratorNode: Node, module: ModuleBinding, facts?: Database): DecoratorClassification;
|
|
738
758
|
|
|
739
759
|
/**
|
|
740
760
|
* What discovery uses for one file. `factsPath` is the path the facts were
|
|
@@ -1028,6 +1048,22 @@ interface ExtractPythonResult {
|
|
|
1028
1048
|
summaries: BehavioralSummary[];
|
|
1029
1049
|
facts: Database;
|
|
1030
1050
|
}
|
|
1051
|
+
/** One parsed file and the packs a run over it would load. */
|
|
1052
|
+
interface FileFactsOptions {
|
|
1053
|
+
file: string;
|
|
1054
|
+
root: Node;
|
|
1055
|
+
module: ModuleBinding;
|
|
1056
|
+
packs: readonly PythonPack[];
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* The facts for a single parsed file, with the evaluator bound to them,
|
|
1060
|
+
* for a caller that has one file and no project. A pack's own tests need
|
|
1061
|
+
* these: what built a receiver is an answer the rules give, and without
|
|
1062
|
+
* facts they have nothing to give it from. A project run emits the same
|
|
1063
|
+
* facts across every file at once, so a name written in another file
|
|
1064
|
+
* resolves there and never here.
|
|
1065
|
+
*/
|
|
1066
|
+
declare function factsForFile(options: FileFactsOptions): Database;
|
|
1031
1067
|
declare function extractPythonProject(options: ExtractPythonOptions): Promise<ExtractPythonResult>;
|
|
1032
1068
|
/** Every `.py` file under `root`, depth-first, skipping the usual non-source directories. */
|
|
1033
1069
|
declare function findPythonFiles(root: string): string[];
|
|
@@ -1076,4 +1112,4 @@ declare function pythonImportEvidence(options: PythonImportEvidenceOptions): Pro
|
|
|
1076
1112
|
*/
|
|
1077
1113
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
1078
1114
|
|
|
1079
|
-
export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PyStatusCall, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type StoragePattern, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitEntryFact, emitModuleImportFacts, emitValueFacts, extractPythonProject, findPythonFiles, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, readKey, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, unitKey };
|
|
1115
|
+
export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type FileFactsOptions, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PyStatusCall, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type StoragePattern, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitEntryFact, emitModuleImportFacts, emitValueFacts, extractPythonProject, factsForFile, findPythonFiles, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, readKey, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, unitKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -111,6 +111,8 @@ interface PythonPack {
|
|
|
111
111
|
storage?: StoragePattern[];
|
|
112
112
|
/** Which of the library's calls give back one of a model class. The README says what a chain of them composes into. */
|
|
113
113
|
models?: PyModelQueries[];
|
|
114
|
+
/** Which of the library's classes return themselves from `__enter__`, so a `with` block gets the object itself. */
|
|
115
|
+
contextManagers?: PyContextManager[];
|
|
114
116
|
/** How the library lets a project hand the database SQL it wrote itself. */
|
|
115
117
|
rawSql?: RawSqlPattern[];
|
|
116
118
|
}
|
|
@@ -170,6 +172,20 @@ interface PyModelQueries {
|
|
|
170
172
|
entryMethods: PyModelEntryMethod[];
|
|
171
173
|
/** Functions the library exports that do the same, called on their own rather than read off a session. */
|
|
172
174
|
entryFunctions: PyModelEntryFunction[];
|
|
175
|
+
/** The library's own constructors for a field that reaches another model. */
|
|
176
|
+
relationships?: PyRelationshipConstructor[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* `items: list[Item] = Relationship(...)`: the callable a model's field
|
|
180
|
+
* is given to say it reaches another model, and where it comes from. A
|
|
181
|
+
* project function spelled the same way is somebody else's, so the
|
|
182
|
+
* import is what settles a match.
|
|
183
|
+
*/
|
|
184
|
+
interface PyRelationshipConstructor {
|
|
185
|
+
/** The module it is imported from, `sqlmodel` or `sqlalchemy.orm`. */
|
|
186
|
+
module: string;
|
|
187
|
+
/** Its name, `Relationship` or `relationship`. */
|
|
188
|
+
name: string;
|
|
173
189
|
}
|
|
174
190
|
/** `session.get(User, id)`: the method, and where the class is written. */
|
|
175
191
|
interface PyModelEntryMethod {
|
|
@@ -197,6 +213,18 @@ interface RawSqlPattern {
|
|
|
197
213
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
198
214
|
}
|
|
199
215
|
type PythonDiscoveryPattern = DecoratedClassRoute | DecoratedFunctionRoute;
|
|
216
|
+
/**
|
|
217
|
+
* A class whose `__enter__` gives back the object it was called on, so
|
|
218
|
+
* `with X() as y` makes y the `X()` the block opened. Python
|
|
219
|
+
* lets `__enter__` return anything, so only the library that wrote the
|
|
220
|
+
* class can say this, and a pack declares it for its own classes alone.
|
|
221
|
+
*/
|
|
222
|
+
interface PyContextManager {
|
|
223
|
+
/** The module the classes come from, `httpx`. */
|
|
224
|
+
module: string;
|
|
225
|
+
/** The class names the library documents as returning self. */
|
|
226
|
+
returnsSelf: string[];
|
|
227
|
+
}
|
|
200
228
|
/**
|
|
201
229
|
* The callables a library gives a project for making a request. A
|
|
202
230
|
* function that calls one of them is a client of the boundary that call
|
|
@@ -516,6 +544,11 @@ type Binding = {
|
|
|
516
544
|
module: string;
|
|
517
545
|
relativeLevel: number;
|
|
518
546
|
localName: string;
|
|
547
|
+
/**
|
|
548
|
+
* False for `import a.b.c`, where the name binds the package `a`
|
|
549
|
+
* and a member read off it lands somewhere other than `module`.
|
|
550
|
+
*/
|
|
551
|
+
bindsWholeModule: boolean;
|
|
519
552
|
} | {
|
|
520
553
|
kind: "importFrom";
|
|
521
554
|
module: string;
|
|
@@ -595,23 +628,11 @@ type RoutePrefixResolution = {
|
|
|
595
628
|
interface RouterIndex {
|
|
596
629
|
resolve(pattern: PythonDiscoveryPattern, module: ModuleBinding, objectName: string): RoutePrefixResolution;
|
|
597
630
|
/**
|
|
598
|
-
* The same
|
|
599
|
-
*
|
|
600
|
-
*
|
|
631
|
+
* The same for a decorator whose object has no variable name to look up,
|
|
632
|
+
* such as one written on `self.router`. The rules give the call that
|
|
633
|
+
* built it, and every construction is already keyed by its call.
|
|
601
634
|
*/
|
|
602
635
|
resolveConstruction(pattern: PythonDiscoveryPattern, module: ModuleBinding, constructorName: string, constructionKey: string): RoutePrefixResolution;
|
|
603
|
-
/**
|
|
604
|
-
* The module-level def a name in another module refers to, with that
|
|
605
|
-
* module's own bindings, so a decorator written through a project wrapper
|
|
606
|
-
* can be read where the wrapper is written.
|
|
607
|
-
*/
|
|
608
|
-
moduleDef(fromFile: string, spec: {
|
|
609
|
-
module: string;
|
|
610
|
-
relativeLevel: number;
|
|
611
|
-
}, name: string): {
|
|
612
|
-
node: Node;
|
|
613
|
-
module: ModuleBinding;
|
|
614
|
-
} | null;
|
|
615
636
|
}
|
|
616
637
|
interface RouterIndexOptions extends ModuleResolverOptions {
|
|
617
638
|
/** The project's facts, so a loop over a call can be settled by the rules. */
|
|
@@ -713,7 +734,6 @@ interface DecoratorClassification {
|
|
|
713
734
|
module: string | null;
|
|
714
735
|
/** The local variable an attribute decorator hangs on, `app` in `@app.get(...)`. */
|
|
715
736
|
objectName: string | null;
|
|
716
|
-
relativeLevel: number;
|
|
717
737
|
args: DecoratorArg[];
|
|
718
738
|
keywordArgs: Record<string, DecoratorArg>;
|
|
719
739
|
/** Where the decorator is written. Anything we read out of its arguments uses this as its provenance. */
|
|
@@ -725,16 +745,16 @@ interface DecoratorClassification {
|
|
|
725
745
|
*/
|
|
726
746
|
objectModule?: ModuleBinding;
|
|
727
747
|
/**
|
|
728
|
-
* The call the rules say built the object this decorator hangs on
|
|
729
|
-
* the
|
|
730
|
-
*
|
|
748
|
+
* The call the rules say built the object this decorator hangs on. A
|
|
749
|
+
* router the index never saw under a name is looked up by this call
|
|
750
|
+
* instead, and a decorator on `self.router` has no name to look up.
|
|
731
751
|
*/
|
|
732
752
|
subjectConstruction?: {
|
|
733
753
|
key: string;
|
|
734
754
|
constructorName: string;
|
|
735
755
|
};
|
|
736
756
|
}
|
|
737
|
-
declare function classifyDecorator(decoratorNode: Node,
|
|
757
|
+
declare function classifyDecorator(decoratorNode: Node, module: ModuleBinding, facts?: Database): DecoratorClassification;
|
|
738
758
|
|
|
739
759
|
/**
|
|
740
760
|
* What discovery uses for one file. `factsPath` is the path the facts were
|
|
@@ -1028,6 +1048,22 @@ interface ExtractPythonResult {
|
|
|
1028
1048
|
summaries: BehavioralSummary[];
|
|
1029
1049
|
facts: Database;
|
|
1030
1050
|
}
|
|
1051
|
+
/** One parsed file and the packs a run over it would load. */
|
|
1052
|
+
interface FileFactsOptions {
|
|
1053
|
+
file: string;
|
|
1054
|
+
root: Node;
|
|
1055
|
+
module: ModuleBinding;
|
|
1056
|
+
packs: readonly PythonPack[];
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* The facts for a single parsed file, with the evaluator bound to them,
|
|
1060
|
+
* for a caller that has one file and no project. A pack's own tests need
|
|
1061
|
+
* these: what built a receiver is an answer the rules give, and without
|
|
1062
|
+
* facts they have nothing to give it from. A project run emits the same
|
|
1063
|
+
* facts across every file at once, so a name written in another file
|
|
1064
|
+
* resolves there and never here.
|
|
1065
|
+
*/
|
|
1066
|
+
declare function factsForFile(options: FileFactsOptions): Database;
|
|
1031
1067
|
declare function extractPythonProject(options: ExtractPythonOptions): Promise<ExtractPythonResult>;
|
|
1032
1068
|
/** Every `.py` file under `root`, depth-first, skipping the usual non-source directories. */
|
|
1033
1069
|
declare function findPythonFiles(root: string): string[];
|
|
@@ -1076,4 +1112,4 @@ declare function pythonImportEvidence(options: PythonImportEvidenceOptions): Pro
|
|
|
1076
1112
|
*/
|
|
1077
1113
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
1078
1114
|
|
|
1079
|
-
export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PyStatusCall, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type StoragePattern, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitEntryFact, emitModuleImportFacts, emitValueFacts, extractPythonProject, findPythonFiles, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, readKey, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, unitKey };
|
|
1115
|
+
export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type FileFactsOptions, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PyStatusCall, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type StoragePattern, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitEntryFact, emitModuleImportFacts, emitValueFacts, extractPythonProject, factsForFile, findPythonFiles, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, readKey, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, unitKey };
|