@suss/adapter-ruby 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/dist/index.cjs +1442 -365
- package/dist/index.d.cts +86 -13
- package/dist/index.d.ts +86 -13
- package/dist/index.js +1345 -261
- 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.
|
|
@@ -258,6 +266,8 @@ interface BodyReading {
|
|
|
258
266
|
interface AncestorLookup {
|
|
259
267
|
/** Directory the constant-to-path convention resolves an ancestor's name against. */
|
|
260
268
|
root: string;
|
|
269
|
+
/** Further directories tried after `root`, each as the top of the namespace. */
|
|
270
|
+
autoloadRoots?: readonly string[];
|
|
261
271
|
pathConvention: ConstantPathConvention;
|
|
262
272
|
/** Acronyms the convention keeps as one word, `ActivityPub` to `activitypub`. */
|
|
263
273
|
acronyms?: readonly string[];
|
|
@@ -277,9 +287,10 @@ interface AncestorLookup {
|
|
|
277
287
|
localDefinition?(qualifiedName: string): ReachedBody[] | null;
|
|
278
288
|
}
|
|
279
289
|
/**
|
|
280
|
-
* Every block a file defines under `qualifiedName`, or null when
|
|
281
|
-
* constant-to-path convention points at
|
|
282
|
-
*
|
|
290
|
+
* Every block a file defines under `qualifiedName`, or null when no file
|
|
291
|
+
* the constant-to-path convention points at defines it. A class nested
|
|
292
|
+
* in its namespace's own file, `Order::NotPaid` written inside
|
|
293
|
+
* `order.rb`, is found there, since loading `Order` defines it.
|
|
283
294
|
*/
|
|
284
295
|
declare function reachDefinition(qualifiedName: string, lookup: AncestorLookup): Promise<ReachedBody[] | null>;
|
|
285
296
|
declare function ancestryOf(name: string, blocks: readonly ReachedBody[], lookup: AncestorLookup): Promise<Ancestry>;
|
|
@@ -302,6 +313,8 @@ type MethodLookup =
|
|
|
302
313
|
type: "unsettled";
|
|
303
314
|
reason: string;
|
|
304
315
|
cause: "unreadAncestor" | "dynamicDefine";
|
|
316
|
+
/** True when an ancestor past the unread one defines it in the project. */
|
|
317
|
+
definedLater?: boolean;
|
|
305
318
|
} | {
|
|
306
319
|
type: "none";
|
|
307
320
|
};
|
|
@@ -618,6 +631,8 @@ interface RbClientResponse {
|
|
|
618
631
|
body?: string[];
|
|
619
632
|
/** Whether a refused request comes back as a response or raises where it was made. */
|
|
620
633
|
failureDelivery?: "response" | "exception";
|
|
634
|
+
/** Whether the client follows a redirect itself or hands the 3xx back. */
|
|
635
|
+
redirectDelivery?: "followed" | "response";
|
|
621
636
|
}
|
|
622
637
|
/**
|
|
623
638
|
* Ruby code declares no return types, so a call is matched by what its
|
|
@@ -663,6 +678,11 @@ interface RbStoragePattern {
|
|
|
663
678
|
scopes?: string[];
|
|
664
679
|
/** Which database is behind the connection. The project decides this, so the pack passes it in. */
|
|
665
680
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
681
|
+
/** The exception each of these methods raises when the row is missing or does not save, ActiveRecord's `RecordNotFound` from `find`. */
|
|
682
|
+
raises?: Array<{
|
|
683
|
+
exception: string;
|
|
684
|
+
methods: string[];
|
|
685
|
+
}>;
|
|
666
686
|
}
|
|
667
687
|
/**
|
|
668
688
|
* A library whose calls take SQL the project wrote, instead of building
|
|
@@ -797,12 +817,19 @@ interface RbLoaderSource {
|
|
|
797
817
|
method: string;
|
|
798
818
|
}
|
|
799
819
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
820
|
+
/** One route to a controller action. */
|
|
821
|
+
interface ControllerRoute {
|
|
822
|
+
method: string;
|
|
823
|
+
path: string;
|
|
824
|
+
/** True for a route served with no `.{format}` in a framework that adds one; see `ControllerActions.optionalFormat`. */
|
|
825
|
+
formatless?: true;
|
|
826
|
+
}
|
|
800
827
|
/**
|
|
801
828
|
* A class whose ancestry reaches one of `baseClassNames` or
|
|
802
829
|
* `ancestryRootClassNames` is a controller, and every instance method it
|
|
803
|
-
* defines directly is an action. `
|
|
804
|
-
*
|
|
805
|
-
*
|
|
830
|
+
* defines directly is an action. `routesFor` binds each action to the
|
|
831
|
+
* methods and paths the project's routing gives it, one unit per route.
|
|
832
|
+
* An action with no route is still discovered, with no boundary binding.
|
|
806
833
|
*/
|
|
807
834
|
interface ControllerActions {
|
|
808
835
|
type: "controllerActions";
|
|
@@ -810,6 +837,15 @@ interface ControllerActions {
|
|
|
810
837
|
baseClassNames: string[];
|
|
811
838
|
/** The directory a bare superclass name is looked up under, which depends on the project's layout. */
|
|
812
839
|
root: string;
|
|
840
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
841
|
+
autoloadRoots?: string[];
|
|
842
|
+
/**
|
|
843
|
+
* The library's own exception classes, with the classes each one
|
|
844
|
+
* inherits from, so a handler for a base class counts. `status` is
|
|
845
|
+
* what the library sends when an action raises one and no handler
|
|
846
|
+
* rescues it, Rails' `rescue_responses`.
|
|
847
|
+
*/
|
|
848
|
+
libraryExceptions?: Record<string, LibraryException>;
|
|
813
849
|
pathConvention: ConstantPathConvention;
|
|
814
850
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word: `ActivityPub` becomes `activitypub`. */
|
|
815
851
|
acronyms?: string[];
|
|
@@ -821,6 +857,8 @@ interface ControllerActions {
|
|
|
821
857
|
responseStatusCalls?: RbStatusCall[];
|
|
822
858
|
/** The number for each status name the library accepts in place of a number. For Rails this is Rack's symbol table. */
|
|
823
859
|
statusCodeNames?: Record<string, number>;
|
|
860
|
+
/** The call whose block responds differently for each format the request asks for, Rails' `respond_to`. */
|
|
861
|
+
formatSwitch?: RbFormatSwitch;
|
|
824
862
|
/**
|
|
825
863
|
* Methods every controller inherits from the library, which for Rails
|
|
826
864
|
* are `params`, `render` and the rest of what `ActionController` mixes
|
|
@@ -830,11 +868,17 @@ interface ControllerActions {
|
|
|
830
868
|
inheritedMethodNames?: string[];
|
|
831
869
|
/** Absolute path of the routes file this pattern read, used in the gap `routingGaps` can report. */
|
|
832
870
|
routesFile: string;
|
|
833
|
-
/**
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
871
|
+
/**
|
|
872
|
+
* Every method and path the project's routing gives one controller
|
|
873
|
+
* action, in the order they are declared, or none.
|
|
874
|
+
*/
|
|
875
|
+
routesFor: (controllerQualifiedName: string, actionName: string) => readonly ControllerRoute[];
|
|
876
|
+
/**
|
|
877
|
+
* Whether the framework also serves a route with `.{format}` after its
|
|
878
|
+
* path, as Rails serves `/search.json` from `get "search"`. A route
|
|
879
|
+
* marked `formatless`, and one whose path ends in a slash, get none.
|
|
880
|
+
*/
|
|
881
|
+
optionalFormat?: boolean;
|
|
838
882
|
/** One message for each kind of routing declaration the pattern could not read. Calling it again returns the same list. */
|
|
839
883
|
routingGaps?: () => readonly string[];
|
|
840
884
|
/** The class-level calls that run one of the controller's own methods around its actions, Rails' `before_action` and `rescue_from`. */
|
|
@@ -883,6 +927,33 @@ interface RbStatusCall {
|
|
|
883
927
|
* so a default declared here takes precedence over `defaultStatusCode`.
|
|
884
928
|
*/
|
|
885
929
|
defaultStatusCode?: number;
|
|
930
|
+
/** The keyword whose value the library sends as a JSON body, `json` for Rails' `render json:`. */
|
|
931
|
+
bodyKeyword?: string;
|
|
932
|
+
/**
|
|
933
|
+
* Methods that turn the value they are called on into that same JSON,
|
|
934
|
+
* so `render json: { ok: true }.to_json` sends the hash. Only a call
|
|
935
|
+
* with no arguments counts, since `as_json(only: ...)` drops keys.
|
|
936
|
+
*/
|
|
937
|
+
bodySerializers?: string[];
|
|
938
|
+
}
|
|
939
|
+
/** One of a library's exception classes. */
|
|
940
|
+
interface LibraryException {
|
|
941
|
+
/** Every class it inherits from, nearest first, up to `Exception`. */
|
|
942
|
+
ancestors: string[];
|
|
943
|
+
/** The status the library responds with when nothing rescues it. */
|
|
944
|
+
status?: number;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* A receiverless call whose block responds one way per format the request
|
|
948
|
+
* asks for. Each call on the block's parameter, `format.json { ... }`, is
|
|
949
|
+
* one branch, and the request runs the first one whose format it accepts.
|
|
950
|
+
* When none does, the library raises.
|
|
951
|
+
*/
|
|
952
|
+
interface RbFormatSwitch {
|
|
953
|
+
/** The call's own name, `respond_to` for Rails. */
|
|
954
|
+
name: string;
|
|
955
|
+
/** The format that accepts every request, `any` for Rails. */
|
|
956
|
+
matchesEvery?: string;
|
|
886
957
|
}
|
|
887
958
|
/** A class or module whose ancestry reaches one of `baseClassNames` declares GraphQL fields through DSL calls in its own body. */
|
|
888
959
|
interface GraphqlObjectFields {
|
|
@@ -891,6 +962,8 @@ interface GraphqlObjectFields {
|
|
|
891
962
|
baseClassNames: string[];
|
|
892
963
|
/** The directory a wiring keyword's referenced class is looked up under, which depends on the project's layout. */
|
|
893
964
|
root: string;
|
|
965
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
966
|
+
autoloadRoots?: string[];
|
|
894
967
|
pathConvention: ConstantPathConvention;
|
|
895
968
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word. */
|
|
896
969
|
acronyms?: string[];
|
|
@@ -1435,4 +1508,4 @@ declare function typeShapeFromNode(node: Node, ctx: TypeReadContext): TypeShape
|
|
|
1435
1508
|
*/
|
|
1436
1509
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
1437
1510
|
|
|
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 };
|
|
1511
|
+
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.
|
|
@@ -258,6 +266,8 @@ interface BodyReading {
|
|
|
258
266
|
interface AncestorLookup {
|
|
259
267
|
/** Directory the constant-to-path convention resolves an ancestor's name against. */
|
|
260
268
|
root: string;
|
|
269
|
+
/** Further directories tried after `root`, each as the top of the namespace. */
|
|
270
|
+
autoloadRoots?: readonly string[];
|
|
261
271
|
pathConvention: ConstantPathConvention;
|
|
262
272
|
/** Acronyms the convention keeps as one word, `ActivityPub` to `activitypub`. */
|
|
263
273
|
acronyms?: readonly string[];
|
|
@@ -277,9 +287,10 @@ interface AncestorLookup {
|
|
|
277
287
|
localDefinition?(qualifiedName: string): ReachedBody[] | null;
|
|
278
288
|
}
|
|
279
289
|
/**
|
|
280
|
-
* Every block a file defines under `qualifiedName`, or null when
|
|
281
|
-
* constant-to-path convention points at
|
|
282
|
-
*
|
|
290
|
+
* Every block a file defines under `qualifiedName`, or null when no file
|
|
291
|
+
* the constant-to-path convention points at defines it. A class nested
|
|
292
|
+
* in its namespace's own file, `Order::NotPaid` written inside
|
|
293
|
+
* `order.rb`, is found there, since loading `Order` defines it.
|
|
283
294
|
*/
|
|
284
295
|
declare function reachDefinition(qualifiedName: string, lookup: AncestorLookup): Promise<ReachedBody[] | null>;
|
|
285
296
|
declare function ancestryOf(name: string, blocks: readonly ReachedBody[], lookup: AncestorLookup): Promise<Ancestry>;
|
|
@@ -302,6 +313,8 @@ type MethodLookup =
|
|
|
302
313
|
type: "unsettled";
|
|
303
314
|
reason: string;
|
|
304
315
|
cause: "unreadAncestor" | "dynamicDefine";
|
|
316
|
+
/** True when an ancestor past the unread one defines it in the project. */
|
|
317
|
+
definedLater?: boolean;
|
|
305
318
|
} | {
|
|
306
319
|
type: "none";
|
|
307
320
|
};
|
|
@@ -618,6 +631,8 @@ interface RbClientResponse {
|
|
|
618
631
|
body?: string[];
|
|
619
632
|
/** Whether a refused request comes back as a response or raises where it was made. */
|
|
620
633
|
failureDelivery?: "response" | "exception";
|
|
634
|
+
/** Whether the client follows a redirect itself or hands the 3xx back. */
|
|
635
|
+
redirectDelivery?: "followed" | "response";
|
|
621
636
|
}
|
|
622
637
|
/**
|
|
623
638
|
* Ruby code declares no return types, so a call is matched by what its
|
|
@@ -663,6 +678,11 @@ interface RbStoragePattern {
|
|
|
663
678
|
scopes?: string[];
|
|
664
679
|
/** Which database is behind the connection. The project decides this, so the pack passes it in. */
|
|
665
680
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
681
|
+
/** The exception each of these methods raises when the row is missing or does not save, ActiveRecord's `RecordNotFound` from `find`. */
|
|
682
|
+
raises?: Array<{
|
|
683
|
+
exception: string;
|
|
684
|
+
methods: string[];
|
|
685
|
+
}>;
|
|
666
686
|
}
|
|
667
687
|
/**
|
|
668
688
|
* A library whose calls take SQL the project wrote, instead of building
|
|
@@ -797,12 +817,19 @@ interface RbLoaderSource {
|
|
|
797
817
|
method: string;
|
|
798
818
|
}
|
|
799
819
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
820
|
+
/** One route to a controller action. */
|
|
821
|
+
interface ControllerRoute {
|
|
822
|
+
method: string;
|
|
823
|
+
path: string;
|
|
824
|
+
/** True for a route served with no `.{format}` in a framework that adds one; see `ControllerActions.optionalFormat`. */
|
|
825
|
+
formatless?: true;
|
|
826
|
+
}
|
|
800
827
|
/**
|
|
801
828
|
* A class whose ancestry reaches one of `baseClassNames` or
|
|
802
829
|
* `ancestryRootClassNames` is a controller, and every instance method it
|
|
803
|
-
* defines directly is an action. `
|
|
804
|
-
*
|
|
805
|
-
*
|
|
830
|
+
* defines directly is an action. `routesFor` binds each action to the
|
|
831
|
+
* methods and paths the project's routing gives it, one unit per route.
|
|
832
|
+
* An action with no route is still discovered, with no boundary binding.
|
|
806
833
|
*/
|
|
807
834
|
interface ControllerActions {
|
|
808
835
|
type: "controllerActions";
|
|
@@ -810,6 +837,15 @@ interface ControllerActions {
|
|
|
810
837
|
baseClassNames: string[];
|
|
811
838
|
/** The directory a bare superclass name is looked up under, which depends on the project's layout. */
|
|
812
839
|
root: string;
|
|
840
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
841
|
+
autoloadRoots?: string[];
|
|
842
|
+
/**
|
|
843
|
+
* The library's own exception classes, with the classes each one
|
|
844
|
+
* inherits from, so a handler for a base class counts. `status` is
|
|
845
|
+
* what the library sends when an action raises one and no handler
|
|
846
|
+
* rescues it, Rails' `rescue_responses`.
|
|
847
|
+
*/
|
|
848
|
+
libraryExceptions?: Record<string, LibraryException>;
|
|
813
849
|
pathConvention: ConstantPathConvention;
|
|
814
850
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word: `ActivityPub` becomes `activitypub`. */
|
|
815
851
|
acronyms?: string[];
|
|
@@ -821,6 +857,8 @@ interface ControllerActions {
|
|
|
821
857
|
responseStatusCalls?: RbStatusCall[];
|
|
822
858
|
/** The number for each status name the library accepts in place of a number. For Rails this is Rack's symbol table. */
|
|
823
859
|
statusCodeNames?: Record<string, number>;
|
|
860
|
+
/** The call whose block responds differently for each format the request asks for, Rails' `respond_to`. */
|
|
861
|
+
formatSwitch?: RbFormatSwitch;
|
|
824
862
|
/**
|
|
825
863
|
* Methods every controller inherits from the library, which for Rails
|
|
826
864
|
* are `params`, `render` and the rest of what `ActionController` mixes
|
|
@@ -830,11 +868,17 @@ interface ControllerActions {
|
|
|
830
868
|
inheritedMethodNames?: string[];
|
|
831
869
|
/** Absolute path of the routes file this pattern read, used in the gap `routingGaps` can report. */
|
|
832
870
|
routesFile: string;
|
|
833
|
-
/**
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
871
|
+
/**
|
|
872
|
+
* Every method and path the project's routing gives one controller
|
|
873
|
+
* action, in the order they are declared, or none.
|
|
874
|
+
*/
|
|
875
|
+
routesFor: (controllerQualifiedName: string, actionName: string) => readonly ControllerRoute[];
|
|
876
|
+
/**
|
|
877
|
+
* Whether the framework also serves a route with `.{format}` after its
|
|
878
|
+
* path, as Rails serves `/search.json` from `get "search"`. A route
|
|
879
|
+
* marked `formatless`, and one whose path ends in a slash, get none.
|
|
880
|
+
*/
|
|
881
|
+
optionalFormat?: boolean;
|
|
838
882
|
/** One message for each kind of routing declaration the pattern could not read. Calling it again returns the same list. */
|
|
839
883
|
routingGaps?: () => readonly string[];
|
|
840
884
|
/** The class-level calls that run one of the controller's own methods around its actions, Rails' `before_action` and `rescue_from`. */
|
|
@@ -883,6 +927,33 @@ interface RbStatusCall {
|
|
|
883
927
|
* so a default declared here takes precedence over `defaultStatusCode`.
|
|
884
928
|
*/
|
|
885
929
|
defaultStatusCode?: number;
|
|
930
|
+
/** The keyword whose value the library sends as a JSON body, `json` for Rails' `render json:`. */
|
|
931
|
+
bodyKeyword?: string;
|
|
932
|
+
/**
|
|
933
|
+
* Methods that turn the value they are called on into that same JSON,
|
|
934
|
+
* so `render json: { ok: true }.to_json` sends the hash. Only a call
|
|
935
|
+
* with no arguments counts, since `as_json(only: ...)` drops keys.
|
|
936
|
+
*/
|
|
937
|
+
bodySerializers?: string[];
|
|
938
|
+
}
|
|
939
|
+
/** One of a library's exception classes. */
|
|
940
|
+
interface LibraryException {
|
|
941
|
+
/** Every class it inherits from, nearest first, up to `Exception`. */
|
|
942
|
+
ancestors: string[];
|
|
943
|
+
/** The status the library responds with when nothing rescues it. */
|
|
944
|
+
status?: number;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* A receiverless call whose block responds one way per format the request
|
|
948
|
+
* asks for. Each call on the block's parameter, `format.json { ... }`, is
|
|
949
|
+
* one branch, and the request runs the first one whose format it accepts.
|
|
950
|
+
* When none does, the library raises.
|
|
951
|
+
*/
|
|
952
|
+
interface RbFormatSwitch {
|
|
953
|
+
/** The call's own name, `respond_to` for Rails. */
|
|
954
|
+
name: string;
|
|
955
|
+
/** The format that accepts every request, `any` for Rails. */
|
|
956
|
+
matchesEvery?: string;
|
|
886
957
|
}
|
|
887
958
|
/** A class or module whose ancestry reaches one of `baseClassNames` declares GraphQL fields through DSL calls in its own body. */
|
|
888
959
|
interface GraphqlObjectFields {
|
|
@@ -891,6 +962,8 @@ interface GraphqlObjectFields {
|
|
|
891
962
|
baseClassNames: string[];
|
|
892
963
|
/** The directory a wiring keyword's referenced class is looked up under, which depends on the project's layout. */
|
|
893
964
|
root: string;
|
|
965
|
+
/** Other directories the project autoloads constants from, each read as the top of the namespace, after `root`. */
|
|
966
|
+
autoloadRoots?: string[];
|
|
894
967
|
pathConvention: ConstantPathConvention;
|
|
895
968
|
/** Acronyms the project registers with the inflector. The path convention keeps each one as one word. */
|
|
896
969
|
acronyms?: string[];
|
|
@@ -1435,4 +1508,4 @@ declare function typeShapeFromNode(node: Node, ctx: TypeReadContext): TypeShape
|
|
|
1435
1508
|
*/
|
|
1436
1509
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
1437
1510
|
|
|
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 };
|
|
1511
|
+
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 };
|