@suss/adapter-ruby 0.25.0 → 0.27.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 +305 -112
- package/dist/index.d.cts +75 -16
- package/dist/index.d.ts +75 -16
- package/dist/index.js +305 -113
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -31,6 +31,13 @@ interface Range {
|
|
|
31
31
|
}
|
|
32
32
|
declare function field(node: Node, name: string): Node | null;
|
|
33
33
|
declare function bodyStatements(body: Node): Node[];
|
|
34
|
+
/**
|
|
35
|
+
* Every statement written directly inside a branching statement's
|
|
36
|
+
* branches, across its `elsif`, `else`, `when`, `rescue` and `ensure`
|
|
37
|
+
* clauses. A statement inside a nested branching statement is not
|
|
38
|
+
* included; the caller descends into that one itself.
|
|
39
|
+
*/
|
|
40
|
+
declare function nestedStatements(stmt: Node): Node[];
|
|
34
41
|
/** A call whose block is the thing being configured rather than a place statements run. */
|
|
35
42
|
type BlockConfigures = (call: Node) => boolean;
|
|
36
43
|
/**
|
|
@@ -68,8 +75,14 @@ declare function readCallArgs(argumentList: Node | null): CallArgs;
|
|
|
68
75
|
*/
|
|
69
76
|
/** A pack picks a convention by name, and the code for each one lives here. */
|
|
70
77
|
type ConstantPathConvention = "railsUnderscore";
|
|
71
|
-
/**
|
|
72
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Ported from ActiveSupport's own `String#underscore`, which is what
|
|
80
|
+
* Rails autoloading runs a constant path through. An acronym the
|
|
81
|
+
* project registers with the inflector is one word to it, so with
|
|
82
|
+
* `ActivityPub` registered the path is `activitypub`, not
|
|
83
|
+
* `activity_pub`.
|
|
84
|
+
*/
|
|
85
|
+
declare function underscoreConstantPath(qualifiedName: string, acronyms?: readonly string[]): string;
|
|
73
86
|
/**
|
|
74
87
|
* Null when there is no file at that path. Rails autoloads from every
|
|
75
88
|
* directory directly under `app`, so `ApplicationController` is
|
|
@@ -77,14 +90,14 @@ declare function underscoreConstantPath(qualifiedName: string): string;
|
|
|
77
90
|
* `app/application_controller.rb`; those directories are tried after
|
|
78
91
|
* the root itself, in name order, and no other spelling is tried.
|
|
79
92
|
*/
|
|
80
|
-
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention): string | null;
|
|
93
|
+
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention, acronyms?: readonly string[]): string | null;
|
|
81
94
|
|
|
82
95
|
/**
|
|
83
96
|
* Resolves Ruby constant paths against lexical nesting.
|
|
84
97
|
*
|
|
85
|
-
* A compound path
|
|
86
|
-
*
|
|
87
|
-
*
|
|
98
|
+
* A compound path referenced, like `Data::Record`, is read as absolute. A
|
|
99
|
+
* bare name is relative to the nesting it is written inside, and so is a
|
|
100
|
+
* compound name `class` or `module` opens. `require` is never resolved,
|
|
88
101
|
* because Rails autoloads by naming convention rather than through a load graph
|
|
89
102
|
* a static reader could follow, so a constant that nesting alone cannot qualify
|
|
90
103
|
* keeps whatever name the source wrote and callers treat it as unresolved.
|
|
@@ -141,7 +154,13 @@ interface ReachedBody {
|
|
|
141
154
|
/** Absolute path of the file the block is written in. */
|
|
142
155
|
file: string;
|
|
143
156
|
}
|
|
144
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* One ancestor: every block reopening its name, the name alone when
|
|
159
|
+
* nothing reached it, or the library's own class the walk stopped at.
|
|
160
|
+
* Blocks stay together because Ruby treats a reopened class as one
|
|
161
|
+
* place in the chain. The root is kept by name so a caller can tell a
|
|
162
|
+
* chain that ended at the library from one that ended at nothing.
|
|
163
|
+
*/
|
|
145
164
|
type AncestorEntry = {
|
|
146
165
|
type: "bodies";
|
|
147
166
|
name: string;
|
|
@@ -149,6 +168,9 @@ type AncestorEntry = {
|
|
|
149
168
|
} | {
|
|
150
169
|
type: "unfollowed";
|
|
151
170
|
name: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: "root";
|
|
173
|
+
name: string;
|
|
152
174
|
};
|
|
153
175
|
/** A class and everything it inherits from, in Ruby's own method-lookup order. */
|
|
154
176
|
type Ancestry = readonly AncestorEntry[];
|
|
@@ -157,6 +179,8 @@ interface AncestorLookup {
|
|
|
157
179
|
/** Directory the constant-to-path convention resolves an ancestor's name against. */
|
|
158
180
|
root: string;
|
|
159
181
|
pathConvention: ConstantPathConvention;
|
|
182
|
+
/** Acronyms the convention keeps as one word, `ActivityPub` to `activitypub`. */
|
|
183
|
+
acronyms?: readonly string[];
|
|
160
184
|
/**
|
|
161
185
|
* The library's own classes a project's chain ends at. Reaching one
|
|
162
186
|
* ends a walk with nothing left unfollowed.
|
|
@@ -244,6 +268,8 @@ interface RubyPack {
|
|
|
244
268
|
clients?: RbClientCall[];
|
|
245
269
|
/** What the library's own database calls look like. The README says how one is matched. */
|
|
246
270
|
storage?: RbStoragePattern[];
|
|
271
|
+
/** Calls the library gives a project for reading a model through a batching loader, rather than on the model itself. */
|
|
272
|
+
loaders?: RbLoaderPattern[];
|
|
247
273
|
}
|
|
248
274
|
/**
|
|
249
275
|
* The calls a library gives a project for making a request. A method
|
|
@@ -264,7 +290,7 @@ interface RbClientCall {
|
|
|
264
290
|
receiverBuilders?: string[];
|
|
265
291
|
/** The keyword such a builder takes the base URL under, which comes in front of the path of a call on it. */
|
|
266
292
|
builderUrlKeyword?: string;
|
|
267
|
-
/** What the response object gives a caller, so a test on
|
|
293
|
+
/** What the response object gives a caller, so a test on one of its members counts as a test on a status. */
|
|
268
294
|
response?: RbClientResponse;
|
|
269
295
|
/** A call that sends a request object built somewhere else, which is how Net::HTTP sends anything with a body. */
|
|
270
296
|
requestObject?: {
|
|
@@ -304,16 +330,35 @@ interface RbStoragePattern {
|
|
|
304
330
|
/** Which database is behind the connection, which the project settles. */
|
|
305
331
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
306
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* A loader that batches reads of a model on the caller's behalf, graphql-ruby's
|
|
335
|
+
* dataloader for one. The call that picks what to load is given the model as
|
|
336
|
+
* a constant argument, so the read is recorded against that model the same
|
|
337
|
+
* way a call on the model itself would be, and a storage pattern from another
|
|
338
|
+
* pack in the run says whether the constant is a model at all.
|
|
339
|
+
*/
|
|
340
|
+
interface RbLoaderPattern {
|
|
341
|
+
/** The receiverless call that gives the loader, `dataloader`. */
|
|
342
|
+
loader: string;
|
|
343
|
+
/** The method on the loader that picks a source and its arguments, `with`. */
|
|
344
|
+
pick: string;
|
|
345
|
+
/** The methods on a picked source that perform the read, `load` and `load_all`. */
|
|
346
|
+
reads: string[];
|
|
347
|
+
/** Receiverless calls that pick and read in one, whose arguments include the model, `dataload` and `dataload_record`. */
|
|
348
|
+
shortcuts: string[];
|
|
349
|
+
}
|
|
307
350
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
308
|
-
/** A class whose ancestry reaches one of `baseClassNames` is a controller, and every instance method it defines directly is one of its actions, bound by `routeFor` to the method and path a project's own routing gives it, or discovered with no boundary binding when `routeFor` finds none. */
|
|
351
|
+
/** A class whose ancestry reaches one of `baseClassNames` or `ancestryRootClassNames` is a controller, and every instance method it defines directly is one of its actions, bound by `routeFor` to the method and path a project's own routing gives it, or discovered with no boundary binding when `routeFor` finds none. */
|
|
309
352
|
interface ControllerActions {
|
|
310
353
|
type: "controllerActions";
|
|
311
|
-
/**
|
|
354
|
+
/** A base a project's controllers extend, `ApplicationController` say. The base itself is not a controller. */
|
|
312
355
|
baseClassNames: string[];
|
|
313
356
|
/** The directory a bare superclass name is looked up under, the project's own layout. */
|
|
314
357
|
root: string;
|
|
315
358
|
pathConvention: ConstantPathConvention;
|
|
316
|
-
/**
|
|
359
|
+
/** Acronyms the project registers with the inflector, which the path convention keeps as one word: `ActivityPub` is `activitypub`, not `activity_pub`. */
|
|
360
|
+
acronyms?: string[];
|
|
361
|
+
/** The library's own classes a project's controller chain ends at. A class extending one directly is a controller too. */
|
|
317
362
|
ancestryRootClassNames: string[];
|
|
318
363
|
/** Status code a wire response gets when the action does not say otherwise. */
|
|
319
364
|
defaultStatusCode: number;
|
|
@@ -356,7 +401,7 @@ interface RbControllerFilter {
|
|
|
356
401
|
* `rescue_from ActiveRecord::RecordNotFound, with: :not_found`.
|
|
357
402
|
*/
|
|
358
403
|
methodFrom: "argument" | "withKeyword";
|
|
359
|
-
/** Set when the library runs the method only for an action that raised,
|
|
404
|
+
/** Set when the library runs the method only for an action that raised, as `rescue_from` does. */
|
|
360
405
|
onThrow?: boolean;
|
|
361
406
|
/** The name of the call that takes a filter back off, `skip_before_action` for `before_action`. */
|
|
362
407
|
skippedBy?: string;
|
|
@@ -369,7 +414,7 @@ interface RbControllerFilter {
|
|
|
369
414
|
/**
|
|
370
415
|
* One call an action writes to send a response, and where that call takes
|
|
371
416
|
* the status. A call may take it both ways, and then the keyword wins,
|
|
372
|
-
*
|
|
417
|
+
* as it does in Rails for `head :ok, status: :created`.
|
|
373
418
|
*/
|
|
374
419
|
interface RbStatusCall {
|
|
375
420
|
/** The call's own name as an action writes it, `render` for Rails. */
|
|
@@ -393,6 +438,8 @@ interface GraphqlObjectFields {
|
|
|
393
438
|
/** The directory a wiring keyword's referenced class is looked up under. That is the project's own layout, not the library's. */
|
|
394
439
|
root: string;
|
|
395
440
|
pathConvention: ConstantPathConvention;
|
|
441
|
+
/** Acronyms the project registers with the inflector, which the path convention keeps as one word. */
|
|
442
|
+
acronyms?: string[];
|
|
396
443
|
/** The DSL call declaring one schema field in an object type's body. */
|
|
397
444
|
fieldCallName: string;
|
|
398
445
|
/** The DSL call declaring a referenced class's own return type. */
|
|
@@ -436,9 +483,19 @@ interface GraphqlObjectFields {
|
|
|
436
483
|
};
|
|
437
484
|
}
|
|
438
485
|
|
|
486
|
+
/**
|
|
487
|
+
* storage.ts: which calls in a body talk to the database, for Ruby.
|
|
488
|
+
*
|
|
489
|
+
* A pack says which base class the library gives a model, and a call on a
|
|
490
|
+
* class that reaches that base is a database call. The README says why
|
|
491
|
+
* ancestry. A loader pattern from another pack adds calls that are given
|
|
492
|
+
* the model as an argument instead, and those go through the same test.
|
|
493
|
+
*/
|
|
494
|
+
|
|
439
495
|
interface RbStorageOptions {
|
|
440
496
|
readonly facts: Database;
|
|
441
497
|
readonly patterns: readonly RbStoragePattern[];
|
|
498
|
+
readonly loaders?: readonly RbLoaderPattern[];
|
|
442
499
|
}
|
|
443
500
|
|
|
444
501
|
/** The methods a pack declared the library defines itself, so a receiverless call to one of them is not work the project does. */
|
|
@@ -725,10 +782,12 @@ interface ProjectNodes {
|
|
|
725
782
|
}
|
|
726
783
|
/** Register the parsed project, so reads through `db` can follow the facts back to nodes. */
|
|
727
784
|
declare function bindEvaluator(db: Database, nodes: ProjectNodes): void;
|
|
785
|
+
/** Strings to read for the parameters of the block or method `node` is written in, the way a caller would supply them. */
|
|
786
|
+
type ParameterBindings = ReadonlyMap<string, string>;
|
|
728
787
|
/** The abstract value `node` comes down to, through the facts when `db` was bound. */
|
|
729
|
-
declare function evaluatedValue(node: Node, db?: Database): Value;
|
|
788
|
+
declare function evaluatedValue(node: Node, db?: Database, bindings?: ParameterBindings): Value;
|
|
730
789
|
/** The one string `node` comes down to, or null when it does not settle on one. */
|
|
731
|
-
declare function stringValueOf(node: Node, db?: Database): string | null;
|
|
790
|
+
declare function stringValueOf(node: Node, db?: Database, bindings?: ParameterBindings): string | null;
|
|
732
791
|
/** Every method a file defines, keyed the way the facts key it, for `bindEvaluator`. */
|
|
733
792
|
declare function methodDefinitionsIn(file: string, root: Node): Map<string, Node>;
|
|
734
793
|
|
|
@@ -742,4 +801,4 @@ declare function methodDefinitionsIn(file: string, root: Node): Map<string, Node
|
|
|
742
801
|
*/
|
|
743
802
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
744
803
|
|
|
745
|
-
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantPathConvention, type ControllerActions, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ProjectNodes, type Range, type RbStatusCall, type RbStoragePattern, 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, createFileCache, discoverUnits, emitConstantBindings, emitEntryFact, emitValueFacts, evaluatedValue, extractRubyProject, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, methodDefinitionsIn, methodInAncestry, nodeId, parseRuby, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, unitKey, walkClasses, walkDefinitions };
|
|
804
|
+
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantPathConvention, type ControllerActions, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbStatusCall, type RbStoragePattern, 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, createFileCache, discoverUnits, emitConstantBindings, emitEntryFact, emitValueFacts, evaluatedValue, extractRubyProject, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, unitKey, walkClasses, walkDefinitions };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ interface Range {
|
|
|
31
31
|
}
|
|
32
32
|
declare function field(node: Node, name: string): Node | null;
|
|
33
33
|
declare function bodyStatements(body: Node): Node[];
|
|
34
|
+
/**
|
|
35
|
+
* Every statement written directly inside a branching statement's
|
|
36
|
+
* branches, across its `elsif`, `else`, `when`, `rescue` and `ensure`
|
|
37
|
+
* clauses. A statement inside a nested branching statement is not
|
|
38
|
+
* included; the caller descends into that one itself.
|
|
39
|
+
*/
|
|
40
|
+
declare function nestedStatements(stmt: Node): Node[];
|
|
34
41
|
/** A call whose block is the thing being configured rather than a place statements run. */
|
|
35
42
|
type BlockConfigures = (call: Node) => boolean;
|
|
36
43
|
/**
|
|
@@ -68,8 +75,14 @@ declare function readCallArgs(argumentList: Node | null): CallArgs;
|
|
|
68
75
|
*/
|
|
69
76
|
/** A pack picks a convention by name, and the code for each one lives here. */
|
|
70
77
|
type ConstantPathConvention = "railsUnderscore";
|
|
71
|
-
/**
|
|
72
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Ported from ActiveSupport's own `String#underscore`, which is what
|
|
80
|
+
* Rails autoloading runs a constant path through. An acronym the
|
|
81
|
+
* project registers with the inflector is one word to it, so with
|
|
82
|
+
* `ActivityPub` registered the path is `activitypub`, not
|
|
83
|
+
* `activity_pub`.
|
|
84
|
+
*/
|
|
85
|
+
declare function underscoreConstantPath(qualifiedName: string, acronyms?: readonly string[]): string;
|
|
73
86
|
/**
|
|
74
87
|
* Null when there is no file at that path. Rails autoloads from every
|
|
75
88
|
* directory directly under `app`, so `ApplicationController` is
|
|
@@ -77,14 +90,14 @@ declare function underscoreConstantPath(qualifiedName: string): string;
|
|
|
77
90
|
* `app/application_controller.rb`; those directories are tried after
|
|
78
91
|
* the root itself, in name order, and no other spelling is tried.
|
|
79
92
|
*/
|
|
80
|
-
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention): string | null;
|
|
93
|
+
declare function resolveConstantFile(root: string, qualifiedName: string, convention: ConstantPathConvention, acronyms?: readonly string[]): string | null;
|
|
81
94
|
|
|
82
95
|
/**
|
|
83
96
|
* Resolves Ruby constant paths against lexical nesting.
|
|
84
97
|
*
|
|
85
|
-
* A compound path
|
|
86
|
-
*
|
|
87
|
-
*
|
|
98
|
+
* A compound path referenced, like `Data::Record`, is read as absolute. A
|
|
99
|
+
* bare name is relative to the nesting it is written inside, and so is a
|
|
100
|
+
* compound name `class` or `module` opens. `require` is never resolved,
|
|
88
101
|
* because Rails autoloads by naming convention rather than through a load graph
|
|
89
102
|
* a static reader could follow, so a constant that nesting alone cannot qualify
|
|
90
103
|
* keeps whatever name the source wrote and callers treat it as unresolved.
|
|
@@ -141,7 +154,13 @@ interface ReachedBody {
|
|
|
141
154
|
/** Absolute path of the file the block is written in. */
|
|
142
155
|
file: string;
|
|
143
156
|
}
|
|
144
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* One ancestor: every block reopening its name, the name alone when
|
|
159
|
+
* nothing reached it, or the library's own class the walk stopped at.
|
|
160
|
+
* Blocks stay together because Ruby treats a reopened class as one
|
|
161
|
+
* place in the chain. The root is kept by name so a caller can tell a
|
|
162
|
+
* chain that ended at the library from one that ended at nothing.
|
|
163
|
+
*/
|
|
145
164
|
type AncestorEntry = {
|
|
146
165
|
type: "bodies";
|
|
147
166
|
name: string;
|
|
@@ -149,6 +168,9 @@ type AncestorEntry = {
|
|
|
149
168
|
} | {
|
|
150
169
|
type: "unfollowed";
|
|
151
170
|
name: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: "root";
|
|
173
|
+
name: string;
|
|
152
174
|
};
|
|
153
175
|
/** A class and everything it inherits from, in Ruby's own method-lookup order. */
|
|
154
176
|
type Ancestry = readonly AncestorEntry[];
|
|
@@ -157,6 +179,8 @@ interface AncestorLookup {
|
|
|
157
179
|
/** Directory the constant-to-path convention resolves an ancestor's name against. */
|
|
158
180
|
root: string;
|
|
159
181
|
pathConvention: ConstantPathConvention;
|
|
182
|
+
/** Acronyms the convention keeps as one word, `ActivityPub` to `activitypub`. */
|
|
183
|
+
acronyms?: readonly string[];
|
|
160
184
|
/**
|
|
161
185
|
* The library's own classes a project's chain ends at. Reaching one
|
|
162
186
|
* ends a walk with nothing left unfollowed.
|
|
@@ -244,6 +268,8 @@ interface RubyPack {
|
|
|
244
268
|
clients?: RbClientCall[];
|
|
245
269
|
/** What the library's own database calls look like. The README says how one is matched. */
|
|
246
270
|
storage?: RbStoragePattern[];
|
|
271
|
+
/** Calls the library gives a project for reading a model through a batching loader, rather than on the model itself. */
|
|
272
|
+
loaders?: RbLoaderPattern[];
|
|
247
273
|
}
|
|
248
274
|
/**
|
|
249
275
|
* The calls a library gives a project for making a request. A method
|
|
@@ -264,7 +290,7 @@ interface RbClientCall {
|
|
|
264
290
|
receiverBuilders?: string[];
|
|
265
291
|
/** The keyword such a builder takes the base URL under, which comes in front of the path of a call on it. */
|
|
266
292
|
builderUrlKeyword?: string;
|
|
267
|
-
/** What the response object gives a caller, so a test on
|
|
293
|
+
/** What the response object gives a caller, so a test on one of its members counts as a test on a status. */
|
|
268
294
|
response?: RbClientResponse;
|
|
269
295
|
/** A call that sends a request object built somewhere else, which is how Net::HTTP sends anything with a body. */
|
|
270
296
|
requestObject?: {
|
|
@@ -304,16 +330,35 @@ interface RbStoragePattern {
|
|
|
304
330
|
/** Which database is behind the connection, which the project settles. */
|
|
305
331
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
306
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* A loader that batches reads of a model on the caller's behalf, graphql-ruby's
|
|
335
|
+
* dataloader for one. The call that picks what to load is given the model as
|
|
336
|
+
* a constant argument, so the read is recorded against that model the same
|
|
337
|
+
* way a call on the model itself would be, and a storage pattern from another
|
|
338
|
+
* pack in the run says whether the constant is a model at all.
|
|
339
|
+
*/
|
|
340
|
+
interface RbLoaderPattern {
|
|
341
|
+
/** The receiverless call that gives the loader, `dataloader`. */
|
|
342
|
+
loader: string;
|
|
343
|
+
/** The method on the loader that picks a source and its arguments, `with`. */
|
|
344
|
+
pick: string;
|
|
345
|
+
/** The methods on a picked source that perform the read, `load` and `load_all`. */
|
|
346
|
+
reads: string[];
|
|
347
|
+
/** Receiverless calls that pick and read in one, whose arguments include the model, `dataload` and `dataload_record`. */
|
|
348
|
+
shortcuts: string[];
|
|
349
|
+
}
|
|
307
350
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
308
|
-
/** A class whose ancestry reaches one of `baseClassNames` is a controller, and every instance method it defines directly is one of its actions, bound by `routeFor` to the method and path a project's own routing gives it, or discovered with no boundary binding when `routeFor` finds none. */
|
|
351
|
+
/** A class whose ancestry reaches one of `baseClassNames` or `ancestryRootClassNames` is a controller, and every instance method it defines directly is one of its actions, bound by `routeFor` to the method and path a project's own routing gives it, or discovered with no boundary binding when `routeFor` finds none. */
|
|
309
352
|
interface ControllerActions {
|
|
310
353
|
type: "controllerActions";
|
|
311
|
-
/**
|
|
354
|
+
/** A base a project's controllers extend, `ApplicationController` say. The base itself is not a controller. */
|
|
312
355
|
baseClassNames: string[];
|
|
313
356
|
/** The directory a bare superclass name is looked up under, the project's own layout. */
|
|
314
357
|
root: string;
|
|
315
358
|
pathConvention: ConstantPathConvention;
|
|
316
|
-
/**
|
|
359
|
+
/** Acronyms the project registers with the inflector, which the path convention keeps as one word: `ActivityPub` is `activitypub`, not `activity_pub`. */
|
|
360
|
+
acronyms?: string[];
|
|
361
|
+
/** The library's own classes a project's controller chain ends at. A class extending one directly is a controller too. */
|
|
317
362
|
ancestryRootClassNames: string[];
|
|
318
363
|
/** Status code a wire response gets when the action does not say otherwise. */
|
|
319
364
|
defaultStatusCode: number;
|
|
@@ -356,7 +401,7 @@ interface RbControllerFilter {
|
|
|
356
401
|
* `rescue_from ActiveRecord::RecordNotFound, with: :not_found`.
|
|
357
402
|
*/
|
|
358
403
|
methodFrom: "argument" | "withKeyword";
|
|
359
|
-
/** Set when the library runs the method only for an action that raised,
|
|
404
|
+
/** Set when the library runs the method only for an action that raised, as `rescue_from` does. */
|
|
360
405
|
onThrow?: boolean;
|
|
361
406
|
/** The name of the call that takes a filter back off, `skip_before_action` for `before_action`. */
|
|
362
407
|
skippedBy?: string;
|
|
@@ -369,7 +414,7 @@ interface RbControllerFilter {
|
|
|
369
414
|
/**
|
|
370
415
|
* One call an action writes to send a response, and where that call takes
|
|
371
416
|
* the status. A call may take it both ways, and then the keyword wins,
|
|
372
|
-
*
|
|
417
|
+
* as it does in Rails for `head :ok, status: :created`.
|
|
373
418
|
*/
|
|
374
419
|
interface RbStatusCall {
|
|
375
420
|
/** The call's own name as an action writes it, `render` for Rails. */
|
|
@@ -393,6 +438,8 @@ interface GraphqlObjectFields {
|
|
|
393
438
|
/** The directory a wiring keyword's referenced class is looked up under. That is the project's own layout, not the library's. */
|
|
394
439
|
root: string;
|
|
395
440
|
pathConvention: ConstantPathConvention;
|
|
441
|
+
/** Acronyms the project registers with the inflector, which the path convention keeps as one word. */
|
|
442
|
+
acronyms?: string[];
|
|
396
443
|
/** The DSL call declaring one schema field in an object type's body. */
|
|
397
444
|
fieldCallName: string;
|
|
398
445
|
/** The DSL call declaring a referenced class's own return type. */
|
|
@@ -436,9 +483,19 @@ interface GraphqlObjectFields {
|
|
|
436
483
|
};
|
|
437
484
|
}
|
|
438
485
|
|
|
486
|
+
/**
|
|
487
|
+
* storage.ts: which calls in a body talk to the database, for Ruby.
|
|
488
|
+
*
|
|
489
|
+
* A pack says which base class the library gives a model, and a call on a
|
|
490
|
+
* class that reaches that base is a database call. The README says why
|
|
491
|
+
* ancestry. A loader pattern from another pack adds calls that are given
|
|
492
|
+
* the model as an argument instead, and those go through the same test.
|
|
493
|
+
*/
|
|
494
|
+
|
|
439
495
|
interface RbStorageOptions {
|
|
440
496
|
readonly facts: Database;
|
|
441
497
|
readonly patterns: readonly RbStoragePattern[];
|
|
498
|
+
readonly loaders?: readonly RbLoaderPattern[];
|
|
442
499
|
}
|
|
443
500
|
|
|
444
501
|
/** The methods a pack declared the library defines itself, so a receiverless call to one of them is not work the project does. */
|
|
@@ -725,10 +782,12 @@ interface ProjectNodes {
|
|
|
725
782
|
}
|
|
726
783
|
/** Register the parsed project, so reads through `db` can follow the facts back to nodes. */
|
|
727
784
|
declare function bindEvaluator(db: Database, nodes: ProjectNodes): void;
|
|
785
|
+
/** Strings to read for the parameters of the block or method `node` is written in, the way a caller would supply them. */
|
|
786
|
+
type ParameterBindings = ReadonlyMap<string, string>;
|
|
728
787
|
/** The abstract value `node` comes down to, through the facts when `db` was bound. */
|
|
729
|
-
declare function evaluatedValue(node: Node, db?: Database): Value;
|
|
788
|
+
declare function evaluatedValue(node: Node, db?: Database, bindings?: ParameterBindings): Value;
|
|
730
789
|
/** The one string `node` comes down to, or null when it does not settle on one. */
|
|
731
|
-
declare function stringValueOf(node: Node, db?: Database): string | null;
|
|
790
|
+
declare function stringValueOf(node: Node, db?: Database, bindings?: ParameterBindings): string | null;
|
|
732
791
|
/** Every method a file defines, keyed the way the facts key it, for `bindEvaluator`. */
|
|
733
792
|
declare function methodDefinitionsIn(file: string, root: Node): Map<string, Node>;
|
|
734
793
|
|
|
@@ -742,4 +801,4 @@ declare function methodDefinitionsIn(file: string, root: Node): Map<string, Node
|
|
|
742
801
|
*/
|
|
743
802
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
744
803
|
|
|
745
|
-
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantPathConvention, type ControllerActions, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ProjectNodes, type Range, type RbStatusCall, type RbStoragePattern, 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, createFileCache, discoverUnits, emitConstantBindings, emitEntryFact, emitValueFacts, evaluatedValue, extractRubyProject, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, methodDefinitionsIn, methodInAncestry, nodeId, parseRuby, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, unitKey, walkClasses, walkDefinitions };
|
|
804
|
+
export { ADAPTER_VERSION, type AncestorEntry, type AncestorLookup, type Ancestry, type CallArgs, type ClassInfo, type ConstantPathConvention, type ControllerActions, type DiscoveryOptions, type EvaluatedFile, type ExtractRubyOptions, type ExtractRubyResult, type FileCache, type FileConstants, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbStatusCall, type RbStoragePattern, 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, createFileCache, discoverUnits, emitConstantBindings, emitEntryFact, emitValueFacts, evaluatedValue, extractRubyProject, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, unitKey, walkClasses, walkDefinitions };
|