Skip to content

Commit

Permalink
Add AccessPathSuggestions to "models as data" model (#3295)
Browse files Browse the repository at this point in the history
  • Loading branch information
shati-patel authored Jan 31, 2024
1 parent 8c679ab commit 841efbf
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import type {
import type { DataTuple } from "../model-extension-file";
import type { Mode } from "../shared/mode";
import type { QueryConstraints } from "../../local-queries/query-constraints";
import type { DecodedBqrs } from "../../common/bqrs-cli-types";
import type {
DecodedBqrs,
DecodedBqrsChunk,
} from "../../common/bqrs-cli-types";
import type { BaseLogger } from "../../common/logging";
import type { AccessPathSuggestionRow } from "../suggestions";

type GenerateMethodDefinition<T> = (method: T) => DataTuple[];
type ReadModeledMethod = (row: DataTuple[]) => ModeledMethod;
Expand Down Expand Up @@ -39,6 +43,18 @@ type ModelsAsDataLanguageModelGeneration = {
) => ModeledMethod[];
};

type ModelsAsDataLanguageAccessPathSuggestions = {
parseResults: (
// The results of a single predicate of the query.
bqrs: DecodedBqrsChunk,
// The language-specific predicate that was used to generate the results. This is passed to allow
// sharing of code between different languages.
modelsAsDataLanguage: ModelsAsDataLanguage,
// The logger to use for logging.
logger: BaseLogger,
) => AccessPathSuggestionRow[];
};

export type ModelsAsDataLanguagePredicates = {
source?: ModelsAsDataLanguagePredicate<SourceModeledMethod>;
sink?: ModelsAsDataLanguagePredicate<SinkModeledMethod>;
Expand All @@ -61,6 +77,7 @@ export type ModelsAsDataLanguage = {
createMethodSignature: (method: MethodDefinition) => string;
predicates: ModelsAsDataLanguagePredicates;
modelGeneration?: ModelsAsDataLanguageModelGeneration;
accessPathSuggestions?: ModelsAsDataLanguageAccessPathSuggestions;
/**
* Returns the list of valid arguments that can be selected for the given method.
* @param method The method to get the valid arguments for.
Expand Down

0 comments on commit 841efbf

Please sign in to comment.