patram 0.10.0 → 0.12.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.
Files changed (117) hide show
  1. package/bin/patram.js +4 -4
  2. package/lib/cli/arguments.types.d.ts +1 -0
  3. package/lib/cli/commands/check.js +27 -15
  4. package/lib/cli/commands/fields.js +0 -4
  5. package/lib/cli/commands/queries.js +179 -1
  6. package/lib/cli/commands/query.js +1 -8
  7. package/lib/cli/commands/refs.js +3 -10
  8. package/lib/cli/commands/show.js +1 -8
  9. package/lib/cli/help-metadata.js +106 -111
  10. package/lib/cli/main.js +10 -10
  11. package/lib/cli/parse-arguments-helpers.js +416 -66
  12. package/lib/cli/parse-arguments.js +4 -4
  13. package/lib/cli/render-help.js +10 -4
  14. package/lib/config/defaults.js +33 -25
  15. package/lib/config/load-patram-config.d.ts +19 -33
  16. package/lib/config/load-patram-config.js +18 -121
  17. package/lib/config/load-patram-config.types.d.ts +3 -40
  18. package/lib/config/manage-stored-queries-helpers.d.ts +69 -0
  19. package/lib/config/manage-stored-queries-helpers.js +320 -0
  20. package/lib/config/manage-stored-queries-jsonc.d.ts +31 -0
  21. package/lib/config/manage-stored-queries-jsonc.js +95 -0
  22. package/lib/config/manage-stored-queries.d.ts +77 -0
  23. package/lib/config/manage-stored-queries.js +300 -0
  24. package/lib/config/patram-config.d.ts +34 -34
  25. package/lib/config/patram-config.js +3 -3
  26. package/lib/config/patram-config.types.d.ts +5 -11
  27. package/lib/config/resolve-patram-graph-config.d.ts +5 -1
  28. package/lib/config/resolve-patram-graph-config.js +3 -119
  29. package/lib/config/schema.d.ts +158 -269
  30. package/lib/config/schema.js +72 -210
  31. package/lib/config/validate-patram-config-value.d.ts +13 -0
  32. package/lib/config/validate-patram-config-value.js +94 -0
  33. package/lib/config/validation.d.ts +2 -12
  34. package/lib/config/validation.js +125 -483
  35. package/lib/find-close-match.d.ts +4 -1
  36. package/lib/graph/build-graph-identity.d.ts +1 -32
  37. package/lib/graph/build-graph-identity.js +5 -269
  38. package/lib/graph/build-graph.d.ts +13 -4
  39. package/lib/graph/build-graph.js +347 -488
  40. package/lib/graph/build-graph.types.d.ts +8 -9
  41. package/lib/graph/check-directive-metadata-helpers.d.ts +30 -0
  42. package/lib/graph/check-directive-metadata-helpers.js +126 -0
  43. package/lib/graph/check-directive-metadata.d.ts +8 -9
  44. package/lib/graph/check-directive-metadata.js +70 -561
  45. package/lib/graph/check-directive-path-target.d.ts +6 -13
  46. package/lib/graph/check-directive-path-target.js +26 -57
  47. package/lib/graph/check-directive-value.d.ts +1 -5
  48. package/lib/graph/check-directive-value.js +40 -180
  49. package/lib/graph/check-graph.d.ts +5 -5
  50. package/lib/graph/check-graph.js +8 -6
  51. package/lib/graph/document-node-identity.d.ts +23 -7
  52. package/lib/graph/document-node-identity.js +417 -160
  53. package/lib/graph/graph-node.d.ts +42 -0
  54. package/lib/graph/graph-node.js +83 -0
  55. package/lib/graph/inspect-reverse-references.js +16 -11
  56. package/lib/graph/load-project-graph.d.ts +7 -7
  57. package/lib/graph/load-project-graph.js +7 -7
  58. package/lib/graph/parse-where-clause.types.d.ts +3 -2
  59. package/lib/graph/query/cypher-reader.d.ts +59 -0
  60. package/lib/graph/query/cypher-reader.js +151 -0
  61. package/lib/graph/query/cypher-support.d.ts +79 -0
  62. package/lib/graph/query/cypher-support.js +213 -0
  63. package/lib/graph/query/cypher-tokenize.d.ts +13 -0
  64. package/lib/graph/query/cypher-tokenize.js +225 -0
  65. package/lib/graph/query/cypher.types.d.ts +43 -0
  66. package/lib/graph/query/execute.d.ts +7 -7
  67. package/lib/graph/query/execute.js +71 -33
  68. package/lib/graph/query/inspect.js +58 -24
  69. package/lib/graph/query/parse-cypher-patterns.d.ts +27 -0
  70. package/lib/graph/query/parse-cypher-patterns.js +382 -0
  71. package/lib/graph/query/parse-cypher.d.ts +7 -0
  72. package/lib/graph/query/parse-cypher.js +580 -0
  73. package/lib/graph/query/parse-query.d.ts +13 -0
  74. package/lib/graph/query/parse-query.js +97 -0
  75. package/lib/graph/query/resolve.d.ts +6 -0
  76. package/lib/graph/query/resolve.js +81 -24
  77. package/lib/output/command-output.js +12 -5
  78. package/lib/output/compact-layout.js +221 -0
  79. package/lib/output/format-output-item-block.js +31 -1
  80. package/lib/output/format-output-metadata.js +16 -29
  81. package/lib/output/format-stored-query-block.js +95 -0
  82. package/lib/output/layout-incoming-references.js +101 -19
  83. package/lib/output/layout-stored-queries.js +23 -330
  84. package/lib/output/list-queries.js +1 -1
  85. package/lib/output/render-field-discovery.js +11 -2
  86. package/lib/output/render-output-view.js +9 -5
  87. package/lib/output/renderers/json.js +5 -26
  88. package/lib/output/renderers/plain.js +155 -35
  89. package/lib/output/renderers/rich.js +250 -36
  90. package/lib/output/resolve-check-target.js +120 -11
  91. package/lib/output/resolved-link-layout.js +43 -0
  92. package/lib/output/rich-source/render.js +193 -35
  93. package/lib/output/show-document.js +25 -18
  94. package/lib/output/view-model/index.js +124 -103
  95. package/lib/parse/jsdoc/parse-jsdoc-blocks.js +1 -1
  96. package/lib/parse/jsdoc/parse-jsdoc-claims.js +12 -6
  97. package/lib/parse/markdown/parse-markdown-claims.js +99 -62
  98. package/lib/parse/markdown/parse-markdown-directives.d.ts +10 -6
  99. package/lib/parse/markdown/parse-markdown-directives.js +104 -18
  100. package/lib/parse/markdown/parse-markdown-prose.d.ts +27 -0
  101. package/lib/parse/markdown/parse-markdown-prose.js +243 -0
  102. package/lib/parse/parse-claims.d.ts +2 -6
  103. package/lib/parse/parse-claims.js +11 -53
  104. package/lib/parse/tagged-fenced/tagged-fenced-blocks.d.ts +4 -4
  105. package/lib/parse/tagged-fenced/tagged-fenced-blocks.js +4 -4
  106. package/lib/parse/yaml/parse-yaml-claims.js +4 -4
  107. package/lib/patram.d.ts +9 -3
  108. package/lib/patram.js +1 -1
  109. package/lib/scan/discover-fields.js +194 -55
  110. package/lib/scan/list-source-files.d.ts +4 -4
  111. package/lib/scan/list-source-files.js +4 -4
  112. package/package.json +2 -1
  113. package/lib/directive-validation-test-helpers.js +0 -87
  114. package/lib/graph/query/parse.d.ts +0 -75
  115. package/lib/graph/query/parse.js +0 -1064
  116. package/lib/output/derived-summary.js +0 -280
  117. package/lib/output/format-derived-summary-row.js +0 -9
