@eagleoutice/flowr 2.1.11 → 2.1.12

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.
Files changed (62) hide show
  1. package/README.md +1 -0
  2. package/cli/repl/commands/repl-query.js +1 -1
  3. package/cli/repl/server/connection.js +1 -1
  4. package/core/steps/pipeline/default-pipelines.d.ts +6 -0
  5. package/core/steps/pipeline/default-pipelines.js +6 -0
  6. package/dataflow/graph/vertex.d.ts +4 -0
  7. package/dataflow/graph/vertex.js +3 -1
  8. package/documentation/doc-util/doc-dfg.js +1 -1
  9. package/documentation/doc-util/doc-query.js +1 -1
  10. package/documentation/doc-util/doc-search.d.ts +25 -0
  11. package/documentation/doc-util/doc-search.js +121 -0
  12. package/documentation/doc-util/doc-types.d.ts +10 -2
  13. package/documentation/doc-util/doc-types.js +81 -3
  14. package/documentation/print-dataflow-graph-wiki.js +1 -1
  15. package/documentation/print-interface-wiki.js +24 -13
  16. package/documentation/print-normalized-ast-wiki.js +4 -4
  17. package/documentation/print-query-wiki.js +22 -0
  18. package/documentation/print-search-wiki.d.ts +1 -0
  19. package/documentation/print-search-wiki.js +74 -0
  20. package/package.json +2 -1
  21. package/queries/base-query-format.d.ts +2 -2
  22. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  23. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  24. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  25. package/queries/catalog/cluster-query/cluster-query-executor.js +1 -1
  26. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  27. package/queries/catalog/dataflow-query/dataflow-query-executor.js +1 -1
  28. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  29. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  30. package/queries/catalog/lineage-query/lineage-query-executor.js +1 -1
  31. package/queries/catalog/search-query/search-query-executor.d.ts +3 -0
  32. package/queries/catalog/search-query/search-query-executor.js +27 -0
  33. package/queries/catalog/search-query/search-query-format.d.ts +72 -0
  34. package/queries/catalog/search-query/search-query-format.js +29 -0
  35. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  36. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  37. package/queries/query.d.ts +59 -1
  38. package/queries/query.js +3 -1
  39. package/r-bridge/lang-4.x/ast/model/type.d.ts +4 -0
  40. package/r-bridge/lang-4.x/ast/model/type.js +3 -1
  41. package/search/flowr-search-builder.d.ts +193 -0
  42. package/search/flowr-search-builder.js +192 -0
  43. package/search/flowr-search-executor.d.ts +9 -0
  44. package/search/flowr-search-executor.js +16 -0
  45. package/search/flowr-search-filters.d.ts +74 -0
  46. package/search/flowr-search-filters.js +136 -0
  47. package/search/flowr-search-printer.d.ts +10 -0
  48. package/search/flowr-search-printer.js +85 -0
  49. package/search/flowr-search-traverse.d.ts +7 -0
  50. package/search/flowr-search-traverse.js +12 -0
  51. package/search/flowr-search.d.ts +58 -0
  52. package/search/flowr-search.js +29 -0
  53. package/search/search-executor/search-generators.d.ts +37 -0
  54. package/search/search-executor/search-generators.js +64 -0
  55. package/search/search-executor/search-transformer.d.ts +57 -0
  56. package/search/search-executor/search-transformer.js +99 -0
  57. package/search/search-optimizer/search-optimizer.d.ts +9 -0
  58. package/search/search-optimizer/search-optimizer.js +89 -0
  59. package/util/arrays.d.ts +13 -0
  60. package/util/assert.d.ts +1 -1
  61. package/util/mermaid/mermaid.js +17 -0
  62. package/util/version.js +1 -1
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const shell_1 = require("../r-bridge/shell");
7
+ const log_1 = require("../../test/functionality/_helper/log");
8
+ const doc_files_1 = require("./doc-util/doc-files");
9
+ const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
10
+ const doc_search_1 = require("./doc-util/doc-search");
11
+ const flowr_search_builder_1 = require("../search/flowr-search-builder");
12
+ const vertex_1 = require("../dataflow/graph/vertex");
13
+ const doc_types_1 = require("./doc-util/doc-types");
14
+ const path_1 = __importDefault(require("path"));
15
+ async function getText(shell) {
16
+ const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
17
+ const types = (0, doc_types_1.getTypesFromFolderAsMermaid)({
18
+ rootFolder: path_1.default.resolve('./src/search/'),
19
+ typeName: 'FlowrSearchGenerator',
20
+ inlineTypes: doc_types_1.mermaidHide
21
+ });
22
+ return `${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'search API', rVersion: rversion })}
23
+
24
+ This page briefly summarizes flowR's search API which provides a set of functions to search for nodes in the [Dataflow Graph](${doc_files_1.FlowrWikiBaseRef}/Dataflow%20Graph) and the
25
+ [Normalized AST](${doc_files_1.FlowrWikiBaseRef}/Normalized%20AST) of a given R code (the search will always consider both, with respect to your search query).
26
+ Please see the [Interface](${doc_files_1.FlowrWikiBaseRef}/Interface) wiki page for more information on how to access this API.
27
+ Within code, you can execute a search using the ${(0, doc_types_1.shortLink)('runSearch', types.info)} function.
28
+
29
+ For an initial motivation, let's have a look at the following example:
30
+
31
+ ${await (0, doc_search_1.showSearch)(shell, 'x <- x * x', flowr_search_builder_1.Q.var('x'))}
32
+
33
+ This returns all references to the variable \`x\` in the code.
34
+ However, the search API is not limited to simple variable references and can do much more.
35
+
36
+ For example, let's have every definition of \`x\` in the code but the first one:
37
+
38
+ ${await (0, doc_search_1.showSearch)(shell, 'x <- x * x\nprint(x)\nx <- y <- 3\nprint(x)\nx <- 2', flowr_search_builder_1.Q.var('x').filter(vertex_1.VertexType.VariableDefinition).skip(1))}
39
+
40
+ In summary, every search has two parts. It is initialized with a _generator_ (such as \`Q.var('x')\`)
41
+ and can be further refined with _transformers_ or _modifiers_.
42
+ Such queries can be constructed starting from the ${(0, doc_types_1.shortLink)('Q', types.info)} object (backed by ${(0, doc_types_1.shortLink)('FlowrSearchGenerator', types.info)}) and
43
+ are fully serializable so you can use them when communicating with the [Query API](${doc_files_1.FlowrWikiBaseRef}/Query%20API).
44
+
45
+ We offer the following generators:
46
+
47
+ ${Object.keys(flowr_search_builder_1.Q).sort().map(key => `- ${(0, doc_types_1.shortLink)(`FlowrSearchGenerator::${key}`, types.info)}\\\n${(0, doc_types_1.getDocumentationForType)(`FlowrSearchGenerator::${key}`, types.info)}`).join('\n')}
48
+
49
+ Likewise, we have a palette of _transformers_ and _modifiers_:
50
+
51
+ ${
52
+ /* let's iterate over all methods of FlowrSearchBuilder */
53
+ Object.getOwnPropertyNames(Object.getPrototypeOf(new flowr_search_builder_1.FlowrSearchBuilder(undefined)))
54
+ .filter(n => n !== 'constructor').sort().map(key => `- ${(0, doc_types_1.shortLink)(`FlowrSearchBuilder::${key}`, types.info)}\\\n${(0, doc_types_1.getDocumentationForType)(`FlowrSearchBuilder::${key}`, types.info)}`).join('\n')}
55
+
56
+ Every search (and consequently the search pipeline) works with an array of ${(0, doc_types_1.shortLink)('FlowrSearchElement', types.info)} (neatly wrapped in ${(0, doc_types_1.shortLink)('FlowrSearchElements', types.info)}).
57
+ Hence, even operations such as \`.first\` or \`.last\` return an array of elements (albeit with a single or no element).
58
+ The search API does its best to stay typesafe wrt. to the return type and the transformers in use.
59
+ In addition, it offers optimizer passes to optimize the search pipeline before execution.
60
+ They are executed with \`.build\` which may happen automatically, whenever you want to run a search using ${(0, doc_types_1.shortLink)('runSearch', types.info)}.
61
+
62
+ `;
63
+ }
64
+ /** if we run this script, we want a Markdown representation of the capabilities */
65
+ if (require.main === module) {
66
+ (0, log_1.setMinLevelOfAllLogs)(6 /* LogLevel.Fatal */);
67
+ const shell = new shell_1.RShell();
68
+ void getText(shell).then(str => {
69
+ console.log(str);
70
+ }).finally(() => {
71
+ shell.close();
72
+ });
73
+ }
74
+ //# sourceMappingURL=print-search-wiki.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.1.11",
3
+ "version": "2.1.12",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "wiki:df-graph": "ts-node src/documentation/print-dataflow-graph-wiki.ts",
29
29
  "wiki:normalized-ast": "ts-node src/documentation/print-normalized-ast-wiki.ts",
