@suss/adapter-ruby 0.32.0 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/index.cjs +900 -180
- package/dist/index.d.cts +127 -5
- package/dist/index.d.ts +127 -5
- package/dist/index.js +889 -171
- package/package.json +8 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Database } from '@suss/datalog';
|
|
2
2
|
import { Tree, Node } from 'web-tree-sitter';
|
|
3
3
|
export { Node as RbNode, Tree as RbTree } from 'web-tree-sitter';
|
|
4
|
-
import { TypeShape, BehavioralSummary } from '@suss/behavioral-ir';
|
|
4
|
+
import { TypeShape, Effect, BehavioralSummary } from '@suss/behavioral-ir';
|
|
5
5
|
import { RawCodeStructure, TimingReport, ExtractionReport, CacheDiagnostic, ExtractorOptions } from '@suss/extractor';
|
|
6
6
|
import { WhyExplained } from '@suss/resolution';
|
|
7
7
|
import { Value } from '@suss/values';
|
|
@@ -316,6 +316,8 @@ interface RubyPack {
|
|
|
316
316
|
clients?: RbClientCall[];
|
|
317
317
|
/** What the library's own database calls look like. The README says how one is matched. */
|
|
318
318
|
storage?: RbStoragePattern[];
|
|
319
|
+
/** The calls the library gives a project for handing the store a statement it wrote itself. */
|
|
320
|
+
rawSql?: RbRawSqlPattern[];
|
|
319
321
|
/** Calls the library gives a project for reading a model through a batching loader, rather than on the model itself. */
|
|
320
322
|
loaders?: RbLoaderPattern[];
|
|
321
323
|
/** Calls the library gives a class or module body whose block runs as part of that body. */
|
|
@@ -417,6 +419,17 @@ interface RbStoragePattern {
|
|
|
417
419
|
reads: string[];
|
|
418
420
|
/** Methods whose result is the model again: one record, or a relation a later read narrows to one. */
|
|
419
421
|
givesBack: string[];
|
|
422
|
+
/**
|
|
423
|
+
* Methods on the model that take a statement the project wrote itself,
|
|
424
|
+
* and where each one takes it. The tables come from the statement, so
|
|
425
|
+
* one of these says nothing about the model's own container, and the
|
|
426
|
+
* statement is read in the dialect of `storageSystem`.
|
|
427
|
+
*/
|
|
428
|
+
statements?: Record<string, RbArgumentPlace>;
|
|
429
|
+
/** The token the library writes where a bind value goes, ActiveRecord's `?`. */
|
|
430
|
+
bindPlaceholder?: string;
|
|
431
|
+
/** The methods the library runs of its own accord when a write happens, `after_commit :sync_search`. */
|
|
432
|
+
callbacks?: RbModelCallbacks;
|
|
420
433
|
/** Methods that pick rows by the primary key when they are given a positional argument, and the column that is. */
|
|
421
434
|
byPrimaryKey?: RbPrimaryKeyLookup;
|
|
422
435
|
/** Read methods whose symbol arguments are the columns they ask for. */
|
|
@@ -426,7 +439,88 @@ interface RbStoragePattern {
|
|
|
426
439
|
/** Which database is behind the connection, which the project settles. */
|
|
427
440
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
428
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* A library whose calls take SQL the project wrote, rather than
|
|
444
|
+
* building it from a model. Ruby writes no types, so the receiver is
|
|
445
|
+
* typed by following it back to the library call that produced it: the
|
|
446
|
+
* chain starts at `constantName`, one of `clientBuilders` gives back a
|
|
447
|
+
* client, and `addressing` calls narrow that client to a part of the
|
|
448
|
+
* store before the statement or the row call arrives.
|
|
449
|
+
*/
|
|
450
|
+
interface RbRawSqlPattern {
|
|
451
|
+
/** The constant the library's calls start at, `PG` or `Google::Cloud::Bigquery`. */
|
|
452
|
+
constantName: string;
|
|
453
|
+
/**
|
|
454
|
+
* Base classes whose subclasses hand a client out the same way the
|
|
455
|
+
* constant does, `ActiveRecord::Base` for Rails. A project writes
|
|
456
|
+
* `Account.connection` and a bare `connection` inside the model as
|
|
457
|
+
* readily as the base class itself, and all three reach one store.
|
|
458
|
+
*/
|
|
459
|
+
baseClasses?: string[];
|
|
460
|
+
/** Methods on that constant that give back a client, `connect` for the pg gem. */
|
|
461
|
+
clientBuilders: string[];
|
|
462
|
+
/** Calls that narrow a client to part of the store and give back something the rest of the calls can be made on. */
|
|
463
|
+
addressing?: Record<string, RbAddressingCall>;
|
|
464
|
+
/** Calls that take a statement, and where each one takes it. */
|
|
465
|
+
statements?: Record<string, RbArgumentPlace>;
|
|
466
|
+
/** The token the library writes where a bind value goes, when it is not the one the dialect itself reads. */
|
|
467
|
+
bindPlaceholder?: string;
|
|
468
|
+
/** Calls that read or write rows of an addressed container with no statement, `insert` on a BigQuery table. */
|
|
469
|
+
rowCalls?: Record<string, RbRowCall>;
|
|
470
|
+
/** Which store is behind the calls, in the words OpenTelemetry's semantic conventions use: `postgresql`, `gcp.bigquery`. */
|
|
471
|
+
storageSystem: string;
|
|
472
|
+
/**
|
|
473
|
+
* Which dialect the statements are written in, which is a separate
|
|
474
|
+
* answer from the store: BigQuery's store is `gcp.bigquery` and its
|
|
475
|
+
* statements are `bigquery`, and a default here would read the wrong
|
|
476
|
+
* tables without saying so.
|
|
477
|
+
*/
|
|
478
|
+
dialect: string;
|
|
479
|
+
/** Which namespace the calls reach when neither the chain nor the table name says. Defaults to "default". */
|
|
480
|
+
scope?: string;
|
|
481
|
+
}
|
|
482
|
+
/** A call that says which part of the store the calls after it reach, `bigquery.dataset("core")`. */
|
|
483
|
+
interface RbAddressingCall extends RbArgumentPlace {
|
|
484
|
+
/** Which part of the address this call states. */
|
|
485
|
+
says: "scope" | "container";
|
|
486
|
+
}
|
|
487
|
+
/** A call that reads or writes rows without a statement. */
|
|
488
|
+
interface RbRowCall {
|
|
489
|
+
kind: "read" | "write";
|
|
490
|
+
/**
|
|
491
|
+
* Where the call may say which container, for a library that gives
|
|
492
|
+
* the same call on the container and one level above it: BigQuery's
|
|
493
|
+
* `table.insert(rows)` and `dataset.insert("accounts", rows)`. The
|
|
494
|
+
* chain's own container is used when this argument settles on no
|
|
495
|
+
* string, which is what a row argument does.
|
|
496
|
+
*/
|
|
497
|
+
container?: RbArgumentPlace;
|
|
498
|
+
}
|
|
499
|
+
/** Where a call writes one of its arguments. A call that takes it both ways is matched on the keyword first. */
|
|
500
|
+
interface RbArgumentPlace {
|
|
501
|
+
/** The index of the positional argument. */
|
|
502
|
+
at: number;
|
|
503
|
+
/** The keyword the argument may travel under instead. */
|
|
504
|
+
keyword?: string;
|
|
505
|
+
}
|
|
429
506
|
/** Which methods take the primary key positionally, and what that column is called. */
|
|
507
|
+
/**
|
|
508
|
+
* The methods a model registers in its own class body for the library
|
|
509
|
+
* to run when a write happens. A body that writes through the model
|
|
510
|
+
* runs them too, so their effects belong to that body.
|
|
511
|
+
*
|
|
512
|
+
* `events` is the library's own vocabulary for what a write is, and
|
|
513
|
+
* both halves of this are keyed by it: a write method says which events
|
|
514
|
+
* it runs, and a registering call says which events it covers.
|
|
515
|
+
*/
|
|
516
|
+
interface RbModelCallbacks {
|
|
517
|
+
/** Each write method the pattern declares, and the events it runs. */
|
|
518
|
+
eventOf: Record<string, string[]>;
|
|
519
|
+
/** Each class-body call that registers a callback, and the events it covers when the call narrows to none. */
|
|
520
|
+
registeredBy: Record<string, string[]>;
|
|
521
|
+
/** The keyword that narrows one registration to some of those events, `on`. */
|
|
522
|
+
eventKeyword: string;
|
|
523
|
+
}
|
|
430
524
|
interface RbPrimaryKeyLookup {
|
|
431
525
|
methods: string[];
|
|
432
526
|
/** The column the library uses unless a model says another. */
|
|
@@ -463,6 +557,19 @@ interface RbLoaderPattern {
|
|
|
463
557
|
reads: string[];
|
|
464
558
|
/** Receiverless calls that pick and read in one, whose arguments include the model, `dataload` and `dataload_record`. */
|
|
465
559
|
shortcuts: string[];
|
|
560
|
+
/**
|
|
561
|
+
* Where `pick` takes the project's own source class, and the method
|
|
562
|
+
* the library runs on it. The read happens in that method, so what it
|
|
563
|
+
* reaches belongs to every body that loads through it.
|
|
564
|
+
*/
|
|
565
|
+
source?: RbLoaderSource;
|
|
566
|
+
}
|
|
567
|
+
/** The source class a loader is given, and the method the library runs on it. */
|
|
568
|
+
interface RbLoaderSource {
|
|
569
|
+
/** The position `pick` takes the source class at, 0 for `dataloader.with(Source, ...)`. */
|
|
570
|
+
at: number;
|
|
571
|
+
/** The method the library runs on the source, `fetch`. */
|
|
572
|
+
method: string;
|
|
466
573
|
}
|
|
467
574
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
468
575
|
/** 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. */
|
|
@@ -610,16 +717,31 @@ interface GraphqlObjectFields {
|
|
|
610
717
|
* defines, and every other call is left to the reach walk. The README says
|
|
611
718
|
* why ancestry.
|
|
612
719
|
*
|
|
613
|
-
* The class behind the receiver comes from the constant bindings
|
|
614
|
-
*
|
|
615
|
-
* pattern adds calls
|
|
720
|
+
* The class behind the receiver comes from the constant bindings, or from the
|
|
721
|
+
* resolution rules. A loader pattern adds calls given the model, and a raw
|
|
722
|
+
* SQL pattern adds calls handed a statement, both reported through here.
|
|
616
723
|
*/
|
|
617
724
|
|
|
618
725
|
interface RbStorageOptions {
|
|
619
726
|
readonly facts: Database;
|
|
620
727
|
readonly patterns: readonly RbStoragePattern[];
|
|
621
728
|
readonly loaders?: readonly RbLoaderPattern[];
|
|
729
|
+
/** What a pack says about calls that take SQL the project wrote itself. */
|
|
730
|
+
readonly rawSql?: readonly RbRawSqlPattern[];
|
|
622
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* Whether the recognizer records this call as database work, so a walk
|
|
734
|
+
* need not report it as a gap. `enclosing` is the method the call is
|
|
735
|
+
* written in, which is what tells one body's locals from the next.
|
|
736
|
+
*/
|
|
737
|
+
declare function storageClaims(call: Node, file: string, options: RbStorageOptions, enclosing?: Node | null): boolean;
|
|
738
|
+
/**
|
|
739
|
+
* The database work a body does, one effect per chain. A chain is one thing
|
|
740
|
+
* the code does, so `Order.where(id: 1).first` counts once. `file` is the
|
|
741
|
+
* absolute path the calls were read from, which the constant bindings key on.
|
|
742
|
+
* `enclosing` is the method the calls were read from, or null outside one.
|
|
743
|
+
*/
|
|
744
|
+
declare function storageEffects(calls: readonly Node[], file: string, options: RbStorageOptions, enclosing?: Node | null): Effect[];
|
|
623
745
|
|
|
624
746
|
/** The methods a pack declared the library defines itself, so a receiverless call to one of them is not work the project does. */
|
|
625
747
|
type InheritedMethods = ReadonlySet<string>;
|
|
@@ -985,4 +1107,4 @@ declare function methodDefinitionsIn(file: string, root: Node): Map<string, Node
|
|
|
985
1107
|
*/
|
|
986
1108
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
987
1109
|
|
|
988
|
-
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 FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbBodyBlock, type RbInflections, 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, factsForFile, 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 };
|
|
1110
|
+
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 FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbAddressingCall, type RbArgumentPlace, type RbBodyBlock, type RbInflections, type RbRawSqlPattern, type RbRowCall, type RbStatusCall, type RbStorageOptions, 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, factsForFile, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, storageClaims, storageEffects, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, unitKey, walkClasses, walkDefinitions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Database } from '@suss/datalog';
|
|
2
2
|
import { Tree, Node } from 'web-tree-sitter';
|
|
3
3
|
export { Node as RbNode, Tree as RbTree } from 'web-tree-sitter';
|
|
4
|
-
import { TypeShape, BehavioralSummary } from '@suss/behavioral-ir';
|
|
4
|
+
import { TypeShape, Effect, BehavioralSummary } from '@suss/behavioral-ir';
|
|
5
5
|
import { RawCodeStructure, TimingReport, ExtractionReport, CacheDiagnostic, ExtractorOptions } from '@suss/extractor';
|
|
6
6
|
import { WhyExplained } from '@suss/resolution';
|
|
7
7
|
import { Value } from '@suss/values';
|
|
@@ -316,6 +316,8 @@ interface RubyPack {
|
|
|
316
316
|
clients?: RbClientCall[];
|
|
317
317
|
/** What the library's own database calls look like. The README says how one is matched. */
|
|
318
318
|
storage?: RbStoragePattern[];
|
|
319
|
+
/** The calls the library gives a project for handing the store a statement it wrote itself. */
|
|
320
|
+
rawSql?: RbRawSqlPattern[];
|
|
319
321
|
/** Calls the library gives a project for reading a model through a batching loader, rather than on the model itself. */
|
|
320
322
|
loaders?: RbLoaderPattern[];
|
|
321
323
|
/** Calls the library gives a class or module body whose block runs as part of that body. */
|
|
@@ -417,6 +419,17 @@ interface RbStoragePattern {
|
|
|
417
419
|
reads: string[];
|
|
418
420
|
/** Methods whose result is the model again: one record, or a relation a later read narrows to one. */
|
|
419
421
|
givesBack: string[];
|
|
422
|
+
/**
|
|
423
|
+
* Methods on the model that take a statement the project wrote itself,
|
|
424
|
+
* and where each one takes it. The tables come from the statement, so
|
|
425
|
+
* one of these says nothing about the model's own container, and the
|
|
426
|
+
* statement is read in the dialect of `storageSystem`.
|
|
427
|
+
*/
|
|
428
|
+
statements?: Record<string, RbArgumentPlace>;
|
|
429
|
+
/** The token the library writes where a bind value goes, ActiveRecord's `?`. */
|
|
430
|
+
bindPlaceholder?: string;
|
|
431
|
+
/** The methods the library runs of its own accord when a write happens, `after_commit :sync_search`. */
|
|
432
|
+
callbacks?: RbModelCallbacks;
|
|
420
433
|
/** Methods that pick rows by the primary key when they are given a positional argument, and the column that is. */
|
|
421
434
|
byPrimaryKey?: RbPrimaryKeyLookup;
|
|
422
435
|
/** Read methods whose symbol arguments are the columns they ask for. */
|
|
@@ -426,7 +439,88 @@ interface RbStoragePattern {
|
|
|
426
439
|
/** Which database is behind the connection, which the project settles. */
|
|
427
440
|
storageSystem: "postgresql" | "mysql" | "sqlite";
|
|
428
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* A library whose calls take SQL the project wrote, rather than
|
|
444
|
+
* building it from a model. Ruby writes no types, so the receiver is
|
|
445
|
+
* typed by following it back to the library call that produced it: the
|
|
446
|
+
* chain starts at `constantName`, one of `clientBuilders` gives back a
|
|
447
|
+
* client, and `addressing` calls narrow that client to a part of the
|
|
448
|
+
* store before the statement or the row call arrives.
|
|
449
|
+
*/
|
|
450
|
+
interface RbRawSqlPattern {
|
|
451
|
+
/** The constant the library's calls start at, `PG` or `Google::Cloud::Bigquery`. */
|
|
452
|
+
constantName: string;
|
|
453
|
+
/**
|
|
454
|
+
* Base classes whose subclasses hand a client out the same way the
|
|
455
|
+
* constant does, `ActiveRecord::Base` for Rails. A project writes
|
|
456
|
+
* `Account.connection` and a bare `connection` inside the model as
|
|
457
|
+
* readily as the base class itself, and all three reach one store.
|
|
458
|
+
*/
|
|
459
|
+
baseClasses?: string[];
|
|
460
|
+
/** Methods on that constant that give back a client, `connect` for the pg gem. */
|
|
461
|
+
clientBuilders: string[];
|
|
462
|
+
/** Calls that narrow a client to part of the store and give back something the rest of the calls can be made on. */
|
|
463
|
+
addressing?: Record<string, RbAddressingCall>;
|
|
464
|
+
/** Calls that take a statement, and where each one takes it. */
|
|
465
|
+
statements?: Record<string, RbArgumentPlace>;
|
|
466
|
+
/** The token the library writes where a bind value goes, when it is not the one the dialect itself reads. */
|
|
467
|
+
bindPlaceholder?: string;
|
|
468
|
+
/** Calls that read or write rows of an addressed container with no statement, `insert` on a BigQuery table. */
|
|
469
|
+
rowCalls?: Record<string, RbRowCall>;
|
|
470
|
+
/** Which store is behind the calls, in the words OpenTelemetry's semantic conventions use: `postgresql`, `gcp.bigquery`. */
|
|
471
|
+
storageSystem: string;
|
|
472
|
+
/**
|
|
473
|
+
* Which dialect the statements are written in, which is a separate
|
|
474
|
+
* answer from the store: BigQuery's store is `gcp.bigquery` and its
|
|
475
|
+
* statements are `bigquery`, and a default here would read the wrong
|
|
476
|
+
* tables without saying so.
|
|
477
|
+
*/
|
|
478
|
+
dialect: string;
|
|
479
|
+
/** Which namespace the calls reach when neither the chain nor the table name says. Defaults to "default". */
|
|
480
|
+
scope?: string;
|
|
481
|
+
}
|
|
482
|
+
/** A call that says which part of the store the calls after it reach, `bigquery.dataset("core")`. */
|
|
483
|
+
interface RbAddressingCall extends RbArgumentPlace {
|
|
484
|
+
/** Which part of the address this call states. */
|
|
485
|
+
says: "scope" | "container";
|
|
486
|
+
}
|
|
487
|
+
/** A call that reads or writes rows without a statement. */
|
|
488
|
+
interface RbRowCall {
|
|
489
|
+
kind: "read" | "write";
|
|
490
|
+
/**
|
|
491
|
+
* Where the call may say which container, for a library that gives
|
|
492
|
+
* the same call on the container and one level above it: BigQuery's
|
|
493
|
+
* `table.insert(rows)` and `dataset.insert("accounts", rows)`. The
|
|
494
|
+
* chain's own container is used when this argument settles on no
|
|
495
|
+
* string, which is what a row argument does.
|
|
496
|
+
*/
|
|
497
|
+
container?: RbArgumentPlace;
|
|
498
|
+
}
|
|
499
|
+
/** Where a call writes one of its arguments. A call that takes it both ways is matched on the keyword first. */
|
|
500
|
+
interface RbArgumentPlace {
|
|
501
|
+
/** The index of the positional argument. */
|
|
502
|
+
at: number;
|
|
503
|
+
/** The keyword the argument may travel under instead. */
|
|
504
|
+
keyword?: string;
|
|
505
|
+
}
|
|
429
506
|
/** Which methods take the primary key positionally, and what that column is called. */
|
|
507
|
+
/**
|
|
508
|
+
* The methods a model registers in its own class body for the library
|
|
509
|
+
* to run when a write happens. A body that writes through the model
|
|
510
|
+
* runs them too, so their effects belong to that body.
|
|
511
|
+
*
|
|
512
|
+
* `events` is the library's own vocabulary for what a write is, and
|
|
513
|
+
* both halves of this are keyed by it: a write method says which events
|
|
514
|
+
* it runs, and a registering call says which events it covers.
|
|
515
|
+
*/
|
|
516
|
+
interface RbModelCallbacks {
|
|
517
|
+
/** Each write method the pattern declares, and the events it runs. */
|
|
518
|
+
eventOf: Record<string, string[]>;
|
|
519
|
+
/** Each class-body call that registers a callback, and the events it covers when the call narrows to none. */
|
|
520
|
+
registeredBy: Record<string, string[]>;
|
|
521
|
+
/** The keyword that narrows one registration to some of those events, `on`. */
|
|
522
|
+
eventKeyword: string;
|
|
523
|
+
}
|
|
430
524
|
interface RbPrimaryKeyLookup {
|
|
431
525
|
methods: string[];
|
|
432
526
|
/** The column the library uses unless a model says another. */
|
|
@@ -463,6 +557,19 @@ interface RbLoaderPattern {
|
|
|
463
557
|
reads: string[];
|
|
464
558
|
/** Receiverless calls that pick and read in one, whose arguments include the model, `dataload` and `dataload_record`. */
|
|
465
559
|
shortcuts: string[];
|
|
560
|
+
/**
|
|
561
|
+
* Where `pick` takes the project's own source class, and the method
|
|
562
|
+
* the library runs on it. The read happens in that method, so what it
|
|
563
|
+
* reaches belongs to every body that loads through it.
|
|
564
|
+
*/
|
|
565
|
+
source?: RbLoaderSource;
|
|
566
|
+
}
|
|
567
|
+
/** The source class a loader is given, and the method the library runs on it. */
|
|
568
|
+
interface RbLoaderSource {
|
|
569
|
+
/** The position `pick` takes the source class at, 0 for `dataloader.with(Source, ...)`. */
|
|
570
|
+
at: number;
|
|
571
|
+
/** The method the library runs on the source, `fetch`. */
|
|
572
|
+
method: string;
|
|
466
573
|
}
|
|
467
574
|
type RubyDiscoveryPattern = GraphqlObjectFields | ControllerActions;
|
|
468
575
|
/** 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. */
|
|
@@ -610,16 +717,31 @@ interface GraphqlObjectFields {
|
|
|
610
717
|
* defines, and every other call is left to the reach walk. The README says
|
|
611
718
|
* why ancestry.
|
|
612
719
|
*
|
|
613
|
-
* The class behind the receiver comes from the constant bindings
|
|
614
|
-
*
|
|
615
|
-
* pattern adds calls
|
|
720
|
+
* The class behind the receiver comes from the constant bindings, or from the
|
|
721
|
+
* resolution rules. A loader pattern adds calls given the model, and a raw
|
|
722
|
+
* SQL pattern adds calls handed a statement, both reported through here.
|
|
616
723
|
*/
|
|
617
724
|
|
|
618
725
|
interface RbStorageOptions {
|
|
619
726
|
readonly facts: Database;
|
|
620
727
|
readonly patterns: readonly RbStoragePattern[];
|
|
621
728
|
readonly loaders?: readonly RbLoaderPattern[];
|
|
729
|
+
/** What a pack says about calls that take SQL the project wrote itself. */
|
|
730
|
+
readonly rawSql?: readonly RbRawSqlPattern[];
|
|
622
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* Whether the recognizer records this call as database work, so a walk
|
|
734
|
+
* need not report it as a gap. `enclosing` is the method the call is
|
|
735
|
+
* written in, which is what tells one body's locals from the next.
|
|
736
|
+
*/
|
|
737
|
+
declare function storageClaims(call: Node, file: string, options: RbStorageOptions, enclosing?: Node | null): boolean;
|
|
738
|
+
/**
|
|
739
|
+
* The database work a body does, one effect per chain. A chain is one thing
|
|
740
|
+
* the code does, so `Order.where(id: 1).first` counts once. `file` is the
|
|
741
|
+
* absolute path the calls were read from, which the constant bindings key on.
|
|
742
|
+
* `enclosing` is the method the calls were read from, or null outside one.
|
|
743
|
+
*/
|
|
744
|
+
declare function storageEffects(calls: readonly Node[], file: string, options: RbStorageOptions, enclosing?: Node | null): Effect[];
|
|
623
745
|
|
|
624
746
|
/** The methods a pack declared the library defines itself, so a receiverless call to one of them is not work the project does. */
|
|
625
747
|
type InheritedMethods = ReadonlySet<string>;
|
|
@@ -985,4 +1107,4 @@ declare function methodDefinitionsIn(file: string, root: Node): Map<string, Node
|
|
|
985
1107
|
*/
|
|
986
1108
|
declare const ADAPTER_VERSION = "0.1.0";
|
|
987
1109
|
|
|
988
|
-
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 FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbBodyBlock, type RbInflections, 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, factsForFile, 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 };
|
|
1110
|
+
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 FileFactsOptions, type GraphqlObjectFields, type GraphqlTypeNameConvention, type MethodLookup, type ParameterBindings, type ProjectNodes, type Range, type RbAddressingCall, type RbArgumentPlace, type RbBodyBlock, type RbInflections, type RbRawSqlPattern, type RbRowCall, type RbStatusCall, type RbStorageOptions, 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, factsForFile, field, findRubyFiles, graphqlTypeNameFromQualified, hashKeySymbolName, inheritedStatements, methodDefinitionsIn, methodInAncestry, nestedStatements, nodeId, parseRuby, parseRubySync, preloadRubyGrammar, qualifyConstantRef, reachDefinition, readCallArgs, readKey, resolveConstantFile, rubyStubEvidence, runStatements, storageClaims, storageEffects, stringLiteralValue, stringValueOf, symbolValue, typeShapeFromNode, underscoreConstantPath, unitKey, walkClasses, walkDefinitions };
|