@suss/adapter-ruby 0.34.0 → 0.35.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.cjs +1995 -504
- package/dist/index.d.cts +91 -19
- package/dist/index.d.ts +91 -19
- package/dist/index.js +1919 -412
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -40,6 +40,13 @@ interface Range {
|
|
|
40
40
|
end: number;
|
|
41
41
|
}
|
|
42
42
|
declare function field(node: Node, name: string): Node | null;
|
|
43
|
+
/**
|
|
44
|
+
* A node's named children, and nothing for an absent node. Every read of
|
|
45
|
+
* children in this adapter goes through here or `allChildren`, because the
|
|
46
|
+
* library's `namedChildren` and `children` getters keep the array on the
|
|
47
|
+
* node, and the run keeps every root to the end.
|
|
48
|
+
*/
|
|
49
|
+
declare function children(node: Node | null | undefined): Node[];
|
|
43
50
|
declare function bodyStatements(body: Node): Node[];
|
|
44
51
|
/**
|
|
45
52
|
* Every statement written directly inside a branching statement's
|
|
@@ -131,8 +138,9 @@ declare function createConstantFileCache(): ConstantFileCache;
|
|
|
131
138
|
* `app/models/concerns/archivable.rb`. The root is tried first, then the
|
|
132
139
|
* directories under it in name order, then their `concerns` directories
|
|
133
140
|
* in the same order. Rails' own autoload glob lists them in that order.
|
|
141
|
+
* Paths a project adds, such as `lib`, come last.
|
|
134
142
|
*/
|
|
135
|
-
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention, acronyms?: readonly string[], cache?: ConstantFileCache): string | null;
|
|
143
|
+
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention, acronyms?: readonly string[], cache?: ConstantFileCache, autoloadRoots?: readonly string[]): string | null;
|
|
136
144
|
|
|
137
145
|
/**
|
|
138
146
|
* The methods a class defines under a name the source computes.
|
|
@@ -142,11 +150,10 @@ declare function resolveConstantFile(root: string, qualifiedName: string, conven
|
|
|
142
150
|
* Knowing the names lets a lookup for any other name continue up the
|
|
143
151
|
* ancestry instead of stopping at the class.
|
|
144
152
|
*
|
|
145
|
-
* The calls
|
|
146
|
-
*
|
|
147
|
-
* name
|
|
148
|
-
*
|
|
149
|
-
* becomes a pattern the whole name has to match.
|
|
153
|
+
* The calls come in as `definesMethodFrom` facts, and the loops around
|
|
154
|
+
* them as `elementOf` and `positionOf`. The shared value evaluator reads
|
|
155
|
+
* each name once for each element of each loop. A name that settles
|
|
156
|
+
* only in part becomes a pattern the whole name has to match.
|
|
150
157
|
*/
|
|
151
158
|
|
|
152
159
|
/** What the dynamic definitions in one class define. */
|
|
@@ -258,6 +265,8 @@ interface BodyReading {
|
|
|
258
265
|
interface AncestorLookup {
|
|
259
266
|
/** Directory the constant-to-path convention resolves an ancestor's name against. */
|
|
260
267
|
root: string;
|
|
268
|
+
/** Further directories tried after `root`, each as the top of the namespace. */
|
|
269
|
+
autoloadRoots?: readonly string[];
|
|
261
270
|
pathConvention: ConstantPathConvention;
|
|
262
271
|
/** Acronyms the convention keeps as one word, `ActivityPub` to `activitypub`. */
|
|
263
272
|
acronyms?: readonly string[];
|
|
@@ -277,9 +286,10 @@ interface AncestorLookup {
|
|
|
277
286
|
localDefinition?(qualifiedName: string): ReachedBody[] | null;
|
|
278
287
|
}
|
|
279
288
|
/**
|
|
280
|
-
* Every block a file defines under `qualifiedName`, or null when
|
|
281
|
-
* constant-to-path convention points at
|
|
282
|
-
*
|
|
289
|
+
* Every block a file defines under `qualifiedName`, or null when no file
|
|
290
|
+
* the constant-to-path convention points at defines it. A class nested
|
|
291
|
+
* in its namespace's own file, `Order::NotPaid` written inside
|
|
292
|
+
* `order.rb`, is found there, since loading `Order` defines it.
|
|
283
293
|
*/
|
|
284
294
|
declare function reachDefinition(qualifiedName: string, lookup: AncestorLookup): Promise<ReachedBody[] | null>;
|
|
285
295
|
declare function ancestryOf(name: string, blocks: readonly ReachedBody[], lookup: AncestorLookup): Promise<Ancestry>;
|
|
@@ -302,6 +312,8 @@ type MethodLookup =
|
|
|
302
312
|
type: "unsettled";
|
|
303
313
|
reason: string;
|
|
304
314
|
cause: "unreadAncestor" | "dynamicDefine";
|
|
315
|
+
/** True when an ancestor past the unread one defines it in the project. */
|
|
316
|
+
definedLater?: boolean;
|
|
305
317
|
} | {
|
|
306
318
|
type: "none";
|
|
307
319
|
};
|
|
@@ -618,6 +630,8 @@ interface RbClientResponse {
|
|
|
618
630
|
body?: string[];
|
|
619
631
|
/** Whether a refused request comes back as a response or raises where it was made. */
|
|
620
632
|
failureDelivery?: "response" | "exception";
|
|
633
|
+
/** Whether the client follows a redirect itself or hands the 3xx back. */
|
|
634
|
+
redirectDelivery?: "followed" | "response";
|
|
621
635
|
}
|
|
622
636
|
/**
|
|
623
637
|
* Ruby code declares no return types, so a call is matched by what its
|
|
@@ -663,6 +677,11 @@ interface RbStoragePattern {
|
|
|
663
677
|
scopes?: string[];
|
|
664
678
|
/** Which database is behind the connection. The project decides this, so the pack passes it in. */
|
|
665
679
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
680
|
+
/** The exception each of these methods raises when the row is missing or does not save, ActiveRecord's `RecordNotFound` from `find`. */
|
|
681
|
+
raises?: Array<{
|
|
682
|
+
exception: string;
|
|
683
|
+
methods: string[];
|
|
684
|
+
}>;
|
|
666
685
|
}
|
|
667
686
|
/**
|
|
668
687
|
* A library whose calls take SQL the project wrote, instead of building
|
|
@@ -797,12 +816,19 @@ interface RbLoaderSource {
|
|
|
797
816
|
method: string;
|
|
798
817
|
}
|
|
799
818
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
819
|
+
/** One route to a controller action. */
|
|
820
|
+
interface ControllerRoute {
|
|
821
|
+
method: string;
|
|
822
|
+
path: string;
|
|
823
|
+
/** True for a route served with no `.{format}` in a framework that adds one; see `ControllerActions.optionalFormat`. */
|
|
824
|
+
formatless?: true;
|
|
825
|
+
}
|
|
800
826
|
/**
|
|
801
827
|
* A class whose ancestry reaches one of `baseClassNames` or
|
|
802
828
|
* `ancestryRootClassNames` is a controller, and every instance method it
|
|
803
|
-
* defines directly is an action. `
|
|
804
|
-
*
|
|
805
|
-
*
|
|
829
|
+
* defines directly is an action. `routesFor` binds each action to the
|
|
830
|
+
* methods and paths the project's routing gives it, one unit per route.
|
|
831
|
+
* An action with no route is still discovered, with no boundary binding.
|
|
806
832
|
*/
|
|
807
833
|
interface ControllerActions {
|
|
808
834
|
type: "controllerActions";
|
|
@@ -810,6 +836,15 @@ interface ControllerActions {
|
|
|
810
836
|
baseClassNames: string[];
|
|
811
837
|
/** The directory a bare superclass name is looked up under, which depends on the project's layout. */
|
|
812
838
|
root: string;
|
|
839
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
840
|
+
autoloadRoots?: string[];
|
|
841
|
+
/**
|
|
842
|
+
* The library's own exception classes, with the classes each one
|
|
843
|
+
* inherits from, so a handler for a base class counts. `status` is
|
|
844
|
+
* what the library sends when an action raises one and no handler
|
|
845
|
+
* rescues it, Rails' `rescue_responses`.
|
|
846
|
+
*/
|
|
847
|
+
libraryExceptions?: Record<string, LibraryException>;
|
|
813
848
|
pathConvention: ConstantPathConvention;
|
|
814
849
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word: `ActivityPub` becomes `activitypub`. */
|
|
815
850
|
acronyms?: string[];
|
|
@@ -821,6 +856,8 @@ interface ControllerActions {
|
|
|
821
856
|
responseStatusCalls?: RbStatusCall[];
|
|
822
857
|
/** The number for each status name the library accepts in place of a number. For Rails this is Rack's symbol table. */
|
|
823
858
|
statusCodeNames?: Record<string, number>;
|
|
859
|
+
/** The call whose block responds differently for each format the request asks for, Rails' `respond_to`. */
|
|
860
|
+
formatSwitch?: RbFormatSwitch;
|
|
824
861
|
/**
|
|
825
862
|
* Methods every controller inherits from the library, which for Rails
|
|
826
863
|
* are `params`, `render` and the rest of what `ActionController` mixes
|
|
@@ -830,11 +867,17 @@ interface ControllerActions {
|
|
|
830
867
|
inheritedMethodNames?: string[];
|
|
831
868
|
/** Absolute path of the routes file this pattern read, used in the gap `routingGaps` can report. */
|
|
832
869
|
routesFile: string;
|
|
833
|
-
/**
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
870
|
+
/**
|
|
871
|
+
* Every method and path the project's routing gives one controller
|
|
872
|
+
* action, in the order they are declared, or none.
|
|
873
|
+
*/
|
|
874
|
+
routesFor: (controllerQualifiedName: string, actionName: string) => readonly ControllerRoute[];
|
|
875
|
+
/**
|
|
876
|
+
* Whether the framework also serves a route with `.{format}` after its
|
|
877
|
+
* path, as Rails serves `/search.json` from `get "search"`. A route
|
|
878
|
+
* marked `formatless`, and one whose path ends in a slash, get none.
|
|
879
|
+
*/
|
|
880
|
+
optionalFormat?: boolean;
|
|
838
881
|
/** One message for each kind of routing declaration the pattern could not read. Calling it again returns the same list. */
|
|
839
882
|
routingGaps?: () => readonly string[];
|
|
840
883
|
/** The class-level calls that run one of the controller's own methods around its actions, Rails' `before_action` and `rescue_from`. */
|
|
@@ -883,6 +926,33 @@ interface RbStatusCall {
|
|
|
883
926
|
* so a default declared here takes precedence over `defaultStatusCode`.
|
|
884
927
|
*/
|
|
885
928
|
defaultStatusCode?: number;
|
|
929
|
+
/** The keyword whose value the library sends as a JSON body, `json` for Rails' `render json:`. */
|
|
930
|
+
bodyKeyword?: string;
|
|
931
|
+
/**
|
|
932
|
+
* Methods that turn the value they are called on into that same JSON,
|
|
933
|
+
* so `render json: { ok: true }.to_json` sends the hash. Only a call
|
|
934
|
+
* with no arguments counts, since `as_json(only: ...)` drops keys.
|
|
935
|
+
*/
|
|
936
|
+
bodySerializers?: string[];
|
|
937
|
+
}
|
|
938
|
+
/** One of a library's exception classes. */
|
|
939
|
+
interface LibraryException {
|
|
940
|
+
/** Every class it inherits from, nearest first, up to `Exception`. */
|
|
941
|
+
ancestors: string[];
|
|
942
|
+
/** The status the library responds with when nothing rescues it. */
|
|
943
|
+
status?: number;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* A receiverless call whose block responds one way per format the request
|
|
947
|
+
* asks for. Each call on the block's parameter, `format.json { ... }`, is
|
|
948
|
+
* one branch, and the request runs the first one whose format it accepts.
|
|
949
|
+
* When none does, the library raises.
|
|
950
|
+
*/
|
|
951
|
+
interface RbFormatSwitch {
|
|
952
|
+
/** The call's own name, `respond_to` for Rails. */
|
|
953
|
+
name: string;
|
|
954
|
+
/** The format that accepts every request, `any` for Rails. */
|
|
955
|
+
matchesEvery?: string;
|
|
886
956
|
}
|
|
887
957
|
/** A class or module whose ancestry reaches one of `baseClassNames` declares GraphQL fields through DSL calls in its own body. */
|
|
888
958
|
interface GraphqlObjectFields {
|
|
@@ -891,6 +961,8 @@ interface GraphqlObjectFields {
|
|
|
891
961
|
baseClassNames: string[];
|
|
892
962
|
/** The directory a wiring keyword's referenced class is looked up under, which depends on the project's layout. */
|
|
893
963
|
root: string;
|
|
964
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
965
|
+
autoloadRoots?: string[];
|
|
894
966
|
pathConvention: ConstantPathConvention;
|
|
895
967
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word. */
|
|
896
968
|
acronyms?: string[];
|
|
@@ -1328,7 +1400,7 @@ interface ExtractRubyOptions {
|
|
|
1328
1400
|
onExtractionReport?: (report: ExtractionReport) => void;
|
|
1329
1401
|
/** Called once with what the cache decided, for `suss extract --timing`. */
|
|
1330
1402
|
onCacheDiagnostic?: (diagnostic: CacheDiagnostic) => void;
|
|
1331
|
-
/** Absolute. `<projectRoot>/.suss/cache` by default
|
|
1403
|
+
/** Absolute. `<projectRoot>/.suss/cache` by default, or under `SUSS_CACHE_DIR`; `null` turns it off. */
|
|
1332
1404
|
cacheDir?: string | null;
|
|
1333
1405
|
/** How to handle gaps. Composing a controller's filters into its actions can add one. */
|
|
1334
1406
|
gapHandling?: ExtractorOptions["gapHandling"];
|
|
@@ -1435,4 +1507,4 @@ declare function typeShapeFromNode(node: Node, ctx: TypeReadContext): TypeShape
|
|
|
1435
1507
|
*/
|
|
1436
1508
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
1437
1509
|
|
|
1438
|
-
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantFileCache, type ConstantPathConvention, type ControllerActions, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type KeptRubyParses, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbAddressingCall, type RbArgumentPlace, type RbBodyBlock, type RbExpectations, type RbFactories, type RbFactoryBuilder, type RbInflections, type RbPredicateMatcher, type RbRawSqlPattern, type RbRowCall, type RbSharedInclude, type RbStatusCall, type RbStorageOptions, type RbStoragePattern, type RbTestCases, type RbTestClasses, type RbTestMocks, type ReachedBody, type RubyDiscoveryPattern, type RubyExtendsSite, type RubyPack, type RubyRequireSite, type RubyStubEvidence, type RubyStubEvidenceOptions, type RubyValueHandle, RubyWhySession, type RubyWhySessionOptions, type TypeReadContext, ancestryOf, bindEvaluator, bodyStatements, booleanLiteralValue, collectFileConstants, createConstantFileCache, createFileCache, discoverUnits, emitConstantBindings, emitValueFacts, evaluatedValue, extractRubyProject, factsForFile, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, keptRubyParses, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubyAhead, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, storageClaims, storageEffects, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, walkClasses, walkDefinitions };
|
|
1510
|
+
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantFileCache, type ConstantPathConvention, type ControllerActions, type ControllerRoute, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type KeptRubyParses, type LibraryException, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbAddressingCall, type RbArgumentPlace, type RbBodyBlock, type RbExpectations, type RbFactories, type RbFactoryBuilder, type RbFormatSwitch, type RbInflections, type RbPredicateMatcher, type RbRawSqlPattern, type RbRowCall, type RbSharedInclude, type RbStatusCall, type RbStorageOptions, type RbStoragePattern, type RbTestCases, type RbTestClasses, type RbTestMocks, type ReachedBody, type RubyDiscoveryPattern, type RubyExtendsSite, type RubyPack, type RubyRequireSite, type RubyStubEvidence, type RubyStubEvidenceOptions, type RubyValueHandle, RubyWhySession, type RubyWhySessionOptions, type TypeReadContext, ancestryOf, bindEvaluator, bodyStatements, booleanLiteralValue, children, collectFileConstants, createConstantFileCache, createFileCache, discoverUnits, emitConstantBindings, emitValueFacts, evaluatedValue, extractRubyProject, factsForFile, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, keptRubyParses, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubyAhead, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, storageClaims, storageEffects, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, walkClasses, walkDefinitions };
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,13 @@ interface Range {
|
|
|
40
40
|
end: number;
|
|
41
41
|
}
|
|
42
42
|
declare function field(node: Node, name: string): Node | null;
|
|
43
|
+
/**
|
|
44
|
+
* A node's named children, and nothing for an absent node. Every read of
|
|
45
|
+
* children in this adapter goes through here or `allChildren`, because the
|
|
46
|
+
* library's `namedChildren` and `children` getters keep the array on the
|
|
47
|
+
* node, and the run keeps every root to the end.
|
|
48
|
+
*/
|
|
49
|
+
declare function children(node: Node | null | undefined): Node[];
|
|
43
50
|
declare function bodyStatements(body: Node): Node[];
|
|
44
51
|
/**
|
|
45
52
|
* Every statement written directly inside a branching statement's
|
|
@@ -131,8 +138,9 @@ declare function createConstantFileCache(): ConstantFileCache;
|
|
|
131
138
|
* `app/models/concerns/archivable.rb`. The root is tried first, then the
|
|
132
139
|
* directories under it in name order, then their `concerns` directories
|
|
133
140
|
* in the same order. Rails' own autoload glob lists them in that order.
|
|
141
|
+
* Paths a project adds, such as `lib`, come last.
|
|
134
142
|
*/
|
|
135
|
-
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention, acronyms?: readonly string[], cache?: ConstantFileCache): string | null;
|
|
143
|
+
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention, acronyms?: readonly string[], cache?: ConstantFileCache, autoloadRoots?: readonly string[]): string | null;
|
|
136
144
|
|
|
137
145
|
/**
|
|
138
146
|
* The methods a class defines under a name the source computes.
|
|
@@ -142,11 +150,10 @@ declare function resolveConstantFile(root: string, qualifiedName: string, conven
|
|
|
142
150
|
* Knowing the names lets a lookup for any other name continue up the
|
|
143
151
|
* ancestry instead of stopping at the class.
|
|
144
152
|
*
|
|
145
|
-
* The calls
|
|
146
|
-
*
|
|
147
|
-
* name
|
|
148
|
-
*
|
|
149
|
-
* becomes a pattern the whole name has to match.
|
|
153
|
+
* The calls come in as `definesMethodFrom` facts, and the loops around
|
|
154
|
+
* them as `elementOf` and `positionOf`. The shared value evaluator reads
|
|
155
|
+
* each name once for each element of each loop. A name that settles
|
|
156
|
+
* only in part becomes a pattern the whole name has to match.
|
|
150
157
|
*/
|
|
151
158
|
|
|
152
159
|
/** What the dynamic definitions in one class define. */
|
|
@@ -258,6 +265,8 @@ interface BodyReading {
|
|
|
258
265
|
interface AncestorLookup {
|
|
259
266
|
/** Directory the constant-to-path convention resolves an ancestor's name against. */
|
|
260
267
|
root: string;
|
|
268
|
+
/** Further directories tried after `root`, each as the top of the namespace. */
|
|
269
|
+
autoloadRoots?: readonly string[];
|
|
261
270
|
pathConvention: ConstantPathConvention;
|
|
262
271
|
/** Acronyms the convention keeps as one word, `ActivityPub` to `activitypub`. */
|
|
263
272
|
acronyms?: readonly string[];
|
|
@@ -277,9 +286,10 @@ interface AncestorLookup {
|
|
|
277
286
|
localDefinition?(qualifiedName: string): ReachedBody[] | null;
|
|
278
287
|
}
|
|
279
288
|
/**
|
|
280
|
-
* Every block a file defines under `qualifiedName`, or null when
|
|
281
|
-
* constant-to-path convention points at
|
|
282
|
-
*
|
|
289
|
+
* Every block a file defines under `qualifiedName`, or null when no file
|
|
290
|
+
* the constant-to-path convention points at defines it. A class nested
|
|
291
|
+
* in its namespace's own file, `Order::NotPaid` written inside
|
|
292
|
+
* `order.rb`, is found there, since loading `Order` defines it.
|
|
283
293
|
*/
|
|
284
294
|
declare function reachDefinition(qualifiedName: string, lookup: AncestorLookup): Promise<ReachedBody[] | null>;
|
|
285
295
|
declare function ancestryOf(name: string, blocks: readonly ReachedBody[], lookup: AncestorLookup): Promise<Ancestry>;
|
|
@@ -302,6 +312,8 @@ type MethodLookup =
|
|
|
302
312
|
type: "unsettled";
|
|
303
313
|
reason: string;
|
|
304
314
|
cause: "unreadAncestor" | "dynamicDefine";
|
|
315
|
+
/** True when an ancestor past the unread one defines it in the project. */
|
|
316
|
+
definedLater?: boolean;
|
|
305
317
|
} | {
|
|
306
318
|
type: "none";
|
|
307
319
|
};
|
|
@@ -618,6 +630,8 @@ interface RbClientResponse {
|
|
|
618
630
|
body?: string[];
|
|
619
631
|
/** Whether a refused request comes back as a response or raises where it was made. */
|
|
620
632
|
failureDelivery?: "response" | "exception";
|
|
633
|
+
/** Whether the client follows a redirect itself or hands the 3xx back. */
|
|
634
|
+
redirectDelivery?: "followed" | "response";
|
|
621
635
|
}
|
|
622
636
|
/**
|
|
623
637
|
* Ruby code declares no return types, so a call is matched by what its
|
|
@@ -663,6 +677,11 @@ interface RbStoragePattern {
|
|
|
663
677
|
scopes?: string[];
|
|
664
678
|
/** Which database is behind the connection. The project decides this, so the pack passes it in. */
|
|
665
679
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
680
|
+
/** The exception each of these methods raises when the row is missing or does not save, ActiveRecord's `RecordNotFound` from `find`. */
|
|
681
|
+
raises?: Array<{
|
|
682
|
+
exception: string;
|
|
683
|
+
methods: string[];
|
|
684
|
+
}>;
|
|
666
685
|
}
|
|
667
686
|
/**
|
|
668
687
|
* A library whose calls take SQL the project wrote, instead of building
|
|
@@ -797,12 +816,19 @@ interface RbLoaderSource {
|
|
|
797
816
|
method: string;
|
|
798
817
|
}
|
|
799
818
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
819
|
+
/** One route to a controller action. */
|
|
820
|
+
interface ControllerRoute {
|
|
821
|
+
method: string;
|
|
822
|
+
path: string;
|
|
823
|
+
/** True for a route served with no `.{format}` in a framework that adds one; see `ControllerActions.optionalFormat`. */
|
|
824
|
+
formatless?: true;
|
|
825
|
+
}
|
|
800
826
|
/**
|
|
801
827
|
* A class whose ancestry reaches one of `baseClassNames` or
|
|
802
828
|
* `ancestryRootClassNames` is a controller, and every instance method it
|
|
803
|
-
* defines directly is an action. `
|
|
804
|
-
*
|
|
805
|
-
*
|
|
829
|
+
* defines directly is an action. `routesFor` binds each action to the
|
|
830
|
+
* methods and paths the project's routing gives it, one unit per route.
|
|
831
|
+
* An action with no route is still discovered, with no boundary binding.
|
|
806
832
|
*/
|
|
807
833
|
interface ControllerActions {
|
|
808
834
|
type: "controllerActions";
|
|
@@ -810,6 +836,15 @@ interface ControllerActions {
|
|
|
810
836
|
baseClassNames: string[];
|
|
811
837
|
/** The directory a bare superclass name is looked up under, which depends on the project's layout. */
|
|
812
838
|
root: string;
|
|
839
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
840
|
+
autoloadRoots?: string[];
|
|
841
|
+
/**
|
|
842
|
+
* The library's own exception classes, with the classes each one
|
|
843
|
+
* inherits from, so a handler for a base class counts. `status` is
|
|
844
|
+
* what the library sends when an action raises one and no handler
|
|
845
|
+
* rescues it, Rails' `rescue_responses`.
|
|
846
|
+
*/
|
|
847
|
+
libraryExceptions?: Record<string, LibraryException>;
|
|
813
848
|
pathConvention: ConstantPathConvention;
|
|
814
849
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word: `ActivityPub` becomes `activitypub`. */
|
|
815
850
|
acronyms?: string[];
|
|
@@ -821,6 +856,8 @@ interface ControllerActions {
|
|
|
821
856
|
responseStatusCalls?: RbStatusCall[];
|
|
822
857
|
/** The number for each status name the library accepts in place of a number. For Rails this is Rack's symbol table. */
|
|
823
858
|
statusCodeNames?: Record<string, number>;
|
|
859
|
+
/** The call whose block responds differently for each format the request asks for, Rails' `respond_to`. */
|
|
860
|
+
formatSwitch?: RbFormatSwitch;
|
|
824
861
|
/**
|
|
825
862
|
* Methods every controller inherits from the library, which for Rails
|
|
826
863
|
* are `params`, `render` and the rest of what `ActionController` mixes
|
|
@@ -830,11 +867,17 @@ interface ControllerActions {
|
|
|
830
867
|
inheritedMethodNames?: string[];
|
|
831
868
|
/** Absolute path of the routes file this pattern read, used in the gap `routingGaps` can report. */
|
|
832
869
|
routesFile: string;
|
|
833
|
-
/**
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
870
|
+
/**
|
|
871
|
+
* Every method and path the project's routing gives one controller
|
|
872
|
+
* action, in the order they are declared, or none.
|
|
873
|
+
*/
|
|
874
|
+
routesFor: (controllerQualifiedName: string, actionName: string) => readonly ControllerRoute[];
|
|
875
|
+
/**
|
|
876
|
+
* Whether the framework also serves a route with `.{format}` after its
|
|
877
|
+
* path, as Rails serves `/search.json` from `get "search"`. A route
|
|
878
|
+
* marked `formatless`, and one whose path ends in a slash, get none.
|
|
879
|
+
*/
|
|
880
|
+
optionalFormat?: boolean;
|
|
838
881
|
/** One message for each kind of routing declaration the pattern could not read. Calling it again returns the same list. */
|
|
839
882
|
routingGaps?: () => readonly string[];
|
|
840
883
|
/** The class-level calls that run one of the controller's own methods around its actions, Rails' `before_action` and `rescue_from`. */
|
|
@@ -883,6 +926,33 @@ interface RbStatusCall {
|
|
|
883
926
|
* so a default declared here takes precedence over `defaultStatusCode`.
|
|
884
927
|
*/
|
|
885
928
|
defaultStatusCode?: number;
|
|
929
|
+
/** The keyword whose value the library sends as a JSON body, `json` for Rails' `render json:`. */
|
|
930
|
+
bodyKeyword?: string;
|
|
931
|
+
/**
|
|
932
|
+
* Methods that turn the value they are called on into that same JSON,
|
|
933
|
+
* so `render json: { ok: true }.to_json` sends the hash. Only a call
|
|
934
|
+
* with no arguments counts, since `as_json(only: ...)` drops keys.
|
|
935
|
+
*/
|
|
936
|
+
bodySerializers?: string[];
|
|
937
|
+
}
|
|
938
|
+
/** One of a library's exception classes. */
|
|
939
|
+
interface LibraryException {
|
|
940
|
+
/** Every class it inherits from, nearest first, up to `Exception`. */
|
|
941
|
+
ancestors: string[];
|
|
942
|
+
/** The status the library responds with when nothing rescues it. */
|
|
943
|
+
status?: number;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* A receiverless call whose block responds one way per format the request
|
|
947
|
+
* asks for. Each call on the block's parameter, `format.json { ... }`, is
|
|
948
|
+
* one branch, and the request runs the first one whose format it accepts.
|
|
949
|
+
* When none does, the library raises.
|
|
950
|
+
*/
|
|
951
|
+
interface RbFormatSwitch {
|
|
952
|
+
/** The call's own name, `respond_to` for Rails. */
|
|
953
|
+
name: string;
|
|
954
|
+
/** The format that accepts every request, `any` for Rails. */
|
|
955
|
+
matchesEvery?: string;
|
|
886
956
|
}
|
|
887
957
|
/** A class or module whose ancestry reaches one of `baseClassNames` declares GraphQL fields through DSL calls in its own body. */
|
|
888
958
|
interface GraphqlObjectFields {
|
|
@@ -891,6 +961,8 @@ interface GraphqlObjectFields {
|
|
|
891
961
|
baseClassNames: string[];
|
|
892
962
|
/** The directory a wiring keyword's referenced class is looked up under, which depends on the project's layout. */
|
|
893
963
|
root: string;
|
|
964
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
965
|
+
autoloadRoots?: string[];
|
|
894
966
|
pathConvention: ConstantPathConvention;
|
|
895
967
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word. */
|
|
896
968
|
acronyms?: string[];
|
|
@@ -1328,7 +1400,7 @@ interface ExtractRubyOptions {
|
|
|
1328
1400
|
onExtractionReport?: (report: ExtractionReport) => void;
|
|
1329
1401
|
/** Called once with what the cache decided, for `suss extract --timing`. */
|
|
1330
1402
|
onCacheDiagnostic?: (diagnostic: CacheDiagnostic) => void;
|
|
1331
|
-
/** Absolute. `<projectRoot>/.suss/cache` by default
|
|
1403
|
+
/** Absolute. `<projectRoot>/.suss/cache` by default, or under `SUSS_CACHE_DIR`; `null` turns it off. */
|
|
1332
1404
|
cacheDir?: string | null;
|
|
1333
1405
|
/** How to handle gaps. Composing a controller's filters into its actions can add one. */
|
|
1334
1406
|
gapHandling?: ExtractorOptions["gapHandling"];
|
|
@@ -1435,4 +1507,4 @@ declare function typeShapeFromNode(node: Node, ctx: TypeReadContext): TypeShape
|
|
|
1435
1507
|
*/
|
|
1436
1508
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
1437
1509
|
|
|
1438
|
-
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantFileCache, type ConstantPathConvention, type ControllerActions, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type KeptRubyParses, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbAddressingCall, type RbArgumentPlace, type RbBodyBlock, type RbExpectations, type RbFactories, type RbFactoryBuilder, type RbInflections, type RbPredicateMatcher, type RbRawSqlPattern, type RbRowCall, type RbSharedInclude, type RbStatusCall, type RbStorageOptions, type RbStoragePattern, type RbTestCases, type RbTestClasses, type RbTestMocks, type ReachedBody, type RubyDiscoveryPattern, type RubyExtendsSite, type RubyPack, type RubyRequireSite, type RubyStubEvidence, type RubyStubEvidenceOptions, type RubyValueHandle, RubyWhySession, type RubyWhySessionOptions, type TypeReadContext, ancestryOf, bindEvaluator, bodyStatements, booleanLiteralValue, collectFileConstants, createConstantFileCache, createFileCache, discoverUnits, emitConstantBindings, emitValueFacts, evaluatedValue, extractRubyProject, factsForFile, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, keptRubyParses, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubyAhead, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, storageClaims, storageEffects, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, walkClasses, walkDefinitions };
|
|
1510
|
+
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantFileCache, type ConstantPathConvention, type ControllerActions, type ControllerRoute, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type KeptRubyParses, type LibraryException, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbAddressingCall, type RbArgumentPlace, type RbBodyBlock, type RbExpectations, type RbFactories, type RbFactoryBuilder, type RbFormatSwitch, type RbInflections, type RbPredicateMatcher, type RbRawSqlPattern, type RbRowCall, type RbSharedInclude, type RbStatusCall, type RbStorageOptions, type RbStoragePattern, type RbTestCases, type RbTestClasses, type RbTestMocks, type ReachedBody, type RubyDiscoveryPattern, type RubyExtendsSite, type RubyPack, type RubyRequireSite, type RubyStubEvidence, type RubyStubEvidenceOptions, type RubyValueHandle, RubyWhySession, type RubyWhySessionOptions, type TypeReadContext, ancestryOf, bindEvaluator, bodyStatements, booleanLiteralValue, children, collectFileConstants, createConstantFileCache, createFileCache, discoverUnits, emitConstantBindings, emitValueFacts, evaluatedValue, extractRubyProject, factsForFile, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, keptRubyParses, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubyAhead, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, storageClaims, storageEffects, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, walkClasses, walkDefinitions };
|