patram 0.2.0 → 0.4.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/lib/build-graph-identity.js +86 -99
- package/lib/build-graph.js +536 -31
- package/lib/build-graph.types.ts +6 -2
- package/lib/check-directive-metadata.js +534 -0
- package/lib/check-directive-value.js +291 -0
- package/lib/check-graph.js +23 -5
- package/lib/cli-help-metadata.js +56 -16
- package/lib/command-output.js +16 -1
- package/lib/derived-summary.js +10 -8
- package/lib/directive-diagnostics.js +38 -0
- package/lib/directive-type-rules.js +133 -0
- package/lib/discover-fields.js +435 -0
- package/lib/discover-fields.types.ts +52 -0
- package/lib/document-node-identity.js +317 -0
- package/lib/format-node-header.js +9 -7
- package/lib/format-output-metadata.js +15 -23
- package/lib/layout-stored-queries.js +124 -85
- package/lib/load-patram-config.js +433 -96
- package/lib/load-patram-config.types.ts +98 -3
- package/lib/load-project-graph.js +4 -1
- package/lib/output-view.types.ts +14 -6
- package/lib/parse-cli-arguments.types.ts +1 -1
- package/lib/parse-where-clause.js +344 -107
- package/lib/parse-where-clause.types.ts +25 -8
- package/lib/patram-cli.js +68 -4
- package/lib/patram-config.js +31 -31
- package/lib/patram-config.types.ts +10 -4
- package/lib/query-graph.js +269 -40
- package/lib/query-inspection.js +440 -60
- package/lib/render-field-discovery.js +184 -0
- package/lib/render-json-output.js +21 -22
- package/lib/render-output-view.js +301 -34
- package/lib/render-plain-output.js +1 -1
- package/lib/render-rich-output.js +1 -1
- package/lib/render-rich-source.js +245 -14
- package/lib/resolve-patram-graph-config.js +15 -9
- package/lib/show-document.js +66 -9
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
ClassDefinition,
|
|
3
3
|
MappingDefinition,
|
|
4
4
|
RelationDefinition,
|
|
5
5
|
} from './patram-config.types.ts';
|
|
@@ -8,6 +8,98 @@ export interface StoredQueryConfig {
|
|
|
8
8
|
where: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type FieldValueTypeName =
|
|
12
|
+
| 'string'
|
|
13
|
+
| 'integer'
|
|
14
|
+
| 'enum'
|
|
15
|
+
| 'path'
|
|
16
|
+
| 'glob'
|
|
17
|
+
| 'date'
|
|
18
|
+
| 'date_time';
|
|
19
|
+
|
|
20
|
+
export interface FieldDisplayConfig {
|
|
21
|
+
hidden?: boolean;
|
|
22
|
+
order?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface FieldQueryConfig {
|
|
26
|
+
contains?: boolean;
|
|
27
|
+
prefix?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface StringFieldConfig {
|
|
31
|
+
display?: FieldDisplayConfig;
|
|
32
|
+
multiple?: boolean;
|
|
33
|
+
query?: FieldQueryConfig;
|
|
34
|
+
type: 'string';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface IntegerFieldConfig {
|
|
38
|
+
display?: FieldDisplayConfig;
|
|
39
|
+
multiple?: boolean;
|
|
40
|
+
type: 'integer';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface EnumFieldConfig {
|
|
44
|
+
display?: FieldDisplayConfig;
|
|
45
|
+
multiple?: boolean;
|
|
46
|
+
type: 'enum';
|
|
47
|
+
values: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface PathFieldConfig {
|
|
51
|
+
display?: FieldDisplayConfig;
|
|
52
|
+
multiple?: boolean;
|
|
53
|
+
path_class?: string;
|
|
54
|
+
type: 'path';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface GlobFieldConfig {
|
|
58
|
+
display?: FieldDisplayConfig;
|
|
59
|
+
multiple?: boolean;
|
|
60
|
+
type: 'glob';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface DateFieldConfig {
|
|
64
|
+
display?: FieldDisplayConfig;
|
|
65
|
+
multiple?: boolean;
|
|
66
|
+
type: 'date';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DateTimeFieldConfig {
|
|
70
|
+
display?: FieldDisplayConfig;
|
|
71
|
+
multiple?: boolean;
|
|
72
|
+
type: 'date_time';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type MetadataFieldConfig =
|
|
76
|
+
| DateFieldConfig
|
|
77
|
+
| DateTimeFieldConfig
|
|
78
|
+
| EnumFieldConfig
|
|
79
|
+
| GlobFieldConfig
|
|
80
|
+
| IntegerFieldConfig
|
|
81
|
+
| PathFieldConfig
|
|
82
|
+
| StringFieldConfig;
|
|
83
|
+
|
|
84
|
+
export interface ClassFieldRuleConfig {
|
|
85
|
+
presence: 'required' | 'optional' | 'forbidden';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type DirectiveTypeConfig = MetadataFieldConfig;
|
|
89
|
+
export type MetadataDirectiveRuleConfig = ClassFieldRuleConfig;
|
|
90
|
+
|
|
91
|
+
export interface ClassSchemaConfig {
|
|
92
|
+
document_path_class?: string;
|
|
93
|
+
fields: Record<string, ClassFieldRuleConfig>;
|
|
94
|
+
unknown_fields?: 'ignore' | 'error';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type MetadataSchemaConfig = ClassSchemaConfig;
|
|
98
|
+
|
|
99
|
+
export interface PathClassConfig {
|
|
100
|
+
prefixes: string[];
|
|
101
|
+
}
|
|
102
|
+
|
|
11
103
|
export type DerivedSummaryScalar = boolean | number | string | null;
|
|
12
104
|
|
|
13
105
|
export interface DerivedSummaryCountFieldConfig {
|
|
@@ -34,15 +126,18 @@ export type DerivedSummaryFieldConfig =
|
|
|
34
126
|
| DerivedSummarySelectFieldConfig;
|
|
35
127
|
|
|
36
128
|
export interface DerivedSummaryConfig {
|
|
129
|
+
classes: string[];
|
|
37
130
|
fields: DerivedSummaryFieldConfig[];
|
|
38
|
-
kinds: string[];
|
|
39
131
|
}
|
|
40
132
|
|
|
41
133
|
export interface PatramRepoConfig {
|
|
134
|
+
class_schemas?: Record<string, ClassSchemaConfig>;
|
|
135
|
+
classes?: Record<string, ClassDefinition>;
|
|
42
136
|
derived_summaries?: Record<string, DerivedSummaryConfig>;
|
|
137
|
+
fields?: Record<string, MetadataFieldConfig>;
|
|
43
138
|
include: string[];
|
|
44
|
-
kinds?: Record<string, KindDefinition>;
|
|
45
139
|
mappings?: Record<string, MappingDefinition>;
|
|
140
|
+
path_classes?: Record<string, PathClassConfig>;
|
|
46
141
|
queries: Record<string, StoredQueryConfig>;
|
|
47
142
|
relations?: Record<string, RelationDefinition>;
|
|
48
143
|
}
|
|
@@ -36,13 +36,14 @@ import { resolvePatramGraphConfig } from './resolve-patram-graph-config.js';
|
|
|
36
36
|
* project directory.
|
|
37
37
|
*
|
|
38
38
|
* @param {string} project_directory
|
|
39
|
-
* @returns {Promise<{ config: PatramRepoConfig, diagnostics: PatramDiagnostic[], graph: BuildGraphResult, source_file_paths: string[] }>}
|
|
39
|
+
* @returns {Promise<{ claims: PatramClaim[], config: PatramRepoConfig, diagnostics: PatramDiagnostic[], graph: BuildGraphResult, source_file_paths: string[] }>}
|
|
40
40
|
*/
|
|
41
41
|
export async function loadProjectGraph(project_directory) {
|
|
42
42
|
const load_result = await loadPatramConfig(project_directory);
|
|
43
43
|
|
|
44
44
|
if (load_result.diagnostics.length > 0) {
|
|
45
45
|
return {
|
|
46
|
+
claims: [],
|
|
46
47
|
config: {
|
|
47
48
|
include: [],
|
|
48
49
|
queries: {},
|
|
@@ -74,6 +75,7 @@ export async function loadProjectGraph(project_directory) {
|
|
|
74
75
|
|
|
75
76
|
if (collect_result.diagnostics.length > 0) {
|
|
76
77
|
return {
|
|
78
|
+
claims: collect_result.claims,
|
|
77
79
|
config: repo_config,
|
|
78
80
|
diagnostics: collect_result.diagnostics,
|
|
79
81
|
graph: {
|
|
@@ -85,6 +87,7 @@ export async function loadProjectGraph(project_directory) {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
return {
|
|
90
|
+
claims: collect_result.claims,
|
|
88
91
|
config: repo_config,
|
|
89
92
|
diagnostics: [],
|
|
90
93
|
graph: buildGraph(graph_config, collect_result.claims),
|
package/lib/output-view.types.ts
CHANGED
|
@@ -12,6 +12,11 @@ export interface OutputDerivedSummary {
|
|
|
12
12
|
name: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export interface OutputMetadataField {
|
|
16
|
+
name: string;
|
|
17
|
+
value: string | string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
export interface OutputViewSummary {
|
|
16
21
|
count: number;
|
|
17
22
|
kind: 'resolved_link_list' | 'result_list' | 'stored_query_list';
|
|
@@ -26,12 +31,13 @@ export interface QueryOutputViewSummary extends OutputViewSummary {
|
|
|
26
31
|
|
|
27
32
|
export interface OutputNodeItem {
|
|
28
33
|
derived_summary?: OutputDerivedSummary;
|
|
34
|
+
fields: Record<string, string | string[]>;
|
|
29
35
|
id: string;
|
|
30
36
|
kind: 'node';
|
|
31
|
-
node_kind:
|
|
32
|
-
path
|
|
33
|
-
status?: string;
|
|
37
|
+
node_kind: string;
|
|
38
|
+
path?: string;
|
|
34
39
|
title: string;
|
|
40
|
+
visible_fields: OutputMetadataField[];
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export interface OutputStoredQueryItem {
|
|
@@ -42,10 +48,12 @@ export interface OutputStoredQueryItem {
|
|
|
42
48
|
|
|
43
49
|
export interface OutputResolvedLinkTarget {
|
|
44
50
|
derived_summary?: OutputDerivedSummary;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
fields: Record<string, string | string[]>;
|
|
52
|
+
id: string;
|
|
53
|
+
kind: string;
|
|
54
|
+
path?: string;
|
|
48
55
|
title: string;
|
|
56
|
+
visible_fields: OutputMetadataField[];
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
export interface OutputResolvedLinkItem {
|