@@ -1,87 +0,0 @@
1
- /**
2
- * @import { MappingDefinition } from './config/patram-config.types.ts';
3
- */
4
-
5
- /**
6
- * @returns {Record<string, { prefixes: string[] }>}
7
- */
8
- export function createDirectivePathClasses() {
9
- return {
10
- decision_docs: {
11
- prefixes: ['docs/decisions/'],
12
- },
13
- plan_docs: {
14
- prefixes: ['docs/plans/'],
15
- },
16
- task_docs: {
17
- prefixes: ['docs/tasks/'],
18
- },
19
- };
20
- }
21
-
22
- /**
23
- * @returns {Record<string, { from: string[], to: string[] }>}
24
- */
25
- export function createDirectiveRelations() {
26
- return {
27
- decided_by: {
28
- from: ['document'],
29
- to: ['document'],
30
- },
31
- tracked_in: {
32
- from: ['document'],
33
- to: ['document'],
34
- },
35
- };
36
- }
37
-
38
- /**
39
- * @returns {Record<string, MappingDefinition>}
40
- */
41
- export function createMarkdownDirectiveMappings() {
42
- return {
43
- 'markdown.directive.decided_by': createRelationMapping('decided_by'),
44
- 'markdown.directive.kind': createNodeMapping('$class'),
45
- 'markdown.directive.status': createNodeMapping('status'),
46
- 'markdown.directive.tracked_in': createRelationMapping('tracked_in'),
47
- };
48
- }
49
-
50
- /**
51
- * @returns {Record<string, MappingDefinition>}
52
- */
53
- export function createJsdocDirectiveMappings() {
54
- return {
55
- 'jsdoc.directive.decided_by': createRelationMapping('decided_by'),
56
- 'jsdoc.directive.kind': createNodeMapping('$class'),
57
- 'jsdoc.directive.status': createNodeMapping('status'),
58
- 'jsdoc.directive.tracked_in': createRelationMapping('tracked_in'),
59
- };
60
- }
61
-
62
- /**
63
- * @param {string} field_name
64
- * @returns {MappingDefinition}
65
- */
66
- function createNodeMapping(field_name) {
67
- return {
68
- node: {
69
- class: 'document',
70
- field: field_name,
71
- },
72
- };
73
- }
74
-
75
- /**
76
- * @param {string} relation_name
77
- * @returns {MappingDefinition}
78
- */
79
- function createRelationMapping(relation_name) {
80
- return {
81
- emit: {
82
- relation: relation_name,
83
- target: 'path',
84
- target_class: 'document',
85
- },
86
- };
87
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * @import { PatramDiagnostic } from '../../config/load-patram-config.types.d.ts';
3
- * @import {
4
- * ParseWhereClauseResult,
5
- * ParsedAggregateComparison,
6
- * ParsedAggregateName,
7
- * ParsedAggregateTerm,
8
- * ParsedExpression,
9
- * ParsedFieldName,
10
- * ParsedTerm,
11
- * ParsedTraversalTerm,
12
- * } from '../parse-where-clause.types.d.ts';
13
- */
14
- /**
15
- * @typedef {{ bindings: Record<string, string>, index: number, where_clause: string }} ParserState
16
- */
17
- /**
18
- * @typedef {{
19
- * diagnostic: PatramDiagnostic,
20
- * success: false,
21
- * }} ParseFailureResult
22
- */
23
- /**
24
- * @typedef {{
25
- * expression: ParsedExpression,
26
- * success: true,
27
- * } | ParseFailureResult} ParseExpressionResult
28
- */
29
- /**
30
- * @typedef {{
31
- * success: true,
32
- * term: ParsedTerm,
33
- * } | ParseFailureResult} ParseTermResult
34
- */
35
- /**
36
- * @typedef {{
37
- * success: true,
38
- * value: string,
39
- * } | ParseFailureResult} ParseValueResult
40
- */
41
- /**
42
- * Parse one where clause into a structured boolean expression.
43
- *
44
- * @param {string} where_clause
45
- * @param {{ bindings?: Record<string, string> }=} options
46
- * @returns {ParseWhereClauseResult}
47
- */
48
- export function parseWhereClause(where_clause: string, options?: {
49
- bindings?: Record<string, string>;
50
- } | undefined): ParseWhereClauseResult;
51
- export type ParserState = {
52
- bindings: Record<string, string>;
53
- index: number;
54
- where_clause: string;
55
- };
56
- export type ParseFailureResult = {
57
- diagnostic: PatramDiagnostic;
58
- success: false;
59
- };
60
- export type ParseExpressionResult = {
61
- expression: ParsedExpression;
62
- success: true;
63
- } | ParseFailureResult;
64
- export type ParseTermResult = {
65
- success: true;
66
- term: ParsedTerm;
67
- } | ParseFailureResult;
68
- export type ParseValueResult = {
69
- success: true;
70
- value: string;
71
- } | ParseFailureResult;
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';