patram 0.8.0 → 0.10.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/bin/patram.js +2 -2
- package/lib/cli/arguments.types.d.ts +63 -0
- package/lib/{parse-cli-color-options.js → cli/color-options.js} +2 -2
- package/lib/cli/command-helpers.js +35 -0
- package/lib/cli/commands/check.js +73 -0
- package/lib/cli/commands/fields.js +57 -0
- package/lib/cli/commands/queries.js +41 -0
- package/lib/cli/commands/query.js +242 -0
- package/lib/cli/commands/refs.js +72 -0
- package/lib/cli/commands/show.js +58 -0
- package/lib/{cli-help-metadata.js → cli/help-metadata.js} +7 -102
- package/lib/cli/main.js +76 -0
- package/lib/{parse-cli-arguments-helpers.js → cli/parse-arguments-helpers.js} +24 -12
- package/lib/{parse-cli-arguments.js → cli/parse-arguments.js} +12 -12
- package/lib/{parse-cli-query-pagination.js → cli/query-pagination.js} +2 -2
- package/lib/{render-cli-help.js → cli/render-help.js} +84 -3
- package/lib/{resolve-output-mode.js → cli/resolve-output-mode.js} +2 -2
- package/lib/cli/test-helpers.js +30 -0
- package/lib/config/defaults.d.ts +10 -0
- package/lib/config/defaults.js +80 -0
- package/lib/config/load-patram-config.d.ts +76 -0
- package/lib/config/load-patram-config.js +315 -0
- package/lib/config/load-patram-config.types.d.ts +45 -0
- package/lib/{patram-config.d.ts → config/patram-config.d.ts} +31 -31
- package/lib/{patram-config.js → config/patram-config.js} +3 -3
- package/lib/{patram-config.types.d.ts → config/patram-config.types.d.ts} +1 -1
- package/lib/{resolve-patram-graph-config.d.ts → config/resolve-patram-graph-config.d.ts} +2 -2
- package/lib/{resolve-patram-graph-config.js → config/resolve-patram-graph-config.js} +3 -3
- package/lib/{load-patram-config.d.ts → config/schema.d.ts} +149 -191
- package/lib/config/schema.js +328 -0
- package/lib/{source-file-defaults.d.ts → config/source-file-defaults.d.ts} +0 -1
- package/lib/{source-file-defaults.js → config/source-file-defaults.js} +1 -1
- package/lib/config/validation.d.ts +27 -0
- package/lib/config/validation.js +615 -0
- package/lib/directive-validation-test-helpers.js +1 -1
- package/lib/find-close-match.d.ts +8 -0
- package/lib/find-close-match.js +98 -0
- package/lib/{build-graph-identity.d.ts → graph/build-graph-identity.d.ts} +2 -2
- package/lib/{build-graph-identity.js → graph/build-graph-identity.js} +1 -1
- package/lib/{build-graph.d.ts → graph/build-graph.d.ts} +3 -3
- package/lib/{build-graph.js → graph/build-graph.js} +17 -13
- package/lib/{build-graph.types.d.ts → graph/build-graph.types.d.ts} +1 -1
- package/lib/graph/check-directive-metadata.d.ts +23 -0
- package/lib/{check-directive-metadata.js → graph/check-directive-metadata.js} +7 -7
- package/lib/graph/check-directive-path-target.d.ts +32 -0
- package/lib/{check-directive-path-target.js → graph/check-directive-path-target.js} +4 -4
- package/lib/graph/check-directive-value.d.ts +19 -0
- package/lib/{check-directive-value.js → graph/check-directive-value.js} +3 -3
- package/lib/graph/check-graph.d.ts +29 -0
- package/lib/{check-graph.js → graph/check-graph.js} +6 -6
- package/lib/graph/directive-diagnostics.d.ts +20 -0
- package/lib/{directive-diagnostics.js → graph/directive-diagnostics.js} +2 -2
- package/lib/graph/directive-type-rules.d.ts +18 -0
- package/lib/{directive-type-rules.js → graph/directive-type-rules.js} +3 -3
- package/lib/{document-node-identity.d.ts → graph/document-node-identity.d.ts} +2 -2
- package/lib/{document-node-identity.js → graph/document-node-identity.js} +2 -2
- package/lib/graph/inspect-reverse-references.d.ts +22 -0
- package/lib/{inspect-reverse-references.js → graph/inspect-reverse-references.js} +2 -2
- package/lib/{load-project-graph.d.ts → graph/load-project-graph.d.ts} +10 -10
- package/lib/{load-project-graph.js → graph/load-project-graph.js} +12 -12
- package/lib/{parse-where-clause.types.d.ts → graph/parse-where-clause.types.d.ts} +1 -1
- package/lib/{query-graph.d.ts → graph/query/execute.d.ts} +11 -11
- package/lib/{query-graph.js → graph/query/execute.js} +12 -12
- package/lib/{query-inspection.d.ts → graph/query/inspect.d.ts} +10 -8
- package/lib/{query-inspection.js → graph/query/inspect.js} +16 -17
- package/lib/{parse-where-clause.d.ts → graph/query/parse.d.ts} +6 -6
- package/lib/{parse-where-clause.js → graph/query/parse.js} +2 -2
- package/lib/graph/query/resolve.d.ts +28 -0
- package/lib/{resolve-where-clause.js → graph/query/resolve.js} +39 -5
- package/lib/graph/reverse-reference-test-helpers.d.ts +55 -0
- package/lib/{command-output.js → output/command-output.js} +5 -5
- package/lib/{derived-summary.js → output/derived-summary.js} +7 -7
- package/lib/{layout-incoming-references.js → output/layout-incoming-references.js} +4 -4
- package/lib/{layout-incoming-summary-lines.js → output/layout-incoming-summary-lines.js} +0 -5
- package/lib/{layout-stored-queries.js → output/layout-stored-queries.js} +27 -11
- package/lib/{list-queries.js → output/list-queries.js} +3 -2
- package/lib/{render-check-output.js → output/render-check-output.js} +1 -1
- package/lib/{render-field-discovery.js → output/render-field-discovery.js} +3 -3
- package/lib/output/render-output-view.js +56 -0
- package/lib/{render-json-output.js → output/renderers/json.js} +10 -6
- package/lib/{render-plain-output.js → output/renderers/plain.js} +34 -33
- package/lib/{render-rich-output.js → output/renderers/rich.js} +44 -32
- package/lib/{resolve-check-target.js → output/resolve-check-target.js} +1 -1
- package/lib/{render-rich-source.js → output/rich-source/render.js} +6 -6
- package/lib/{show-document.js → output/show-document.js} +12 -12
- package/lib/{render-output-view.js → output/view-model/index.js} +11 -70
- package/lib/{write-paged-output.js → output/write-paged-output.js} +9 -5
- package/lib/{claim-helpers.d.ts → parse/claim-helpers.d.ts} +2 -2
- package/lib/{parse-jsdoc-claims.d.ts → parse/jsdoc/parse-jsdoc-claims.d.ts} +2 -2
- package/lib/{parse-jsdoc-claims.js → parse/jsdoc/parse-jsdoc-claims.js} +9 -9
- package/lib/{parse-jsdoc-prose.d.ts → parse/jsdoc/parse-jsdoc-prose.d.ts} +1 -1
- package/lib/{parse-jsdoc-prose.js → parse/jsdoc/parse-jsdoc-prose.js} +1 -1
- package/lib/{parse-markdown-claims.d.ts → parse/markdown/parse-markdown-claims.d.ts} +3 -3
- package/lib/{parse-markdown-claims.js → parse/markdown/parse-markdown-claims.js} +8 -8
- package/lib/{parse-markdown-directives.d.ts → parse/markdown/parse-markdown-directives.d.ts} +2 -2
- package/lib/{parse-markdown-directives.js → parse/markdown/parse-markdown-directives.js} +3 -3
- package/lib/{parse-claims.d.ts → parse/parse-claims.d.ts} +4 -13
- package/lib/{parse-claims.js → parse/parse-claims.js} +18 -26
- package/lib/{parse-claims.types.d.ts → parse/parse-claims.types.d.ts} +1 -1
- package/lib/{tagged-fenced-block-error.d.ts → parse/tagged-fenced/tagged-fenced-block-error.d.ts} +2 -2
- package/lib/{tagged-fenced-block-parser.d.ts → parse/tagged-fenced/tagged-fenced-block-parser.d.ts} +3 -3
- package/lib/{tagged-fenced-blocks.d.ts → parse/tagged-fenced/tagged-fenced-blocks.d.ts} +7 -7
- package/lib/{tagged-fenced-blocks.js → parse/tagged-fenced/tagged-fenced-blocks.js} +3 -3
- package/lib/{parse-yaml-claims.d.ts → parse/yaml/parse-yaml-claims.d.ts} +4 -4
- package/lib/{parse-yaml-claims.js → parse/yaml/parse-yaml-claims.js} +22 -13
- package/lib/patram.d.ts +29 -28
- package/lib/patram.js +5 -6
- package/lib/{discover-fields.js → scan/discover-fields.js} +145 -18
- package/lib/scan/list-repo-files.d.ts +16 -0
- package/lib/{list-source-files.js → scan/list-repo-files.js} +2 -35
- package/lib/{list-source-files.d.ts → scan/list-source-files.d.ts} +4 -11
- package/lib/scan/list-source-files.js +45 -0
- package/package.json +8 -7
- package/lib/build-graph.types.ts +0 -27
- package/lib/discover-fields.types.ts +0 -52
- package/lib/load-patram-config.js +0 -1215
- package/lib/load-patram-config.types.d.ts +0 -45
- package/lib/load-patram-config.types.ts +0 -56
- package/lib/output-view.types.d.ts +0 -88
- package/lib/output-view.types.ts +0 -113
- package/lib/overlay-graph.d.ts +0 -43
- package/lib/overlay-graph.js +0 -191
- package/lib/parse-claims.types.ts +0 -41
- package/lib/parse-cli-arguments.types.ts +0 -75
- package/lib/parse-where-clause.types.ts +0 -87
- package/lib/patram-cli.js +0 -593
- package/lib/patram-config.types.ts +0 -22
- package/lib/tagged-fenced-blocks.types.ts +0 -38
- /package/lib/{reverse-reference-test-helpers.js → graph/reverse-reference-test-helpers.js} +0 -0
- /package/lib/{format-derived-summary-row.js → output/format-derived-summary-row.js} +0 -0
- /package/lib/{format-node-header.js → output/format-node-header.js} +0 -0
- /package/lib/{format-output-item-block.js → output/format-output-item-block.js} +0 -0
- /package/lib/{format-output-metadata.js → output/format-output-metadata.js} +0 -0
- /package/lib/{claim-helpers.js → parse/claim-helpers.js} +0 -0
- /package/lib/{parse-jsdoc-blocks.d.ts → parse/jsdoc/parse-jsdoc-blocks.d.ts} +0 -0
- /package/lib/{parse-jsdoc-blocks.js → parse/jsdoc/parse-jsdoc-blocks.js} +0 -0
- /package/lib/{tagged-fenced-block-error.js → parse/tagged-fenced/tagged-fenced-block-error.js} +0 -0
- /package/lib/{tagged-fenced-block-markdown.d.ts → parse/tagged-fenced/tagged-fenced-block-markdown.d.ts} +0 -0
- /package/lib/{tagged-fenced-block-markdown.js → parse/tagged-fenced/tagged-fenced-block-markdown.js} +0 -0
- /package/lib/{tagged-fenced-block-metadata.d.ts → parse/tagged-fenced/tagged-fenced-block-metadata.d.ts} +0 -0
- /package/lib/{tagged-fenced-block-metadata.js → parse/tagged-fenced/tagged-fenced-block-metadata.js} +0 -0
- /package/lib/{tagged-fenced-block-parser.js → parse/tagged-fenced/tagged-fenced-block-parser.js} +0 -0
- /package/lib/{tagged-fenced-blocks.types.d.ts → parse/tagged-fenced/tagged-fenced-blocks.types.d.ts} +0 -0
|
@@ -39,14 +39,14 @@ export function queryGraph(graph: BuildGraphResult, where_clause: string, repo_c
|
|
|
39
39
|
*
|
|
40
40
|
* Kind: graph
|
|
41
41
|
* Status: active
|
|
42
|
-
* Uses Term:
|
|
43
|
-
* Uses Term:
|
|
44
|
-
* Tracked in:
|
|
45
|
-
* Decided by:
|
|
46
|
-
* Implements:
|
|
42
|
+
* Uses Term: ../../../docs/reference/terms/graph.md
|
|
43
|
+
* Uses Term: ../../../docs/reference/terms/query.md
|
|
44
|
+
* Tracked in: ../../../docs/plans/v0/source-anchor-dogfooding.md
|
|
45
|
+
* Decided by: ../../../docs/decisions/query-language.md
|
|
46
|
+
* Implements: ../../../docs/tasks/v0/query-command.md
|
|
47
47
|
* @patram
|
|
48
|
-
* @see {@link
|
|
49
|
-
* @see {@link ../
|
|
48
|
+
* @see {@link ../../../docs/decisions/query-language.md}
|
|
49
|
+
* @see {@link ../load-project-graph.js}
|
|
50
50
|
*/
|
|
51
51
|
export const DEFAULT_QUERY_LIMIT: 25;
|
|
52
52
|
export type RelationIndexes = {
|
|
@@ -62,7 +62,7 @@ export type EvaluationContext = {
|
|
|
62
62
|
nodes: BuildGraphResult["nodes"];
|
|
63
63
|
relation_indexes: RelationIndexes;
|
|
64
64
|
};
|
|
65
|
-
import type { BuildGraphResult } from '
|
|
66
|
-
import type { PatramRepoConfig } from '
|
|
67
|
-
import type { PatramDiagnostic } from '
|
|
68
|
-
import type { GraphNode } from '
|
|
65
|
+
import type { BuildGraphResult } from '../build-graph.types.d.ts';
|
|
66
|
+
import type { PatramRepoConfig } from '../../config/load-patram-config.types.d.ts';
|
|
67
|
+
import type { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
68
|
+
import type { GraphNode } from '../build-graph.types.d.ts';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
/**
|
|
3
|
-
* @import { BuildGraphResult, GraphNode } from '
|
|
4
|
-
* @import { PatramDiagnostic, PatramRepoConfig } from '
|
|
3
|
+
* @import { BuildGraphResult, GraphNode } from '../build-graph.types.ts';
|
|
4
|
+
* @import { PatramDiagnostic, PatramRepoConfig } from '../../config/load-patram-config.types.ts';
|
|
5
5
|
* @import {
|
|
6
6
|
* ParsedAggregateTerm,
|
|
7
7
|
* ParsedExpression,
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* ParsedRelationTargetTerm,
|
|
11
11
|
* ParsedTerm,
|
|
12
12
|
* ParsedTraversalTerm,
|
|
13
|
-
* } from '
|
|
13
|
+
* } from '../parse-where-clause.types.ts';
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { parseWhereClause } from './parse
|
|
17
|
-
import { getQuerySemanticDiagnostics } from './
|
|
16
|
+
import { parseWhereClause } from './parse.js';
|
|
17
|
+
import { getQuerySemanticDiagnostics } from './inspect.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Query graph filtering.
|
|
@@ -24,14 +24,14 @@ import { getQuerySemanticDiagnostics } from './query-inspection.js';
|
|
|
24
24
|
*
|
|
25
25
|
* Kind: graph
|
|
26
26
|
* Status: active
|
|
27
|
-
* Uses Term:
|
|
28
|
-
* Uses Term:
|
|
29
|
-
* Tracked in:
|
|
30
|
-
* Decided by:
|
|
31
|
-
* Implements:
|
|
27
|
+
* Uses Term: ../../../docs/reference/terms/graph.md
|
|
28
|
+
* Uses Term: ../../../docs/reference/terms/query.md
|
|
29
|
+
* Tracked in: ../../../docs/plans/v0/source-anchor-dogfooding.md
|
|
30
|
+
* Decided by: ../../../docs/decisions/query-language.md
|
|
31
|
+
* Implements: ../../../docs/tasks/v0/query-command.md
|
|
32
32
|
* @patram
|
|
33
|
-
* @see {@link
|
|
34
|
-
* @see {@link ../
|
|
33
|
+
* @see {@link ../../../docs/decisions/query-language.md}
|
|
34
|
+
* @see {@link ../load-project-graph.js}
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
export const DEFAULT_QUERY_LIMIT = 25;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {{ kind: 'ad_hoc' } | { kind: 'stored_query', name: string }} QuerySource
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* @typedef {import('
|
|
5
|
+
* @typedef {import('../parse-where-clause.types.d.ts').ParsedFieldTerm | import('../parse-where-clause.types.d.ts').ParsedFieldSetTerm} FieldDiagnosticTerm
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {{ query_source: QuerySource, where_clause: string }} ResolvedWhereClause
|
|
@@ -41,10 +41,13 @@ export function inspectQuery(repo_config: PatramRepoConfig, resolved_where_claus
|
|
|
41
41
|
* Render a successful query inspection in one output mode.
|
|
42
42
|
*
|
|
43
43
|
* @param {QueryInspectionSuccess} query_inspection
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {{ color_enabled: boolean, renderer_name: 'json' | 'plain' | 'rich' }} output_mode
|
|
45
45
|
* @returns {string}
|
|
46
46
|
*/
|
|
47
|
-
export function renderQueryInspection(query_inspection: QueryInspectionSuccess, output_mode:
|
|
47
|
+
export function renderQueryInspection(query_inspection: QueryInspectionSuccess, output_mode: {
|
|
48
|
+
color_enabled: boolean;
|
|
49
|
+
renderer_name: "json" | "plain" | "rich";
|
|
50
|
+
}): string;
|
|
48
51
|
/**
|
|
49
52
|
* Collect schema-aware diagnostics for one parsed where clause.
|
|
50
53
|
*
|
|
@@ -60,7 +63,7 @@ export type QuerySource = {
|
|
|
60
63
|
kind: "stored_query";
|
|
61
64
|
name: string;
|
|
62
65
|
};
|
|
63
|
-
export type FieldDiagnosticTerm = import("
|
|
66
|
+
export type FieldDiagnosticTerm = import("../parse-where-clause.types.d.ts").ParsedFieldTerm | import("../parse-where-clause.types.d.ts").ParsedFieldSetTerm;
|
|
64
67
|
export type ResolvedWhereClause = {
|
|
65
68
|
query_source: QuerySource;
|
|
66
69
|
where_clause: string;
|
|
@@ -80,7 +83,6 @@ export type QueryInspectionSuccess = {
|
|
|
80
83
|
query_source: QuerySource;
|
|
81
84
|
where_clause: string;
|
|
82
85
|
};
|
|
83
|
-
import type { PatramRepoConfig } from '
|
|
84
|
-
import type { PatramDiagnostic } from '
|
|
85
|
-
import type {
|
|
86
|
-
import type { ParsedExpression } from './parse-where-clause.types.ts';
|
|
86
|
+
import type { PatramRepoConfig } from '../../config/load-patram-config.types.d.ts';
|
|
87
|
+
import type { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
88
|
+
import type { ParsedExpression } from '../parse-where-clause.types.d.ts';
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
/**
|
|
3
|
-
* @import { PatramDiagnostic, PatramRepoConfig } from '
|
|
4
|
-
* @import { ResolvedOutputMode } from './output-view.types.ts';
|
|
3
|
+
* @import { PatramDiagnostic, PatramRepoConfig } from '../../config/load-patram-config.types.ts';
|
|
5
4
|
* @import {
|
|
6
5
|
* ParsedExpression,
|
|
7
6
|
* ParsedRelationTargetTerm,
|
|
8
7
|
* ParsedRelationTerm,
|
|
9
8
|
* ParsedTerm,
|
|
10
9
|
* ParsedTraversalTerm,
|
|
11
|
-
* } from '
|
|
10
|
+
* } from '../parse-where-clause.types.ts';
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
import { Ansis } from 'ansis';
|
|
15
14
|
|
|
16
|
-
import { parseWhereClause } from './parse
|
|
15
|
+
import { parseWhereClause } from './parse.js';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @typedef {{ kind: 'ad_hoc' } | { kind: 'stored_query', name: string }} QuerySource
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
* @typedef {import('
|
|
22
|
+
* @typedef {import('../parse-where-clause.types.ts').ParsedFieldTerm | import('../parse-where-clause.types.ts').ParsedFieldSetTerm} FieldDiagnosticTerm
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
25
|
/**
|
|
@@ -114,7 +113,7 @@ export function inspectQuery(
|
|
|
114
113
|
* Render a successful query inspection in one output mode.
|
|
115
114
|
*
|
|
116
115
|
* @param {QueryInspectionSuccess} query_inspection
|
|
117
|
-
* @param {
|
|
116
|
+
* @param {{ color_enabled: boolean, renderer_name: 'json' | 'plain' | 'rich' }} output_mode
|
|
118
117
|
* @returns {string}
|
|
119
118
|
*/
|
|
120
119
|
export function renderQueryInspection(query_inspection, output_mode) {
|
|
@@ -175,7 +174,7 @@ export function getQuerySemanticDiagnostics(
|
|
|
175
174
|
* @param {ParsedExpression} expression
|
|
176
175
|
* @param {PatramDiagnostic[]} diagnostics
|
|
177
176
|
* @param {Set<string>} known_relation_names
|
|
178
|
-
* @param {Record<string, import('
|
|
177
|
+
* @param {Record<string, import('../../config/load-patram-config.types.ts').MetadataFieldConfig>} known_field_definitions
|
|
179
178
|
* @param {string} diagnostic_path
|
|
180
179
|
*/
|
|
181
180
|
function collectExpressionDiagnostics(
|
|
@@ -230,7 +229,7 @@ function collectExpressionDiagnostics(
|
|
|
230
229
|
* @param {ParsedTerm} term
|
|
231
230
|
* @param {PatramDiagnostic[]} diagnostics
|
|
232
231
|
* @param {Set<string>} known_relation_names
|
|
233
|
-
* @param {Record<string, import('
|
|
232
|
+
* @param {Record<string, import('../../config/load-patram-config.types.ts').MetadataFieldConfig>} known_field_definitions
|
|
234
233
|
* @param {string} diagnostic_path
|
|
235
234
|
*/
|
|
236
235
|
function collectTermDiagnostics(
|
|
@@ -293,7 +292,7 @@ function collectTermDiagnostics(
|
|
|
293
292
|
/**
|
|
294
293
|
* @param {FieldDiagnosticTerm} term
|
|
295
294
|
* @param {PatramDiagnostic[]} diagnostics
|
|
296
|
-
* @param {Record<string, import('
|
|
295
|
+
* @param {Record<string, import('../../config/load-patram-config.types.ts').MetadataFieldConfig>} known_field_definitions
|
|
297
296
|
* @param {string} diagnostic_path
|
|
298
297
|
*/
|
|
299
298
|
function collectFieldDiagnostics(
|
|
@@ -302,12 +301,12 @@ function collectFieldDiagnostics(
|
|
|
302
301
|
known_field_definitions,
|
|
303
302
|
diagnostic_path,
|
|
304
303
|
) {
|
|
305
|
-
const
|
|
304
|
+
const fieldDiagnosticsCollector = getFieldDiagnosticsCollector(
|
|
306
305
|
term.field_name,
|
|
307
306
|
);
|
|
308
307
|
|
|
309
|
-
if (
|
|
310
|
-
|
|
308
|
+
if (fieldDiagnosticsCollector) {
|
|
309
|
+
fieldDiagnosticsCollector(term, diagnostics, diagnostic_path);
|
|
311
310
|
return;
|
|
312
311
|
}
|
|
313
312
|
|
|
@@ -430,8 +429,8 @@ function collectStructuralFieldDiagnostics(term, diagnostics, diagnostic_path) {
|
|
|
430
429
|
}
|
|
431
430
|
|
|
432
431
|
/**
|
|
433
|
-
* @param {import('
|
|
434
|
-
* @param {import('
|
|
432
|
+
* @param {import('../parse-where-clause.types.ts').ParsedFieldTerm} term
|
|
433
|
+
* @param {import('../../config/load-patram-config.types.ts').MetadataFieldConfig} field_definition
|
|
435
434
|
* @param {string} diagnostic_path
|
|
436
435
|
* @returns {PatramDiagnostic | null}
|
|
437
436
|
*/
|
|
@@ -454,7 +453,7 @@ function getMetadataFieldOperatorDiagnostic(
|
|
|
454
453
|
|
|
455
454
|
/**
|
|
456
455
|
* @param {string} operator
|
|
457
|
-
* @param {import('
|
|
456
|
+
* @param {import('../../config/load-patram-config.types.ts').MetadataFieldConfig} field_definition
|
|
458
457
|
* @returns {boolean}
|
|
459
458
|
*/
|
|
460
459
|
function supportsMetadataFieldOperator(operator, field_definition) {
|
|
@@ -474,7 +473,7 @@ function supportsMetadataFieldOperator(operator, field_definition) {
|
|
|
474
473
|
}
|
|
475
474
|
|
|
476
475
|
/**
|
|
477
|
-
* @param {import('
|
|
476
|
+
* @param {import('../../config/load-patram-config.types.ts').MetadataFieldConfig} field_definition
|
|
478
477
|
* @returns {boolean}
|
|
479
478
|
*/
|
|
480
479
|
function supportsPrefixOperator(field_definition) {
|
|
@@ -489,7 +488,7 @@ function supportsPrefixOperator(field_definition) {
|
|
|
489
488
|
}
|
|
490
489
|
|
|
491
490
|
/**
|
|
492
|
-
* @param {import('
|
|
491
|
+
* @param {import('../../config/load-patram-config.types.ts').MetadataFieldConfig} field_definition
|
|
493
492
|
* @returns {boolean}
|
|
494
493
|
*/
|
|
495
494
|
function supportsContainsOperator(field_definition) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { PatramDiagnostic } from '
|
|
2
|
+
* @import { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
3
3
|
* @import {
|
|
4
4
|
* ParseWhereClauseResult,
|
|
5
5
|
* ParsedAggregateComparison,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ParsedFieldName,
|
|
10
10
|
* ParsedTerm,
|
|
11
11
|
* ParsedTraversalTerm,
|
|
12
|
-
* } from '
|
|
12
|
+
* } from '../parse-where-clause.types.d.ts';
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* @typedef {{ bindings: Record<string, string>, index: number, where_clause: string }} ParserState
|
|
@@ -69,7 +69,7 @@ export type ParseValueResult = {
|
|
|
69
69
|
success: true;
|
|
70
70
|
value: string;
|
|
71
71
|
} | ParseFailureResult;
|
|
72
|
-
import type { ParseWhereClauseResult } from '
|
|
73
|
-
import type { PatramDiagnostic } from '
|
|
74
|
-
import type { ParsedExpression } from '
|
|
75
|
-
import type { ParsedTerm } from '
|
|
72
|
+
import type { ParseWhereClauseResult } from '../parse-where-clause.types.d.ts';
|
|
73
|
+
import type { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
|
|
74
|
+
import type { ParsedExpression } from '../parse-where-clause.types.d.ts';
|
|
75
|
+
import type { ParsedTerm } from '../parse-where-clause.types.d.ts';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
/**
|
|
3
|
-
* @import { PatramDiagnostic } from '
|
|
3
|
+
* @import { PatramDiagnostic } from '../../config/load-patram-config.types.ts';
|
|
4
4
|
* @import {
|
|
5
5
|
* ParseWhereClauseResult,
|
|
6
6
|
* ParsedAggregateComparison,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* ParsedFieldName,
|
|
11
11
|
* ParsedTerm,
|
|
12
12
|
* ParsedTraversalTerm,
|
|
13
|
-
* } from '
|
|
13
|
+
* } from '../parse-where-clause.types.ts';
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{ kind: 'ad_hoc' } | { kind: 'stored_query', name: string }} QuerySource
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Resolve an ad hoc or stored query into a where clause.
|
|
6
|
+
*
|
|
7
|
+
* @param {PatramRepoConfig} repo_config
|
|
8
|
+
* @param {string[]} command_arguments
|
|
9
|
+
* @returns {{ success: true, value: { query_source: QuerySource, where_clause: string } } | { error: CliParseError, success: false }}
|
|
10
|
+
*/
|
|
11
|
+
export function resolveWhereClause(repo_config: PatramRepoConfig, command_arguments: string[]): {
|
|
12
|
+
success: true;
|
|
13
|
+
value: {
|
|
14
|
+
query_source: QuerySource;
|
|
15
|
+
where_clause: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
error: CliParseError;
|
|
19
|
+
success: false;
|
|
20
|
+
};
|
|
21
|
+
export type QuerySource = {
|
|
22
|
+
kind: "ad_hoc";
|
|
23
|
+
} | {
|
|
24
|
+
kind: "stored_query";
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
import type { PatramRepoConfig } from '../../config/load-patram-config.types.d.ts';
|
|
28
|
+
import type { CliParseError } from '../../cli/arguments.types.d.ts';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import {
|
|
2
|
+
* @import { CliParseError } from '../../cli/arguments.types.ts';
|
|
3
|
+
* @import { PatramRepoConfig } from '../../config/load-patram-config.types.ts';
|
|
3
4
|
*/
|
|
4
5
|
|
|
6
|
+
import { findCloseMatch } from '../../find-close-match.js';
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* @typedef {{ kind: 'ad_hoc' } | { kind: 'stored_query', name: string }} QuerySource
|
|
7
10
|
*/
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
*
|
|
12
15
|
* @param {PatramRepoConfig} repo_config
|
|
13
16
|
* @param {string[]} command_arguments
|
|
14
|
-
* @returns {{ success: true, value: { query_source: QuerySource, where_clause: string } } | {
|
|
17
|
+
* @returns {{ success: true, value: { query_source: QuerySource, where_clause: string } } | { error: CliParseError, success: false }}
|
|
15
18
|
*/
|
|
16
19
|
export function resolveWhereClause(repo_config, command_arguments) {
|
|
17
20
|
if (command_arguments[0] === '--where') {
|
|
@@ -19,7 +22,10 @@ export function resolveWhereClause(repo_config, command_arguments) {
|
|
|
19
22
|
|
|
20
23
|
if (where_clause.length === 0) {
|
|
21
24
|
return {
|
|
22
|
-
|
|
25
|
+
error: {
|
|
26
|
+
code: 'message',
|
|
27
|
+
message: 'Query requires a where clause.',
|
|
28
|
+
},
|
|
23
29
|
success: false,
|
|
24
30
|
};
|
|
25
31
|
}
|
|
@@ -39,7 +45,10 @@ export function resolveWhereClause(repo_config, command_arguments) {
|
|
|
39
45
|
|
|
40
46
|
if (!stored_query_name) {
|
|
41
47
|
return {
|
|
42
|
-
|
|
48
|
+
error: {
|
|
49
|
+
code: 'message',
|
|
50
|
+
message: 'Query requires "--where" or a stored query name.',
|
|
51
|
+
},
|
|
43
52
|
success: false,
|
|
44
53
|
};
|
|
45
54
|
}
|
|
@@ -48,7 +57,10 @@ export function resolveWhereClause(repo_config, command_arguments) {
|
|
|
48
57
|
|
|
49
58
|
if (!stored_query) {
|
|
50
59
|
return {
|
|
51
|
-
|
|
60
|
+
error: createUnknownStoredQueryError(
|
|
61
|
+
stored_query_name,
|
|
62
|
+
Object.keys(repo_config.queries),
|
|
63
|
+
),
|
|
52
64
|
success: false,
|
|
53
65
|
};
|
|
54
66
|
}
|
|
@@ -64,3 +76,25 @@ export function resolveWhereClause(repo_config, command_arguments) {
|
|
|
64
76
|
},
|
|
65
77
|
};
|
|
66
78
|
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} stored_query_name
|
|
82
|
+
* @param {string[]} stored_query_names
|
|
83
|
+
* @returns {CliParseError}
|
|
84
|
+
*/
|
|
85
|
+
function createUnknownStoredQueryError(stored_query_name, stored_query_names) {
|
|
86
|
+
const suggestion = findCloseMatch(stored_query_name, stored_query_names);
|
|
87
|
+
|
|
88
|
+
if (!suggestion) {
|
|
89
|
+
return {
|
|
90
|
+
code: 'unknown_stored_query',
|
|
91
|
+
name: stored_query_name,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
code: 'unknown_stored_query',
|
|
97
|
+
name: stored_query_name,
|
|
98
|
+
suggestion,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared reverse-reference graph fixtures for tests.
|
|
3
|
+
*/
|
|
4
|
+
export function createDecisionNode(): {
|
|
5
|
+
$class: string;
|
|
6
|
+
$id: string;
|
|
7
|
+
$path: string;
|
|
8
|
+
id: string;
|
|
9
|
+
path: string;
|
|
10
|
+
status: string;
|
|
11
|
+
title: string;
|
|
12
|
+
};
|
|
13
|
+
export function createReconcileNode(): {
|
|
14
|
+
$class: string;
|
|
15
|
+
$id: string;
|
|
16
|
+
$path: string;
|
|
17
|
+
id: string;
|
|
18
|
+
path: string;
|
|
19
|
+
title: string;
|
|
20
|
+
};
|
|
21
|
+
export function createResumeNode(): {
|
|
22
|
+
$class: string;
|
|
23
|
+
$id: string;
|
|
24
|
+
$path: string;
|
|
25
|
+
id: string;
|
|
26
|
+
path: string;
|
|
27
|
+
title: string;
|
|
28
|
+
};
|
|
29
|
+
export function createTaskNode(): {
|
|
30
|
+
$class: string;
|
|
31
|
+
$id: string;
|
|
32
|
+
$path: string;
|
|
33
|
+
id: string;
|
|
34
|
+
path: string;
|
|
35
|
+
status: string;
|
|
36
|
+
title: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} edge_id
|
|
40
|
+
* @param {string} from_id
|
|
41
|
+
* @param {string} origin_path
|
|
42
|
+
* @param {string} relation_name
|
|
43
|
+
* @param {string} to_id
|
|
44
|
+
*/
|
|
45
|
+
export function createGraphEdge(edge_id: string, from_id: string, origin_path: string, relation_name: string, to_id: string): {
|
|
46
|
+
from: string;
|
|
47
|
+
id: string;
|
|
48
|
+
origin: {
|
|
49
|
+
column: number;
|
|
50
|
+
line: number;
|
|
51
|
+
path: string;
|
|
52
|
+
};
|
|
53
|
+
relation: string;
|
|
54
|
+
to: string;
|
|
55
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { ParsedCliArguments } from '
|
|
2
|
+
* @import { ParsedCliArguments } from '../cli/arguments.types.ts';
|
|
3
3
|
* @import { OutputView } from './output-view.types.ts';
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
|
|
8
|
+
import { resolveOutputMode } from '../cli/resolve-output-mode.js';
|
|
8
9
|
import { renderOutputView } from './render-output-view.js';
|
|
9
|
-
import { resolveOutputMode } from './resolve-output-mode.js';
|
|
10
10
|
import { writePagedOutput } from './write-paged-output.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -17,11 +17,11 @@ import { writePagedOutput } from './write-paged-output.js';
|
|
|
17
17
|
*
|
|
18
18
|
* Kind: output
|
|
19
19
|
* Status: active
|
|
20
|
-
* Tracked in:
|
|
21
|
-
* Decided by:
|
|
20
|
+
* Tracked in: ../../docs/plans/v0/source-anchor-dogfooding.md
|
|
21
|
+
* Decided by: ../../docs/decisions/tty-pager-output.md
|
|
22
22
|
* @patram
|
|
23
23
|
* @see {@link ./render-output-view.js}
|
|
24
|
-
* @see {@link
|
|
24
|
+
* @see {@link ../../docs/decisions/tty-pager-output.md}
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { BuildGraphResult, GraphNode } from '
|
|
2
|
+
* @import { BuildGraphResult, GraphNode } from '../graph/build-graph.types.ts';
|
|
3
3
|
* @import { OutputDerivedSummary } from './output-view.types.ts';
|
|
4
|
-
* @import { DerivedSummaryConfig, DerivedSummaryFieldConfig, DerivedSummaryScalar, PatramRepoConfig } from '
|
|
4
|
+
* @import { DerivedSummaryConfig, DerivedSummaryFieldConfig, DerivedSummaryScalar, PatramRepoConfig } from '../config/load-patram-config.types.ts';
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { queryGraph } from '
|
|
7
|
+
import { queryGraph } from '../graph/query/execute.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Derived summary evaluation.
|
|
@@ -14,11 +14,11 @@ import { queryGraph } from './query-graph.js';
|
|
|
14
14
|
*
|
|
15
15
|
* Kind: output
|
|
16
16
|
* Status: active
|
|
17
|
-
* Tracked in:
|
|
18
|
-
* Decided by:
|
|
19
|
-
* Decided by:
|
|
17
|
+
* Tracked in: ../../docs/plans/v0/declarative-derived-summaries.md
|
|
18
|
+
* Decided by: ../../docs/decisions/declarative-derived-summary-config.md
|
|
19
|
+
* Decided by: ../../docs/decisions/declarative-derived-summary-side-effects.md
|
|
20
20
|
* @patram
|
|
21
|
-
* @see {@link
|
|
21
|
+
* @see {@link ../config/load-patram-config.js}
|
|
22
22
|
* @see {@link ./render-output-view.js}
|
|
23
23
|
*/
|
|
24
24
|
|
|
@@ -17,9 +17,9 @@ import { formatOutputItemBlock } from './format-output-item-block.js';
|
|
|
17
17
|
* @returns {string[]}
|
|
18
18
|
*/
|
|
19
19
|
export function layoutIncomingReferenceLines(incoming, layout_options = {}) {
|
|
20
|
-
const
|
|
20
|
+
const formatNodeHeader =
|
|
21
21
|
layout_options.format_node_header ?? defaultNodeHeaderFormatter;
|
|
22
|
-
const
|
|
22
|
+
const formatRelationHeader =
|
|
23
23
|
layout_options.format_relation_header ?? defaultRelationHeaderFormatter;
|
|
24
24
|
/** @type {string[]} */
|
|
25
25
|
const output_lines = [];
|
|
@@ -32,10 +32,10 @@ export function layoutIncomingReferenceLines(incoming, layout_options = {}) {
|
|
|
32
32
|
const relation_sources = incoming[relation_name];
|
|
33
33
|
|
|
34
34
|
output_lines.push(
|
|
35
|
-
|
|
35
|
+
formatRelationHeader(relation_name, relation_sources.length),
|
|
36
36
|
);
|
|
37
37
|
output_lines.push(
|
|
38
|
-
...layoutIncomingRelationSources(relation_sources,
|
|
38
|
+
...layoutIncomingRelationSources(relation_sources, formatNodeHeader),
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -8,11 +8,6 @@ export function layoutIncomingSummaryLines(incoming_summary) {
|
|
|
8
8
|
const relation_names = Object.keys(incoming_summary);
|
|
9
9
|
const output_lines = ['incoming refs:'];
|
|
10
10
|
|
|
11
|
-
if (relation_names.length === 0) {
|
|
12
|
-
output_lines.push(' none');
|
|
13
|
-
return output_lines;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
11
|
for (const relation_name of relation_names) {
|
|
17
12
|
output_lines.push(` ${relation_name}: ${incoming_summary[relation_name]}`);
|
|
18
13
|
}
|