30
30
  "wiki:query-api": "ts-node src/documentation/print-query-wiki.ts",
31
+ "wiki:search-api": "ts-node src/documentation/print-search-wiki.ts",
31
32
  "wiki:linting-and-testing": "ts-node src/documentation/print-linting-and-testing-wiki.ts",
32
33
  "wiki:interface": "ts-node src/documentation/print-interface-wiki.ts",
33
34
  "build": "tsc --project .",
@@ -1,5 +1,5 @@
1
1
  import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
2
- import type { DataflowGraph } from '../dataflow/graph/graph';
2
+ import type { DataflowInformation } from '../dataflow/info';
3
3
  export interface BaseQueryFormat {
4
4
  /** used to select the query type :) */
5
5
  readonly type: string;
@@ -13,5 +13,5 @@ export interface BaseQueryResult {
13
13
  }
14
14
  export interface BasicQueryData {
15
15
  readonly ast: NormalizedAst;
16
- readonly graph: DataflowGraph;
16
+ readonly dataflow: DataflowInformation;
17
17
  }
@@ -9,4 +9,4 @@ import type { BasicQueryData } from '../../base-query-format';
9
9
  * This happens during the main resolution!
10
10
  * 4. Attach `linkTo` calls to the respective calls.
11
11
  */
12
- export declare function executeCallContextQueries({ graph, ast }: BasicQueryData, queries: readonly CallContextQuery[]): CallContextQueryResult;
12
+ export declare function executeCallContextQueries({ dataflow: { graph }, ast }: BasicQueryData, queries: readonly CallContextQuery[]): CallContextQueryResult;
@@ -158,7 +158,7 @@ function doesFilepathMatch(file, filter) {
158
158
  * This happens during the main resolution!
159
159
  * 4. Attach `linkTo` calls to the respective calls.
160
160
  */
161
- function executeCallContextQueries({ graph, ast }, queries) {
161
+ function executeCallContextQueries({ dataflow: { graph }, ast }, queries) {
162
162
  /* omit performance page load */
163
163
  const now = Date.now();
164
164
  /* the node id and call targets if present */
@@ -1,3 +1,3 @@
1
1
  import type { DataflowClusterQuery, DataflowClusterQueryResult } from './cluster-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
- export declare function executeDataflowClusterQuery({ graph }: BasicQueryData, queries: readonly DataflowClusterQuery[]): DataflowClusterQueryResult;
3
+ export declare function executeDataflowClusterQuery({ dataflow: { graph } }: BasicQueryData, queries: readonly DataflowClusterQuery[]): DataflowClusterQueryResult;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeDataflowClusterQuery = executeDataflowClusterQuery;
4
4
  const log_1 = require("../../../util/log");
5
5
  const cluster_1 = require("../../../dataflow/cluster");
6
- function executeDataflowClusterQuery({ graph }, queries) {
6
+ function executeDataflowClusterQuery({ dataflow: { graph } }, queries) {
7
7
  if (queries.length !== 1) {
8
8
  log_1.log.warn('The dataflow cluster query expects only up to one query, but got', queries.length);
9
9
  }
@@ -1,3 +1,3 @@
1
1
  import type { DataflowQuery, DataflowQueryResult } from './dataflow-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
- export declare function executeDataflowQuery({ graph }: BasicQueryData, queries: readonly DataflowQuery[]): DataflowQueryResult;
3
+ export declare function executeDataflowQuery({ dataflow: { graph } }: BasicQueryData, queries: readonly DataflowQuery[]): DataflowQueryResult;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeDataflowQuery = executeDataflowQuery;
4
4
  const log_1 = require("../../../util/log");
5
- function executeDataflowQuery({ graph }, queries) {
5
+ function executeDataflowQuery({ dataflow: { graph } }, queries) {
6
6
  if (queries.length !== 1) {
7
7
  log_1.log.warn('Dataflow query expects only up to one query, but got', queries.length);
8
8
  }
@@ -83,7 +83,7 @@ function makeCallContextQuery(functions, kind) {
83
83
  }
84
84
  function getResults(data, results, kind, functions, makeInfo, additionalAllowedTypes) {
85
85
  return Object.entries(results?.kinds[kind]?.subkinds ?? {}).flatMap(([name, results]) => results.flatMap(({ id, linkedIds }) => {
86
- const vertex = data.graph.getVertex(id);
86
+ const vertex = data.dataflow.graph.getVertex(id);
87
87
  const info = functions.find(f => f.name === name);
88
88
  let index = info.argIdx;
89
89
  if (info.argName) {
@@ -99,7 +99,7 @@ function getResults(data, results, kind, functions, makeInfo, additionalAllowedT
99
99
  return args.flatMap(a => (0, objects_1.compactRecord)(makeInfo(id, vertex, a, linkedIds)));
100
100
  })).filter(assert_1.isNotUndefined) ?? [];
101
101
  }
102
- function getArgumentValue({ graph }, vertex, argumentIndex, additionalAllowedTypes) {
102
+ function getArgumentValue({ dataflow: { graph } }, vertex, argumentIndex, additionalAllowedTypes) {
103
103
  if (vertex) {
104
104
  if (argumentIndex === 'unnamed') {
105
105
  // return all unnamed arguments
@@ -1,3 +1,3 @@
1
1
  import type { LineageQuery, LineageQueryResult } from './lineage-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
- export declare function executeLineageQuery({ graph, ast }: BasicQueryData, queries: readonly LineageQuery[]): LineageQueryResult;
3
+ export declare function executeLineageQuery({ dataflow: { graph }, ast }: BasicQueryData, queries: readonly LineageQuery[]): LineageQueryResult;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeLineageQuery = executeLineageQuery;
4
4
  const log_1 = require("../../../util/log");
5
5
  const repl_lineage_1 = require("../../../cli/repl/commands/repl-lineage");
6
- function executeLineageQuery({ graph, ast }, queries) {
6
+ function executeLineageQuery({ dataflow: { graph }, ast }, queries) {
7
7
  const start = Date.now();
8
8
  const result = {};
9
9
  for (const { criterion } of queries) {
@@ -0,0 +1,3 @@
1
+ import type { BasicQueryData } from '../../base-query-format';
2
+ import type { SearchQuery, SearchQueryResult } from './search-query-format';
3
+ export declare function executeSearch({ ast, dataflow }: BasicQueryData, queries: readonly SearchQuery[]): SearchQueryResult;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeSearch = executeSearch;
4
+ const log_1 = require("../../../util/log");
5
+ const flowr_search_executor_1 = require("../../../search/flowr-search-executor");
6
+ function executeSearch({ ast, dataflow }, queries) {
7
+ const start = Date.now();
8
+ if (queries.length !== 1) {
9
+ log_1.log.warn('Id-Map query expects only up to one query, but got', queries.length);
10
+ }
11
+ const results = [];
12
+ for (const query of queries) {
13
+ const { search } = query;
14
+ results.push({
15
+ ids: (0, flowr_search_executor_1.runSearch)(search, { normalize: ast, dataflow })
16
+ .map(({ node }) => node.info.id),
17
+ search
18
+ });
19
+ }
20
+ return {
21
+ '.meta': {
22
+ timing: Date.now() - start
23
+ },
24
+ results
25
+ };
26
+ }
27
+ //# sourceMappingURL=search-query-executor.js.map
@@ -0,0 +1,72 @@
1
+ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
+ import Joi from 'joi';
3
+ import type { FlowrSearch } from '../../../search/flowr-search-builder';
4
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
+ import { executeSearch } from './search-query-executor';
6
+ export interface SearchQuery extends BaseQueryFormat {
7
+ readonly type: 'search';
8
+ readonly search: FlowrSearch;
9
+ }
10
+ export interface SearchQueryResult extends BaseQueryResult {
11
+ readonly results: {
12
+ ids: NodeId[];
13
+ search: FlowrSearch;
14
+ }[];
15
+ }
16
+ export declare const SearchQueryDefinition: {
17
+ readonly executor: typeof executeSearch;
18
+ readonly asciiSummarizer: (formatter: import("../../../util/ansi").OutputFormatter, _processed: import("../../../core/steps/pipeline/pipeline").PipelineOutput<import("../../../core/steps/pipeline/pipeline").Pipeline<{
19
+ readonly name: "parse";
20
+ readonly humanReadableName: "parse with R shell";
21
+ readonly description: "Parse the given R code into an AST";
22
+ readonly processor: (_results: unknown, input: Partial<import("../../../core/steps/all/core/00-parse").ParseRequiredInput>) => Promise<import("../../../core/steps/all/core/00-parse").ParseStepOutput>;
23
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
24
+ readonly printer: {
25
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
26
+ readonly 2: {
27
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
28
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
29
+ };
30
+ readonly 5: ({ parsed }: import("../../../core/steps/all/core/00-parse").ParseStepOutput, config: import("../../../util/quads").QuadSerializationConfiguration) => string;
31
+ };
32
+ readonly dependencies: readonly [];
33
+ readonly requiredInput: import("../../../core/steps/all/core/00-parse").ParseRequiredInput;
34
+ } | {
35
+ readonly name: "normalize";
36
+ readonly humanReadableName: "normalize";
37
+ readonly description: "Normalize the AST to flowR's AST";
38
+ readonly processor: (results: {
39
+ parse?: import("../../../core/steps/all/core/00-parse").ParseStepOutput;
40
+ }, input: Partial<import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../r-bridge/lang-4.x/ast/model/model").RNode<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
41
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
42
+ readonly printer: {
43
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
44
+ readonly 2: typeof import("../../../core/print/normalize-printer").normalizedAstToJson;
45
+ readonly 5: typeof import("../../../core/print/normalize-printer").normalizedAstToQuads;
46
+ readonly 3: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaid;
47
+ readonly 4: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
48
+ };
49
+ readonly dependencies: readonly ["parse"];
50
+ readonly requiredInput: import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput;
51
+ } | {
52
+ readonly humanReadableName: "dataflow";
53
+ readonly processor: (results: {
54
+ normalize?: import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
55
+ }, input: {
56
+ request?: import("../../../r-bridge/retriever").RParseRequests;
57
+ }) => import("../../../dataflow/info").DataflowInformation;
58
+ readonly requiredInput: {};
59
+ readonly name: "dataflow";
60
+ readonly description: "Construct the dataflow graph";
61
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
62
+ readonly printer: {
63
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
64
+ readonly 2: typeof import("../../../core/print/dataflow-printer").dataflowGraphToJson;
65
+ readonly 5: typeof import("../../../core/print/dataflow-printer").dataflowGraphToQuads;
66
+ readonly 3: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaid;
67
+ readonly 4: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
68
+ };
69
+ readonly dependencies: readonly ["normalize"];
70
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
71
+ readonly schema: Joi.ObjectSchema<any>;
72
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SearchQueryDefinition = void 0;
7
+ const ansi_1 = require("../../../util/ansi");
8
+ const time_1 = require("../../../util/time");
9
+ const joi_1 = __importDefault(require("joi"));
10
+ const query_print_1 = require("../../query-print");
11
+ const search_query_executor_1 = require("./search-query-executor");
12
+ const flowr_search_printer_1 = require("../../../search/flowr-search-printer");
13
+ const mermaid_1 = require("../../../util/mermaid/mermaid");
14
+ exports.SearchQueryDefinition = {
15
+ executor: search_query_executor_1.executeSearch,
16
+ asciiSummarizer: (formatter, _processed, queryResults, result) => {
17
+ const out = queryResults;
18
+ result.push(`Query: ${(0, ansi_1.bold)('search', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
19
+ for (const [, { ids, search }] of out.results.entries()) {
20
+ result.push(` ╰ [query](${(0, mermaid_1.mermaidCodeToUrl)((0, flowr_search_printer_1.flowrSearchToMermaid)(search))}): {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, ids)}}`);
21
+ }
22
+ return true;
23
+ },
24
+ schema: joi_1.default.object({
25
+ type: joi_1.default.string().valid('search').required().description('The type of the query.'),
26
+ search: joi_1.default.object().required().description('The search query to execute.')
27
+ }).description('The id map query retrieves the id map from the normalized AST.')
28
+ };
29
+ //# sourceMappingURL=search-query-format.js.map
@@ -1,4 +1,4 @@
1
1
  import type { StaticSliceQuery, StaticSliceQueryResult } from './static-slice-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
3
  export declare function fingerPrintOfQuery(query: StaticSliceQuery): string;
4
- export declare function executeStaticSliceQuery({ graph, ast }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
4
+ export declare function executeStaticSliceQuery({ dataflow: { graph }, ast }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
@@ -10,7 +10,7 @@ const log_1 = require("../../../util/log");
10
10
  function fingerPrintOfQuery(query) {
11
11
  return JSON.stringify(query);
12
12
  }
13
- function executeStaticSliceQuery({ graph, ast }, queries) {
13
+ function executeStaticSliceQuery({ dataflow: { graph }, ast }, queries) {
14
14
  const start = Date.now();
15
15
  const results = {};
16
16
  for (const query of queries) {
@@ -15,7 +15,8 @@ import type { DEFAULT_DATAFLOW_PIPELINE } from '../core/steps/pipeline/default-p
15
15
  import Joi from 'joi';
16
16
  import type { LocationMapQuery } from './catalog/location-map-query/location-map-query-format';
17
17
  import type { ConfigQuery } from './catalog/config-query/config-query-format';
18
- export type Query = CallContextQuery | ConfigQuery | DataflowQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery;
18
+ import type { SearchQuery } from './catalog/search-query/search-query-format';
19
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery;
19
20
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
20
21
  type: QueryType;
21
22
  };
@@ -443,6 +444,63 @@ export declare const SupportedQueries: {
443
444
  readonly asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => boolean;
444
445
  readonly schema: Joi.ObjectSchema<any>;
445
446
  };
447
+ readonly search: {
448
+ readonly executor: typeof import("./catalog/search-query/search-query-executor").executeSearch;
449
+ readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
450
+ readonly name: "parse";
451
+ readonly humanReadableName: "parse with R shell";
452
+ readonly description: "Parse the given R code into an AST";
453
+ readonly processor: (_results: unknown, input: Partial<import("../core/steps/all/core/00-parse").ParseRequiredInput>) => Promise<import("../core/steps/all/core/00-parse").ParseStepOutput>;
454
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
455
+ readonly printer: {
456
+ readonly 0: typeof import("../core/print/print").internalPrinter;
457
+ readonly 2: {
458
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
459
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
460
+ };
461
+ readonly 5: ({ parsed }: import("../core/steps/all/core/00-parse").ParseStepOutput, config: import("../util/quads").QuadSerializationConfiguration) => string;
462
+ };
463
+ readonly dependencies: readonly [];
464
+ readonly requiredInput: import("../core/steps/all/core/00-parse").ParseRequiredInput;
465
+ } | {
466
+ readonly name: "normalize";
467
+ readonly humanReadableName: "normalize";
468
+ readonly description: "Normalize the AST to flowR's AST";
469
+ readonly processor: (results: {
470
+ parse?: import("../core/steps/all/core/00-parse").ParseStepOutput;
471
+ }, input: Partial<import("../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../r-bridge/lang-4.x/ast/model/model").RNode<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
472
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
473
+ readonly printer: {
474
+ readonly 0: typeof import("../core/print/print").internalPrinter;
475
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
476
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
477
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
478
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
479
+ };
480
+ readonly dependencies: readonly ["parse"];
481
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
482
+ } | {
483
+ readonly humanReadableName: "dataflow";
484
+ readonly processor: (results: {
485
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
486
+ }, input: {
487
+ request?: import("../r-bridge/retriever").RParseRequests;
488
+ }) => import("../dataflow/info").DataflowInformation;
489
+ readonly requiredInput: {};
490
+ readonly name: "dataflow";
491
+ readonly description: "Construct the dataflow graph";
492
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
493
+ readonly printer: {
494
+ readonly 0: typeof import("../core/print/print").internalPrinter;
495
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
496
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
497
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
498
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
499
+ };
500
+ readonly dependencies: readonly ["normalize"];
501
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
502
+ readonly schema: Joi.ObjectSchema<any>;
503
+ };
446
504
  };
447
505
  export type SupportedQueryTypes = keyof typeof SupportedQueries;
448
506
  export type QueryResult<Type extends Query['type']> = ReturnType<typeof SupportedQueries[Type]['executor']>;
package/queries/query.js CHANGED
@@ -23,6 +23,7 @@ const dependencies_query_format_1 = require("./catalog/dependencies-query/depend
23
23
  const joi_1 = __importDefault(require("joi"));
24
24
  const location_map_query_format_1 = require("./catalog/location-map-query/location-map-query-format");
25
25
  const config_query_format_1 = require("./catalog/config-query/config-query-format");
26
+ const search_query_format_1 = require("./catalog/search-query/search-query-format");
26
27
  exports.SupportedQueries = {
27
28
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
28
29
  'config': config_query_format_1.ConfigQueryDefinition,
@@ -33,7 +34,8 @@ exports.SupportedQueries = {
33
34
  'static-slice': static_slice_query_format_1.StaticSliceQueryDefinition,
34
35
  'lineage': lineage_query_format_1.LineageQueryDefinition,
35
36
  'dependencies': dependencies_query_format_1.DependenciesQueryDefinition,
36
- 'location-map': location_map_query_format_1.LocationMapQueryDefinition
37
+ 'location-map': location_map_query_format_1.LocationMapQueryDefinition,
38
+ 'search': search_query_format_1.SearchQueryDefinition
37
39
  };
38
40
  function executeQueriesOfSameType(data, ...queries) {
39
41
  (0, assert_1.guard)(queries.length > 0, 'At least one query must be provided');
@@ -204,6 +204,10 @@ export declare enum RType {
204
204
  */
205
205
  Delimiter = "RDelimiter"
206
206
  }
207
+ export declare const ValidRTypes: Set<string>;
208
+ export declare const ValidRTypesReverse: {
209
+ [k: string]: string;
210
+ };
207
211
  /**
208
212
  * Validates, whether the given type can be used as a symbol in R
209
213
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RType = exports.RawRType = void 0;
3
+ exports.ValidRTypesReverse = exports.ValidRTypes = exports.RType = exports.RawRType = void 0;
4
4
  exports.isSymbol = isSymbol;
5
5
  /**
6
6
  * Token types as they are produced by the R parser.
@@ -211,6 +211,8 @@ var RType;
211
211
  */
212
212
  RType["Delimiter"] = "RDelimiter";
213
213
  })(RType || (exports.RType = RType = {}));
214
+ exports.ValidRTypes = new Set(Object.values(RType));
215
+ exports.ValidRTypesReverse = Object.fromEntries(Object.entries(RType).map(([k, v]) => [v, k]));
214
216
  const validSymbolTypes = new Set([
215
217
  RawRType.Symbol,
216
218
  RawRType.SymbolPackage,