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.
- package/bin/patram.js +4 -4
- package/lib/cli/arguments.types.d.ts +1 -0
- package/lib/cli/commands/check.js +27 -15
- package/lib/cli/commands/fields.js +0 -4
- package/lib/cli/commands/queries.js +179 -1
- package/lib/cli/commands/query.js +1 -8
- package/lib/cli/commands/refs.js +3 -10
- package/lib/cli/commands/show.js +1 -8
- package/lib/cli/help-metadata.js +106 -111
- package/lib/cli/main.js +10 -10
- package/lib/cli/parse-arguments-helpers.js +416 -66
- package/lib/cli/parse-arguments.js +4 -4
- package/lib/cli/render-help.js +10 -4
- package/lib/config/defaults.js +33 -25
- package/lib/config/load-patram-config.d.ts +19 -33
- package/lib/config/load-patram-config.js +18 -121
- package/lib/config/load-patram-config.types.d.ts +3 -40
- package/lib/config/manage-stored-queries-helpers.d.ts +69 -0
- package/lib/config/manage-stored-queries-helpers.js +320 -0
- package/lib/config/manage-stored-queries-jsonc.d.ts +31 -0
- package/lib/config/manage-stored-queries-jsonc.js +95 -0
- package/lib/config/manage-stored-queries.d.ts +77 -0
- package/lib/config/manage-stored-queries.js +300 -0
- package/lib/config/patram-config.d.ts +34 -34
- package/lib/config/patram-config.js +3 -3
- package/lib/config/patram-config.types.d.ts +5 -11
- package/lib/config/resolve-patram-graph-config.d.ts +5 -1
- package/lib/config/resolve-patram-graph-config.js +3 -119
- package/lib/config/schema.d.ts +158 -269
- package/lib/config/schema.js +72 -210
- package/lib/config/validate-patram-config-value.d.ts +13 -0
- package/lib/config/validate-patram-config-value.js +94 -0
- package/lib/config/validation.d.ts +2 -12
- package/lib/config/validation.js +125 -483
- package/lib/find-close-match.d.ts +4 -1
- package/lib/graph/build-graph-identity.d.ts +1 -32
- package/lib/graph/build-graph-identity.js +5 -269
- package/lib/graph/build-graph.d.ts +13 -4
- package/lib/graph/build-graph.js +347 -488
- package/lib/graph/build-graph.types.d.ts +8 -9
- package/lib/graph/check-directive-metadata-helpers.d.ts +30 -0
- package/lib/graph/check-directive-metadata-helpers.js +126 -0
- package/lib/graph/check-directive-metadata.d.ts +8 -9
- package/lib/graph/check-directive-metadata.js +70 -561
- package/lib/graph/check-directive-path-target.d.ts +6 -13
- package/lib/graph/check-directive-path-target.js +26 -57
- package/lib/graph/check-directive-value.d.ts +1 -5
- package/lib/graph/check-directive-value.js +40 -180
- package/lib/graph/check-graph.d.ts +5 -5
- package/lib/graph/check-graph.js +8 -6
- package/lib/graph/document-node-identity.d.ts +23 -7
- package/lib/graph/document-node-identity.js +417 -160
- package/lib/graph/graph-node.d.ts +42 -0
- package/lib/graph/graph-node.js +83 -0
- package/lib/graph/inspect-reverse-references.js +16 -11
- package/lib/graph/load-project-graph.d.ts +7 -7
- package/lib/graph/load-project-graph.js +7 -7
- package/lib/graph/parse-where-clause.types.d.ts +3 -2
- package/lib/graph/query/cypher-reader.d.ts +59 -0
- package/lib/graph/query/cypher-reader.js +151 -0
- package/lib/graph/query/cypher-support.d.ts +79 -0
- package/lib/graph/query/cypher-support.js +213 -0
- package/lib/graph/query/cypher-tokenize.d.ts +13 -0
- package/lib/graph/query/cypher-tokenize.js +225 -0
- package/lib/graph/query/cypher.types.d.ts +43 -0
- package/lib/graph/query/execute.d.ts +7 -7
- package/lib/graph/query/execute.js +71 -33
- package/lib/graph/query/inspect.js +58 -24
- package/lib/graph/query/parse-cypher-patterns.d.ts +27 -0
- package/lib/graph/query/parse-cypher-patterns.js +382 -0
- package/lib/graph/query/parse-cypher.d.ts +7 -0
- package/lib/graph/query/parse-cypher.js +580 -0
- package/lib/graph/query/parse-query.d.ts +13 -0
- package/lib/graph/query/parse-query.js +97 -0
- package/lib/graph/query/resolve.d.ts +6 -0
- package/lib/graph/query/resolve.js +81 -24
- package/lib/output/command-output.js +12 -5
- package/lib/output/compact-layout.js +221 -0
- package/lib/output/format-output-item-block.js +31 -1
- package/lib/output/format-output-metadata.js +16 -29
- package/lib/output/format-stored-query-block.js +95 -0
- package/lib/output/layout-incoming-references.js +101 -19
- package/lib/output/layout-stored-queries.js +23 -330
- package/lib/output/list-queries.js +1 -1
- package/lib/output/render-field-discovery.js +11 -2
- package/lib/output/render-output-view.js +9 -5
- package/lib/output/renderers/json.js +5 -26
- package/lib/output/renderers/plain.js +155 -35
- package/lib/output/renderers/rich.js +250 -36
- package/lib/output/resolve-check-target.js +120 -11
- package/lib/output/resolved-link-layout.js +43 -0
- package/lib/output/rich-source/render.js +193 -35
- package/lib/output/show-document.js +25 -18
- package/lib/output/view-model/index.js +124 -103
- package/lib/parse/jsdoc/parse-jsdoc-blocks.js +1 -1
- package/lib/parse/jsdoc/parse-jsdoc-claims.js +12 -6
- package/lib/parse/markdown/parse-markdown-claims.js +99 -62
- package/lib/parse/markdown/parse-markdown-directives.d.ts +10 -6
- package/lib/parse/markdown/parse-markdown-directives.js +104 -18
- package/lib/parse/markdown/parse-markdown-prose.d.ts +27 -0
- package/lib/parse/markdown/parse-markdown-prose.js +243 -0
- package/lib/parse/parse-claims.d.ts +2 -6
- package/lib/parse/parse-claims.js +11 -53
- package/lib/parse/tagged-fenced/tagged-fenced-blocks.d.ts +4 -4
- package/lib/parse/tagged-fenced/tagged-fenced-blocks.js +4 -4
- package/lib/parse/yaml/parse-yaml-claims.js +4 -4
- package/lib/patram.d.ts +9 -3
- package/lib/patram.js +1 -1
- package/lib/scan/discover-fields.js +194 -55
- package/lib/scan/list-source-files.d.ts +4 -4
- package/lib/scan/list-source-files.js +4 -4
- package/package.json +2 -1
- package/lib/directive-validation-test-helpers.js +0 -87
- package/lib/graph/query/parse.d.ts +0 -75
- package/lib/graph/query/parse.js +0 -1064
- package/lib/output/derived-summary.js +0 -280
- package/lib/output/format-derived-summary-row.js +0 -9
package/lib/config/defaults.js
CHANGED
|
@@ -25,36 +25,12 @@ export function normalizeRepoConfig(repo_config) {
|
|
|
25
25
|
queries: { ...repo_config.queries },
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
assignOptionalRepoConfigField(
|
|
29
|
-
normalized_config,
|
|
30
|
-
'classes',
|
|
31
|
-
repo_config.classes,
|
|
32
|
-
);
|
|
33
|
-
assignOptionalRepoConfigField(
|
|
34
|
-
normalized_config,
|
|
35
|
-
'derived_summaries',
|
|
36
|
-
repo_config.derived_summaries,
|
|
37
|
-
);
|
|
38
28
|
assignOptionalRepoConfigField(
|
|
39
29
|
normalized_config,
|
|
40
30
|
'fields',
|
|
41
31
|
repo_config.fields,
|
|
42
32
|
);
|
|
43
|
-
assignOptionalRepoConfigField(
|
|
44
|
-
normalized_config,
|
|
45
|
-
'mappings',
|
|
46
|
-
repo_config.mappings,
|
|
47
|
-
);
|
|
48
|
-
assignOptionalRepoConfigField(
|
|
49
|
-
normalized_config,
|
|
50
|
-
'path_classes',
|
|
51
|
-
repo_config.path_classes,
|
|
52
|
-
);
|
|
53
|
-
assignOptionalRepoConfigField(
|
|
54
|
-
normalized_config,
|
|
55
|
-
'relations',
|
|
56
|
-
repo_config.relations,
|
|
57
|
-
);
|
|
33
|
+
assignOptionalRepoConfigField(normalized_config, 'types', repo_config.types);
|
|
58
34
|
|
|
59
35
|
return normalized_config;
|
|
60
36
|
}
|
|
@@ -74,7 +50,39 @@ function assignOptionalRepoConfigField(
|
|
|
74
50
|
return;
|
|
75
51
|
}
|
|
76
52
|
|
|
53
|
+
if (field_name === 'types') {
|
|
54
|
+
normalized_config.types = normalizeTypes(
|
|
55
|
+
/** @type {PatramRepoConfig['types']} */ (field_value),
|
|
56
|
+
);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
77
60
|
normalized_config[field_name] = /** @type {PatramRepoConfig[TKey]} */ (
|
|
78
61
|
field_value
|
|
79
62
|
);
|
|
80
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {PatramRepoConfig['types']} types
|
|
67
|
+
* @returns {PatramRepoConfig['types']}
|
|
68
|
+
*/
|
|
69
|
+
function normalizeTypes(types) {
|
|
70
|
+
if (!types) {
|
|
71
|
+
return types;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @type {NonNullable<PatramRepoConfig['types']>} */
|
|
75
|
+
const normalized_types = {};
|
|
76
|
+
|
|
77
|
+
for (const [type_name, type_definition] of Object.entries(types)) {
|
|
78
|
+
normalized_types[type_name] = {
|
|
79
|
+
...type_definition,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (typeof type_definition.in === 'string') {
|
|
83
|
+
normalized_types[type_name].in = [type_definition.in];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return normalized_types;
|
|
88
|
+
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Reads `.patram.json`, applies defaults, and validates repo config and graph
|
|
5
5
|
* schema before command execution.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* kind: config
|
|
8
|
+
* status: active
|
|
9
|
+
* tracked_in: ../../docs/plans/v0/source-anchor-dogfooding.md
|
|
10
|
+
* decided_by: ../../docs/decisions/single-config-file.md
|
|
11
|
+
* decided_by: ../../docs/decisions/optional-config-default-scan.md
|
|
12
12
|
* @patram
|
|
13
13
|
* @see {@link ./schema.js}
|
|
14
14
|
* @see {@link ./validation.js}
|
|
@@ -24,24 +24,10 @@
|
|
|
24
24
|
*/
|
|
25
25
|
/**
|
|
26
26
|
* @typedef {object} LoadPatramConfigResult
|
|
27
|
-
* @property {
|
|
27
|
+
* @property {PatramRepoConfig | null} config
|
|
28
28
|
* @property {string} config_path
|
|
29
29
|
* @property {PatramDiagnostic[]} diagnostics
|
|
30
30
|
*/
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {import('./schema.js').StoredQueryConfig} StoredQueryConfig
|
|
33
|
-
* @typedef {import('./schema.js').FieldDisplayConfig} FieldDisplayConfig
|
|
34
|
-
* @typedef {import('./schema.js').FieldQueryConfig} FieldQueryConfig
|
|
35
|
-
* @typedef {import('./schema.js').MetadataFieldConfig} MetadataFieldConfig
|
|
36
|
-
* @typedef {import('./schema.js').ClassFieldRuleConfig} ClassFieldRuleConfig
|
|
37
|
-
* @typedef {import('./schema.js').ClassSchemaConfig} ClassSchemaConfig
|
|
38
|
-
* @typedef {import('./schema.js').PathClassConfig} PathClassConfig
|
|
39
|
-
* @typedef {import('./schema.js').DerivedSummaryScalar} DerivedSummaryScalar
|
|
40
|
-
* @typedef {import('./schema.js').DerivedSummarySelectCaseConfig} DerivedSummarySelectCaseConfig
|
|
41
|
-
* @typedef {import('./schema.js').DerivedSummaryFieldConfig} DerivedSummaryFieldConfig
|
|
42
|
-
* @typedef {import('./schema.js').DerivedSummaryConfig} DerivedSummaryConfig
|
|
43
|
-
* @typedef {import('./schema.js').PatramRepoConfig} PatramRepoConfig
|
|
44
|
-
*/
|
|
45
31
|
/**
|
|
46
32
|
* Load and validate the repo Patram config.
|
|
47
33
|
*
|
|
@@ -49,6 +35,17 @@
|
|
|
49
35
|
* @returns {Promise<LoadPatramConfigResult>}
|
|
50
36
|
*/
|
|
51
37
|
export function loadPatramConfig(project_directory?: string): Promise<LoadPatramConfigResult>;
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} config_source
|
|
40
|
+
* @returns {{ success: true, value: unknown } | { success: false, diagnostic: PatramDiagnostic }}
|
|
41
|
+
*/
|
|
42
|
+
export function parsePatramConfigSource(config_source: string): {
|
|
43
|
+
success: true;
|
|
44
|
+
value: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
success: false;
|
|
47
|
+
diagnostic: PatramDiagnostic;
|
|
48
|
+
};
|
|
52
49
|
export type PatramDiagnostic = {
|
|
53
50
|
code: string;
|
|
54
51
|
column: number;
|
|
@@ -58,19 +55,8 @@ export type PatramDiagnostic = {
|
|
|
58
55
|
path: string;
|
|
59
56
|
};
|
|
60
57
|
export type LoadPatramConfigResult = {
|
|
61
|
-
config:
|
|
58
|
+
config: PatramRepoConfig | null;
|
|
62
59
|
config_path: string;
|
|
63
60
|
diagnostics: PatramDiagnostic[];
|
|
64
61
|
};
|
|
65
|
-
|
|
66
|
-
export type FieldDisplayConfig = import("./schema.js").FieldDisplayConfig;
|
|
67
|
-
export type FieldQueryConfig = import("./schema.js").FieldQueryConfig;
|
|
68
|
-
export type MetadataFieldConfig = import("./schema.js").MetadataFieldConfig;
|
|
69
|
-
export type ClassFieldRuleConfig = import("./schema.js").ClassFieldRuleConfig;
|
|
70
|
-
export type ClassSchemaConfig = import("./schema.js").ClassSchemaConfig;
|
|
71
|
-
export type PathClassConfig = import("./schema.js").PathClassConfig;
|
|
72
|
-
export type DerivedSummaryScalar = import("./schema.js").DerivedSummaryScalar;
|
|
73
|
-
export type DerivedSummarySelectCaseConfig = import("./schema.js").DerivedSummarySelectCaseConfig;
|
|
74
|
-
export type DerivedSummaryFieldConfig = import("./schema.js").DerivedSummaryFieldConfig;
|
|
75
|
-
export type DerivedSummaryConfig = import("./schema.js").DerivedSummaryConfig;
|
|
76
|
-
export type PatramRepoConfig = import("./schema.js").PatramRepoConfig;
|
|
62
|
+
import type { PatramRepoConfig } from './load-patram-config.types.d.ts';
|
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import {
|
|
3
|
-
*
|
|
4
|
-
* ClassSchemaConfig,
|
|
5
|
-
* DerivedSummaryConfig,
|
|
6
|
-
* DerivedSummaryFieldConfig,
|
|
7
|
-
* DerivedSummaryScalar,
|
|
8
|
-
* DerivedSummarySelectCaseConfig,
|
|
9
|
-
* FieldDisplayConfig,
|
|
10
|
-
* FieldQueryConfig,
|
|
11
|
-
* MetadataFieldConfig,
|
|
12
|
-
* PathClassConfig,
|
|
3
|
+
* PatramRepoConfig,
|
|
13
4
|
* StoredQueryConfig,
|
|
14
|
-
* } from './
|
|
5
|
+
* } from './load-patram-config.types.ts';
|
|
15
6
|
*/
|
|
16
7
|
|
|
17
8
|
import { readFile } from 'node:fs/promises';
|
|
18
9
|
import { resolve } from 'node:path';
|
|
19
10
|
import process from 'node:process';
|
|
20
11
|
|
|
21
|
-
import { CONFIG_FILE_NAME
|
|
22
|
-
import { createDefaultRepoConfig
|
|
23
|
-
import {
|
|
24
|
-
validateDerivedSummaries,
|
|
25
|
-
validateFieldSchemaConfig,
|
|
26
|
-
validateGraphSchema,
|
|
27
|
-
validateLegacyConfigShape,
|
|
28
|
-
validateStoredQueries,
|
|
29
|
-
} from './validation.js';
|
|
12
|
+
import { CONFIG_FILE_NAME } from './schema.js';
|
|
13
|
+
import { createDefaultRepoConfig } from './defaults.js';
|
|
14
|
+
import { validatePatramConfigValue } from './validate-patram-config-value.js';
|
|
30
15
|
|
|
31
16
|
/**
|
|
32
17
|
* Repo config loading.
|
|
@@ -34,11 +19,11 @@ import {
|
|
|
34
19
|
* Reads `.patram.json`, applies defaults, and validates repo config and graph
|
|
35
20
|
* schema before command execution.
|
|
36
21
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
22
|
+
* kind: config
|
|
23
|
+
* status: active
|
|
24
|
+
* tracked_in: ../../docs/plans/v0/source-anchor-dogfooding.md
|
|
25
|
+
* decided_by: ../../docs/decisions/single-config-file.md
|
|
26
|
+
* decided_by: ../../docs/decisions/optional-config-default-scan.md
|
|
42
27
|
* @patram
|
|
43
28
|
* @see {@link ./schema.js}
|
|
44
29
|
* @see {@link ./validation.js}
|
|
@@ -56,26 +41,11 @@ import {
|
|
|
56
41
|
|
|
57
42
|
/**
|
|
58
43
|
* @typedef {object} LoadPatramConfigResult
|
|
59
|
-
* @property {
|
|
44
|
+
* @property {PatramRepoConfig | null} config
|
|
60
45
|
* @property {string} config_path
|
|
61
46
|
* @property {PatramDiagnostic[]} diagnostics
|
|
62
47
|
*/
|
|
63
48
|
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {import('./schema.js').StoredQueryConfig} StoredQueryConfig
|
|
66
|
-
* @typedef {import('./schema.js').FieldDisplayConfig} FieldDisplayConfig
|
|
67
|
-
* @typedef {import('./schema.js').FieldQueryConfig} FieldQueryConfig
|
|
68
|
-
* @typedef {import('./schema.js').MetadataFieldConfig} MetadataFieldConfig
|
|
69
|
-
* @typedef {import('./schema.js').ClassFieldRuleConfig} ClassFieldRuleConfig
|
|
70
|
-
* @typedef {import('./schema.js').ClassSchemaConfig} ClassSchemaConfig
|
|
71
|
-
* @typedef {import('./schema.js').PathClassConfig} PathClassConfig
|
|
72
|
-
* @typedef {import('./schema.js').DerivedSummaryScalar} DerivedSummaryScalar
|
|
73
|
-
* @typedef {import('./schema.js').DerivedSummarySelectCaseConfig} DerivedSummarySelectCaseConfig
|
|
74
|
-
* @typedef {import('./schema.js').DerivedSummaryFieldConfig} DerivedSummaryFieldConfig
|
|
75
|
-
* @typedef {import('./schema.js').DerivedSummaryConfig} DerivedSummaryConfig
|
|
76
|
-
* @typedef {import('./schema.js').PatramRepoConfig} PatramRepoConfig
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
49
|
/**
|
|
80
50
|
* Load and validate the repo Patram config.
|
|
81
51
|
*
|
|
@@ -90,56 +60,19 @@ export async function loadPatramConfig(project_directory = process.cwd()) {
|
|
|
90
60
|
return createLoadResult(createDefaultRepoConfig(), []);
|
|
91
61
|
}
|
|
92
62
|
|
|
93
|
-
const parse_result =
|
|
63
|
+
const parse_result = parsePatramConfigSource(config_source);
|
|
94
64
|
|
|
95
65
|
if (!parse_result.success) {
|
|
96
66
|
return createLoadResult(null, [parse_result.diagnostic]);
|
|
97
67
|
}
|
|
98
68
|
|
|
99
|
-
const
|
|
100
|
-
parse_result.value,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
if (legacy_config_diagnostics.length > 0) {
|
|
104
|
-
return createLoadResult(null, legacy_config_diagnostics);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const config_result = patram_repo_config_schema.safeParse(parse_result.value);
|
|
69
|
+
const validation_result = validatePatramConfigValue(parse_result.value);
|
|
108
70
|
|
|
109
|
-
if (!
|
|
110
|
-
return createLoadResult(
|
|
111
|
-
null,
|
|
112
|
-
config_result.error.issues.map(createValidationDiagnostic),
|
|
113
|
-
);
|
|
71
|
+
if (!validation_result.success) {
|
|
72
|
+
return createLoadResult(null, validation_result.diagnostics);
|
|
114
73
|
}
|
|
115
74
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (graph_schema_diagnostics.length > 0) {
|
|
119
|
-
return createLoadResult(null, graph_schema_diagnostics);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const normalized_config = normalizeRepoConfig(config_result.data);
|
|
123
|
-
const field_schema_diagnostics = validateFieldSchemaConfig(normalized_config);
|
|
124
|
-
|
|
125
|
-
if (field_schema_diagnostics.length > 0) {
|
|
126
|
-
return createLoadResult(null, field_schema_diagnostics);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const stored_query_diagnostics = validateStoredQueries(normalized_config);
|
|
130
|
-
|
|
131
|
-
if (stored_query_diagnostics.length > 0) {
|
|
132
|
-
return createLoadResult(null, stored_query_diagnostics);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const derived_summary_diagnostics =
|
|
136
|
-
validateDerivedSummaries(normalized_config);
|
|
137
|
-
|
|
138
|
-
if (derived_summary_diagnostics.length > 0) {
|
|
139
|
-
return createLoadResult(null, derived_summary_diagnostics);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return createLoadResult(normalized_config, []);
|
|
75
|
+
return createLoadResult(validation_result.config, []);
|
|
143
76
|
}
|
|
144
77
|
|
|
145
78
|
/**
|
|
@@ -162,7 +95,7 @@ async function readConfigSource(config_file_path) {
|
|
|
162
95
|
* @param {string} config_source
|
|
163
96
|
* @returns {{ success: true, value: unknown } | { success: false, diagnostic: PatramDiagnostic }}
|
|
164
97
|
*/
|
|
165
|
-
function
|
|
98
|
+
export function parsePatramConfigSource(config_source) {
|
|
166
99
|
try {
|
|
167
100
|
return {
|
|
168
101
|
success: true,
|
|
@@ -181,7 +114,7 @@ function parseConfigJson(config_source) {
|
|
|
181
114
|
}
|
|
182
115
|
|
|
183
116
|
/**
|
|
184
|
-
* @param {
|
|
117
|
+
* @param {PatramRepoConfig | null} config
|
|
185
118
|
* @param {PatramDiagnostic[]} diagnostics
|
|
186
119
|
* @returns {LoadPatramConfigResult}
|
|
187
120
|
*/
|
|
@@ -211,34 +144,6 @@ function createInvalidJsonDiagnostic(config_source, error) {
|
|
|
211
144
|
};
|
|
212
145
|
}
|
|
213
146
|
|
|
214
|
-
/**
|
|
215
|
-
* @param {import('zod').core.$ZodIssue} issue
|
|
216
|
-
* @returns {PatramDiagnostic}
|
|
217
|
-
*/
|
|
218
|
-
function createValidationDiagnostic(issue) {
|
|
219
|
-
const issue_path = formatIssuePath(issue.path);
|
|
220
|
-
|
|
221
|
-
if (issue_path) {
|
|
222
|
-
return {
|
|
223
|
-
code: 'config.invalid',
|
|
224
|
-
column: 1,
|
|
225
|
-
level: 'error',
|
|
226
|
-
line: 1,
|
|
227
|
-
message: `Invalid config at "${issue_path}": ${issue.message}`,
|
|
228
|
-
path: CONFIG_FILE_NAME,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return {
|
|
233
|
-
code: 'config.invalid',
|
|
234
|
-
column: 1,
|
|
235
|
-
level: 'error',
|
|
236
|
-
line: 1,
|
|
237
|
-
message: `Invalid config: ${issue.message}`,
|
|
238
|
-
path: CONFIG_FILE_NAME,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
147
|
/**
|
|
243
148
|
* @param {unknown} error
|
|
244
149
|
* @returns {error is NodeJS.ErrnoException}
|
|
@@ -281,14 +186,6 @@ function getJsonSyntaxOrigin(config_source, error_message) {
|
|
|
281
186
|
};
|
|
282
187
|
}
|
|
283
188
|
|
|
284
|
-
/**
|
|
285
|
-
* @param {(string | number | symbol | undefined)[]} issue_path
|
|
286
|
-
* @returns {string}
|
|
287
|
-
*/
|
|
288
|
-
function formatIssuePath(issue_path) {
|
|
289
|
-
return issue_path.map(String).join('.');
|
|
290
|
-
}
|
|
291
|
-
|
|
292
189
|
/**
|
|
293
190
|
* @param {string} source_text
|
|
294
191
|
* @param {number} offset
|
|
@@ -1,45 +1,8 @@
|
|
|
1
1
|
export type StoredQueryConfig = import('./schema.js').StoredQueryConfig;
|
|
2
|
-
export type FieldDisplayConfig = import('./schema.js').FieldDisplayConfig;
|
|
3
|
-
export type FieldQueryConfig = import('./schema.js').FieldQueryConfig;
|
|
4
|
-
export type FieldValueTypeName = import('./schema.js').MetadataFieldConfig['type'];
|
|
5
2
|
export type MetadataFieldConfig = import('./schema.js').MetadataFieldConfig;
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type IntegerFieldConfig = Extract<MetadataFieldConfig, {
|
|
10
|
-
type: 'integer';
|
|
11
|
-
}>;
|
|
12
|
-
export type EnumFieldConfig = Extract<MetadataFieldConfig, {
|
|
13
|
-
type: 'enum';
|
|
14
|
-
}>;
|
|
15
|
-
export type PathFieldConfig = Extract<MetadataFieldConfig, {
|
|
16
|
-
type: 'path';
|
|
17
|
-
}>;
|
|
18
|
-
export type GlobFieldConfig = Extract<MetadataFieldConfig, {
|
|
19
|
-
type: 'glob';
|
|
20
|
-
}>;
|
|
21
|
-
export type DateFieldConfig = Extract<MetadataFieldConfig, {
|
|
22
|
-
type: 'date';
|
|
23
|
-
}>;
|
|
24
|
-
export type DateTimeFieldConfig = Extract<MetadataFieldConfig, {
|
|
25
|
-
type: 'date_time';
|
|
26
|
-
}>;
|
|
27
|
-
export type ClassFieldRuleConfig = import('./schema.js').ClassFieldRuleConfig;
|
|
28
|
-
export type DirectiveTypeConfig = MetadataFieldConfig;
|
|
29
|
-
export type MetadataDirectiveRuleConfig = ClassFieldRuleConfig;
|
|
30
|
-
export type ClassSchemaConfig = import('./schema.js').ClassSchemaConfig;
|
|
31
|
-
export type MetadataSchemaConfig = ClassSchemaConfig;
|
|
32
|
-
export type PathClassConfig = import('./schema.js').PathClassConfig;
|
|
33
|
-
export type DerivedSummaryScalar = import('./schema.js').DerivedSummaryScalar;
|
|
34
|
-
export type DerivedSummarySelectCaseConfig = import('./schema.js').DerivedSummarySelectCaseConfig;
|
|
35
|
-
export type DerivedSummaryFieldConfig = import('./schema.js').DerivedSummaryFieldConfig;
|
|
36
|
-
export type DerivedSummaryCountFieldConfig = Extract<DerivedSummaryFieldConfig, {
|
|
37
|
-
count: unknown;
|
|
38
|
-
}>;
|
|
39
|
-
export type DerivedSummarySelectFieldConfig = Extract<DerivedSummaryFieldConfig, {
|
|
40
|
-
select: unknown;
|
|
41
|
-
}>;
|
|
42
|
-
export type DerivedSummaryConfig = import('./schema.js').DerivedSummaryConfig;
|
|
3
|
+
export type ScalarFieldConfig = import('./schema.js').ScalarFieldConfig;
|
|
4
|
+
export type RefFieldConfig = import('./schema.js').RefFieldConfig;
|
|
5
|
+
export type TypeDefinitionConfig = import('./schema.js').TypeDefinitionConfig;
|
|
43
6
|
export type PatramRepoConfig = import('./schema.js').PatramRepoConfig;
|
|
44
7
|
export type PatramDiagnostic = import('./load-patram-config.js').PatramDiagnostic;
|
|
45
8
|
export type LoadPatramConfigResult = import('./load-patram-config.js').LoadPatramConfigResult;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} config_file_path
|
|
3
|
+
* @returns {Promise<
|
|
4
|
+
* | { success: true, value: Record<string, unknown> }
|
|
5
|
+
* | { diagnostic: PatramDiagnostic, success: false }
|
|
6
|
+
* >}
|
|
7
|
+
*/
|
|
8
|
+
export function loadRawConfig(config_file_path: string): Promise<{
|
|
9
|
+
success: true;
|
|
10
|
+
value: Record<string, unknown>;
|
|
11
|
+
} | {
|
|
12
|
+
diagnostic: PatramDiagnostic;
|
|
13
|
+
success: false;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} config_file_path
|
|
17
|
+
* @param {Record<string, unknown>} raw_config
|
|
18
|
+
* @param {StoredQueryMutationResult} mutation_result
|
|
19
|
+
* @returns {Promise<
|
|
20
|
+
* | { success: true, value: StoredQueryMutationResult }
|
|
21
|
+
* | { diagnostics: PatramDiagnostic[], success: false }
|
|
22
|
+
* >}
|
|
23
|
+
*/
|
|
24
|
+
export function persistStoredQueryMutation(config_file_path: string, raw_config: Record<string, unknown>, mutation_result: StoredQueryMutationResult): Promise<{
|
|
25
|
+
success: true;
|
|
26
|
+
value: StoredQueryMutationResult;
|
|
27
|
+
} | {
|
|
28
|
+
diagnostics: PatramDiagnostic[];
|
|
29
|
+
success: false;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} query_text
|
|
33
|
+
* @param {string | undefined} description
|
|
34
|
+
* @returns {StoredQueryConfig}
|
|
35
|
+
*/
|
|
36
|
+
export function createStoredQueryDefinition(query_text: string, description: string | undefined): StoredQueryConfig;
|
|
37
|
+
/**
|
|
38
|
+
* @param {Record<string, unknown> | null} raw_query_value
|
|
39
|
+
* @param {StoredQueryConfig} existing_query
|
|
40
|
+
* @param {{ cypher?: string, description?: string }} stored_query_mutation
|
|
41
|
+
* @returns {StoredQueryConfig}
|
|
42
|
+
*/
|
|
43
|
+
export function createUpdatedStoredQueryDefinition(raw_query_value: Record<string, unknown> | null, existing_query: StoredQueryConfig, stored_query_mutation: {
|
|
44
|
+
cypher?: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
}): StoredQueryConfig;
|
|
47
|
+
/**
|
|
48
|
+
* @param {Record<string, unknown>} raw_config
|
|
49
|
+
* @returns {Record<string, unknown>}
|
|
50
|
+
*/
|
|
51
|
+
export function ensureRawQueries(raw_config: Record<string, unknown>): Record<string, unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* @param {unknown} raw_query_value
|
|
54
|
+
* @returns {Record<string, unknown> | null}
|
|
55
|
+
*/
|
|
56
|
+
export function rawQueryValueToRecord(raw_query_value: unknown): Record<string, unknown> | null;
|
|
57
|
+
export type StoredQueryMutationResult = {
|
|
58
|
+
action: "added";
|
|
59
|
+
name: string;
|
|
60
|
+
} | {
|
|
61
|
+
action: "removed";
|
|
62
|
+
name: string;
|
|
63
|
+
} | {
|
|
64
|
+
action: "updated";
|
|
65
|
+
name: string;
|
|
66
|
+
previous_name?: string;
|
|
67
|
+
};
|
|
68
|
+
import type { PatramDiagnostic } from './load-patram-config.types.d.ts';
|
|
69
|
+
import type { StoredQueryConfig } from './load-patram-config.types.d.ts';
|