patram 0.11.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/commands/fields.js +0 -4
- package/lib/cli/commands/queries.js +10 -20
- 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 +71 -106
- package/lib/cli/main.js +10 -10
- package/lib/cli/parse-arguments-helpers.js +165 -59
- package/lib/cli/parse-arguments.js +4 -4
- package/lib/cli/render-help.js +2 -2
- package/lib/config/defaults.js +33 -25
- package/lib/config/load-patram-config.d.ts +8 -33
- package/lib/config/load-patram-config.js +9 -33
- package/lib/config/load-patram-config.types.d.ts +3 -40
- package/lib/config/manage-stored-queries-helpers.d.ts +4 -4
- package/lib/config/manage-stored-queries-helpers.js +91 -33
- package/lib/config/manage-stored-queries.d.ts +4 -4
- package/lib/config/manage-stored-queries.js +11 -5
- 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.js +6 -31
- 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.js +77 -23
- 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/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 +3 -5
- 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 +1 -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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @typedef {import('./arguments.types.ts').CliParseError} CliParseError
|
|
6
6
|
* @typedef {import('./arguments.types.ts').ParsedCliHelpRequest} ParsedCliHelpRequest
|
|
7
7
|
* @typedef {{ kind: string, name?: string, rawName?: string, value?: string | boolean }} CliOptionToken
|
|
8
|
-
* @typedef {{ color?: string, desc?: string, explain?: boolean, help?: boolean, json?: boolean, limit?: string, lint?: boolean, name?: string, 'no-color'?: boolean, offset?: string, plain?: boolean,
|
|
8
|
+
* @typedef {{ color?: string, cypher?: string, desc?: string, explain?: boolean, help?: boolean, json?: boolean, limit?: string, lint?: boolean, name?: string, 'no-color'?: boolean, offset?: string, plain?: boolean, where?: string }} CliOptionValues
|
|
9
9
|
* @typedef {{ option_tokens: CliOptionToken[], positionals: string[], values: CliOptionValues }} ParsedCommandLine
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -23,6 +23,7 @@ import { findInvalidQueryPagination } from './query-pagination.js';
|
|
|
23
23
|
|
|
24
24
|
export const CLI_OPTIONS = /** @type {const} */ ({
|
|
25
25
|
color: { type: 'string' },
|
|
26
|
+
cypher: { type: 'string' },
|
|
26
27
|
desc: { type: 'string' },
|
|
27
28
|
explain: { type: 'boolean' },
|
|
28
29
|
help: { type: 'boolean' },
|
|
@@ -33,7 +34,6 @@ export const CLI_OPTIONS = /** @type {const} */ ({
|
|
|
33
34
|
'no-color': { type: 'boolean' },
|
|
34
35
|
offset: { type: 'string' },
|
|
35
36
|
plain: { type: 'boolean' },
|
|
36
|
-
query: { type: 'string' },
|
|
37
37
|
where: { type: 'string' },
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -99,39 +99,15 @@ export function validateParsedCommand(command_name, command_line) {
|
|
|
99
99
|
const command_positionals = command_line.positionals.slice(1);
|
|
100
100
|
|
|
101
101
|
if (
|
|
102
|
-
command_name
|
|
103
|
-
command_line.values.where !== undefined &&
|
|
104
|
-
command_positionals.length === 0
|
|
102
|
+
hasAdHocQueryCommand(command_name, command_line.values, command_positionals)
|
|
105
103
|
) {
|
|
106
|
-
return (
|
|
107
|
-
createMessageParseError(
|
|
108
|
-
findInvalidQueryPagination(command_line.option_tokens),
|
|
109
|
-
) ??
|
|
110
|
-
findInvalidQueryMode(
|
|
111
|
-
command_name,
|
|
112
|
-
command_line.values,
|
|
113
|
-
command_positionals,
|
|
114
|
-
)
|
|
115
|
-
);
|
|
104
|
+
return validateAdHocQueryCommand(command_line, command_positionals);
|
|
116
105
|
}
|
|
117
106
|
|
|
118
|
-
return (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
) ??
|
|
123
|
-
findInvalidQueryInspection(command_name, command_line.values) ??
|
|
124
|
-
findInvalidQueryMode(
|
|
125
|
-
command_name,
|
|
126
|
-
command_line.values,
|
|
127
|
-
command_positionals,
|
|
128
|
-
) ??
|
|
129
|
-
findInvalidQueriesMutation(
|
|
130
|
-
command_name,
|
|
131
|
-
command_line.values,
|
|
132
|
-
command_positionals,
|
|
133
|
-
) ??
|
|
134
|
-
validateCommandPositionals(command_name, command_positionals)
|
|
107
|
+
return validateStandardCommand(
|
|
108
|
+
command_name,
|
|
109
|
+
command_line,
|
|
110
|
+
command_positionals,
|
|
135
111
|
);
|
|
136
112
|
}
|
|
137
113
|
|
|
@@ -162,36 +138,134 @@ export function buildCommandArguments(
|
|
|
162
138
|
command_positionals,
|
|
163
139
|
parsed_values,
|
|
164
140
|
) {
|
|
165
|
-
if (command_name === 'query'
|
|
166
|
-
return
|
|
141
|
+
if (command_name === 'query' || command_name === 'refs') {
|
|
142
|
+
return buildAdHocQueryArguments(
|
|
143
|
+
command_name,
|
|
144
|
+
command_positionals,
|
|
145
|
+
parsed_values,
|
|
146
|
+
);
|
|
167
147
|
}
|
|
168
148
|
|
|
169
|
-
if (command_name === '
|
|
170
|
-
return
|
|
149
|
+
if (command_name === 'queries') {
|
|
150
|
+
return buildStoredQueryArguments(command_positionals, parsed_values);
|
|
171
151
|
}
|
|
172
152
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const command_arguments = [...command_positionals];
|
|
153
|
+
return command_positionals;
|
|
154
|
+
}
|
|
176
155
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
156
|
+
/**
|
|
157
|
+
* @param {CliCommandName} command_name
|
|
158
|
+
* @param {CliOptionValues} parsed_values
|
|
159
|
+
* @param {string[]} command_positionals
|
|
160
|
+
* @returns {boolean}
|
|
161
|
+
*/
|
|
162
|
+
function hasAdHocQueryCommand(
|
|
163
|
+
command_name,
|
|
164
|
+
parsed_values,
|
|
165
|
+
command_positionals,
|
|
166
|
+
) {
|
|
167
|
+
return (
|
|
168
|
+
command_name === 'query' &&
|
|
169
|
+
parsed_values.cypher !== undefined &&
|
|
170
|
+
command_positionals.length === 0
|
|
171
|
+
);
|
|
172
|
+
}
|
|
180
173
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
/**
|
|
175
|
+
* @param {ParsedCommandLine} command_line
|
|
176
|
+
* @param {string[]} command_positionals
|
|
177
|
+
* @returns {CliParseError | null}
|
|
178
|
+
*/
|
|
179
|
+
function validateAdHocQueryCommand(command_line, command_positionals) {
|
|
180
|
+
return (
|
|
181
|
+
findInvalidCommandOption('query', command_line.option_tokens) ??
|
|
182
|
+
createMessageParseError(
|
|
183
|
+
findInvalidQueryPagination(command_line.option_tokens),
|
|
184
|
+
) ??
|
|
185
|
+
findInvalidQueryMode('query', command_line.values, command_positionals)
|
|
186
|
+
);
|
|
187
|
+
}
|
|
184
188
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
/**
|
|
190
|
+
* @param {CliCommandName} command_name
|
|
191
|
+
* @param {ParsedCommandLine} command_line
|
|
192
|
+
* @param {string[]} command_positionals
|
|
193
|
+
* @returns {CliParseError | null}
|
|
194
|
+
*/
|
|
195
|
+
function validateStandardCommand(
|
|
196
|
+
command_name,
|
|
197
|
+
command_line,
|
|
198
|
+
command_positionals,
|
|
199
|
+
) {
|
|
200
|
+
return (
|
|
201
|
+
findInvalidCommandOption(command_name, command_line.option_tokens) ??
|
|
202
|
+
createMessageParseError(
|
|
203
|
+
findInvalidQueryPagination(command_line.option_tokens),
|
|
204
|
+
) ??
|
|
205
|
+
findInvalidQueryInspection(command_name, command_line.values) ??
|
|
206
|
+
findInvalidQueryMode(
|
|
207
|
+
command_name,
|
|
208
|
+
command_line.values,
|
|
209
|
+
command_positionals,
|
|
210
|
+
) ??
|
|
211
|
+
findInvalidQueriesMutation(
|
|
212
|
+
command_name,
|
|
213
|
+
command_line.values,
|
|
214
|
+
command_positionals,
|
|
215
|
+
) ??
|
|
216
|
+
validateCommandPositionals(command_name, command_positionals)
|
|
217
|
+
);
|
|
218
|
+
}
|
|
188
219
|
|
|
189
|
-
|
|
220
|
+
/**
|
|
221
|
+
* @param {'query' | 'refs'} command_name
|
|
222
|
+
* @param {string[]} command_positionals
|
|
223
|
+
* @param {CliOptionValues} parsed_values
|
|
224
|
+
* @returns {string[]}
|
|
225
|
+
*/
|
|
226
|
+
function buildAdHocQueryArguments(
|
|
227
|
+
command_name,
|
|
228
|
+
command_positionals,
|
|
229
|
+
parsed_values,
|
|
230
|
+
) {
|
|
231
|
+
if (parsed_values.cypher !== undefined) {
|
|
232
|
+
return command_name === 'query'
|
|
233
|
+
? ['--cypher', parsed_values.cypher]
|
|
234
|
+
: [command_positionals[0], '--cypher', parsed_values.cypher];
|
|
190
235
|
}
|
|
191
236
|
|
|
192
237
|
return command_positionals;
|
|
193
238
|
}
|
|
194
239
|
|
|
240
|
+
/**
|
|
241
|
+
* @param {string[]} command_positionals
|
|
242
|
+
* @param {CliOptionValues} parsed_values
|
|
243
|
+
* @returns {string[]}
|
|
244
|
+
*/
|
|
245
|
+
function buildStoredQueryArguments(command_positionals, parsed_values) {
|
|
246
|
+
/** @type {string[]} */
|
|
247
|
+
const command_arguments = [...command_positionals];
|
|
248
|
+
|
|
249
|
+
appendOptionValue(command_arguments, '--name', parsed_values.name);
|
|
250
|
+
appendOptionValue(command_arguments, '--cypher', parsed_values.cypher);
|
|
251
|
+
appendOptionValue(command_arguments, '--desc', parsed_values.desc);
|
|
252
|
+
|
|
253
|
+
return command_arguments;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @param {string[]} command_arguments
|
|
258
|
+
* @param {string} option_name
|
|
259
|
+
* @param {string | undefined} option_value
|
|
260
|
+
*/
|
|
261
|
+
function appendOptionValue(command_arguments, option_name, option_value) {
|
|
262
|
+
if (option_value === undefined) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
command_arguments.push(option_name, option_value);
|
|
267
|
+
}
|
|
268
|
+
|
|
195
269
|
/**
|
|
196
270
|
* @param {string | undefined} help_target
|
|
197
271
|
* @returns {CliParseError}
|
|
@@ -369,14 +443,38 @@ function findInvalidQueryMode(
|
|
|
369
443
|
) {
|
|
370
444
|
if (
|
|
371
445
|
command_name === 'query' &&
|
|
372
|
-
parsed_values.
|
|
446
|
+
parsed_values.cypher !== undefined &&
|
|
373
447
|
command_positionals.length > 0
|
|
374
448
|
) {
|
|
375
449
|
return createMessageParseError(
|
|
376
|
-
'Query accepts either "--
|
|
450
|
+
'Query accepts either "--cypher" or a stored query name.',
|
|
377
451
|
);
|
|
378
452
|
}
|
|
379
453
|
|
|
454
|
+
if (command_name === 'query' && parsed_values.where !== undefined) {
|
|
455
|
+
return {
|
|
456
|
+
code: 'option_not_valid_for_command',
|
|
457
|
+
command_name: 'query',
|
|
458
|
+
token: '--where',
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (command_name === 'queries' && parsed_values.where !== undefined) {
|
|
463
|
+
return {
|
|
464
|
+
code: 'option_not_valid_for_command',
|
|
465
|
+
command_name: 'queries',
|
|
466
|
+
token: '--where',
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (command_name === 'refs' && parsed_values.where !== undefined) {
|
|
471
|
+
return {
|
|
472
|
+
code: 'option_not_valid_for_command',
|
|
473
|
+
command_name: 'refs',
|
|
474
|
+
token: '--where',
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
|
|
380
478
|
return null;
|
|
381
479
|
}
|
|
382
480
|
|
|
@@ -471,7 +569,7 @@ function validateCommandPositionals(command_name, command_positionals) {
|
|
|
471
569
|
|
|
472
570
|
if (command_name === 'query' && command_positionals.length === 0) {
|
|
473
571
|
return {
|
|
474
|
-
argument_label: "<name> or --
|
|
572
|
+
argument_label: "<name> or --cypher '<query>'",
|
|
475
573
|
code: 'missing_required_argument',
|
|
476
574
|
command_name: 'query',
|
|
477
575
|
};
|
|
@@ -487,6 +585,7 @@ function validateCommandPositionals(command_name, command_positionals) {
|
|
|
487
585
|
function isKnownCommandOptionName(option_name) {
|
|
488
586
|
return (
|
|
489
587
|
option_name === 'desc' ||
|
|
588
|
+
option_name === 'cypher' ||
|
|
490
589
|
option_name === 'explain' ||
|
|
491
590
|
option_name === 'limit' ||
|
|
492
591
|
option_name === 'lint' ||
|
|
@@ -507,8 +606,12 @@ function findMissingOptionValueError(option_token) {
|
|
|
507
606
|
}
|
|
508
607
|
|
|
509
608
|
if (option_token.name === 'where') {
|
|
609
|
+
return createMessageParseError('Where requires a value.');
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (option_token.name === 'cypher') {
|
|
510
613
|
return {
|
|
511
|
-
argument_label: "<name> or --
|
|
614
|
+
argument_label: "<name> or --cypher '<query>'",
|
|
512
615
|
code: 'missing_required_argument',
|
|
513
616
|
command_name: 'query',
|
|
514
617
|
};
|
|
@@ -531,11 +634,13 @@ function getMissingOptionValueMessage(option_name) {
|
|
|
531
634
|
/** @type {Record<string, string>} */
|
|
532
635
|
const option_messages = {
|
|
533
636
|
color: 'Color requires a value.',
|
|
637
|
+
cypher: 'Cypher requires a value.',
|
|
534
638
|
desc: 'Desc requires a value.',
|
|
535
639
|
limit: 'Limit requires a value.',
|
|
536
640
|
name: 'Name requires a value.',
|
|
537
641
|
offset: 'Offset requires a value.',
|
|
538
642
|
query: 'Query requires a value.',
|
|
643
|
+
where: 'Where requires a value.',
|
|
539
644
|
};
|
|
540
645
|
|
|
541
646
|
if (!option_name || !Object.hasOwn(option_messages, option_name)) {
|
|
@@ -564,8 +669,8 @@ function validateQueriesAddMutation(parsed_values, command_positionals) {
|
|
|
564
669
|
return createMessageParseError('Queries add does not accept "--name".');
|
|
565
670
|
}
|
|
566
671
|
|
|
567
|
-
if (parsed_values.
|
|
568
|
-
return createMessageParseError('Queries add requires "--
|
|
672
|
+
if (parsed_values.cypher === undefined) {
|
|
673
|
+
return createMessageParseError('Queries add requires "--cypher <query>".');
|
|
569
674
|
}
|
|
570
675
|
|
|
571
676
|
return null;
|
|
@@ -588,8 +693,9 @@ function validateQueriesRemoveMutation(parsed_values, command_positionals) {
|
|
|
588
693
|
|
|
589
694
|
if (
|
|
590
695
|
parsed_values.desc !== undefined ||
|
|
696
|
+
parsed_values.cypher !== undefined ||
|
|
591
697
|
parsed_values.name !== undefined ||
|
|
592
|
-
parsed_values.
|
|
698
|
+
parsed_values.where !== undefined
|
|
593
699
|
) {
|
|
594
700
|
return createMessageParseError(
|
|
595
701
|
'Queries remove does not accept mutation options.',
|
|
@@ -616,11 +722,11 @@ function validateQueriesUpdateMutation(parsed_values, command_positionals) {
|
|
|
616
722
|
|
|
617
723
|
if (
|
|
618
724
|
parsed_values.desc === undefined &&
|
|
619
|
-
parsed_values.
|
|
620
|
-
parsed_values.
|
|
725
|
+
parsed_values.cypher === undefined &&
|
|
726
|
+
parsed_values.name === undefined
|
|
621
727
|
) {
|
|
622
728
|
return createMessageParseError(
|
|
623
|
-
'Queries update requires at least one of "--name", "--
|
|
729
|
+
'Queries update requires at least one of "--name", "--cypher", or "--desc".',
|
|
624
730
|
);
|
|
625
731
|
}
|
|
626
732
|
|
|
@@ -34,10 +34,10 @@ import { buildQueryPagination } from './query-pagination.js';
|
|
|
34
34
|
* Normalizes raw argv into one validated Patram command plus shared output and
|
|
35
35
|
* pagination options.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* kind: cli
|
|
38
|
+
* status: active
|
|
39
|
+
* tracked_in: ../../docs/plans/v0/source-anchor-dogfooding.md
|
|
40
|
+
* decided_by: ../../docs/decisions/cli-argument-parser.md
|
|
41
41
|
* @patram
|
|
42
42
|
* @see {@link ./main.js}
|
|
43
43
|
* @see {@link ../../docs/decisions/cli-argument-parser.md}
|
package/lib/cli/render-help.js
CHANGED
|
@@ -101,7 +101,7 @@ export function renderInvalidWhereDiagnostic(diagnostic) {
|
|
|
101
101
|
const diagnostic_line = formatDiagnostic(diagnostic);
|
|
102
102
|
|
|
103
103
|
return joinOutputLines([
|
|
104
|
-
'Invalid
|
|
104
|
+
'Invalid query:',
|
|
105
105
|
` ${diagnostic_line}`,
|
|
106
106
|
'',
|
|
107
107
|
'Next:',
|
|
@@ -157,7 +157,7 @@ function renderCommandHelp(command_name) {
|
|
|
157
157
|
) {
|
|
158
158
|
output_lines.push(
|
|
159
159
|
'',
|
|
160
|
-
'
|
|
160
|
+
'Query syntax:',
|
|
161
161
|
...indentLines(command_definition.syntax_lines),
|
|
162
162
|
);
|
|
163
163
|
}
|
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
|
*
|
|
@@ -69,19 +55,8 @@ export type PatramDiagnostic = {
|
|
|
69
55
|
path: string;
|
|
70
56
|
};
|
|
71
57
|
export type LoadPatramConfigResult = {
|
|
72
|
-
config:
|
|
58
|
+
config: PatramRepoConfig | null;
|
|
73
59
|
config_path: string;
|
|
74
60
|
diagnostics: PatramDiagnostic[];
|
|
75
61
|
};
|
|
76
|
-
|
|
77
|
-
export type FieldDisplayConfig = import("./schema.js").FieldDisplayConfig;
|
|
78
|
-
export type FieldQueryConfig = import("./schema.js").FieldQueryConfig;
|
|
79
|
-
export type MetadataFieldConfig = import("./schema.js").MetadataFieldConfig;
|
|
80
|
-
export type ClassFieldRuleConfig = import("./schema.js").ClassFieldRuleConfig;
|
|
81
|
-
export type ClassSchemaConfig = import("./schema.js").ClassSchemaConfig;
|
|
82
|
-
export type PathClassConfig = import("./schema.js").PathClassConfig;
|
|
83
|
-
export type DerivedSummaryScalar = import("./schema.js").DerivedSummaryScalar;
|
|
84
|
-
export type DerivedSummarySelectCaseConfig = import("./schema.js").DerivedSummarySelectCaseConfig;
|
|
85
|
-
export type DerivedSummaryFieldConfig = import("./schema.js").DerivedSummaryFieldConfig;
|
|
86
|
-
export type DerivedSummaryConfig = import("./schema.js").DerivedSummaryConfig;
|
|
87
|
-
export type PatramRepoConfig = import("./schema.js").PatramRepoConfig;
|
|
62
|
+
import type { PatramRepoConfig } from './load-patram-config.types.d.ts';
|
|
@@ -1,17 +1,8 @@
|
|
|
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';
|
|
@@ -28,11 +19,11 @@ import { validatePatramConfigValue } from './validate-patram-config-value.js';
|
|
|
28
19
|
* Reads `.patram.json`, applies defaults, and validates repo config and graph
|
|
29
20
|
* schema before command execution.
|
|
30
21
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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
|
|
36
27
|
* @patram
|
|
37
28
|
* @see {@link ./schema.js}
|
|
38
29
|
* @see {@link ./validation.js}
|
|
@@ -50,26 +41,11 @@ import { validatePatramConfigValue } from './validate-patram-config-value.js';
|
|
|
50
41
|
|
|
51
42
|
/**
|
|
52
43
|
* @typedef {object} LoadPatramConfigResult
|
|
53
|
-
* @property {
|
|
44
|
+
* @property {PatramRepoConfig | null} config
|
|
54
45
|
* @property {string} config_path
|
|
55
46
|
* @property {PatramDiagnostic[]} diagnostics
|
|
56
47
|
*/
|
|
57
48
|
|
|
58
|
-
/**
|
|
59
|
-
* @typedef {import('./schema.js').StoredQueryConfig} StoredQueryConfig
|
|
60
|
-
* @typedef {import('./schema.js').FieldDisplayConfig} FieldDisplayConfig
|
|
61
|
-
* @typedef {import('./schema.js').FieldQueryConfig} FieldQueryConfig
|
|
62
|
-
* @typedef {import('./schema.js').MetadataFieldConfig} MetadataFieldConfig
|
|
63
|
-
* @typedef {import('./schema.js').ClassFieldRuleConfig} ClassFieldRuleConfig
|
|
64
|
-
* @typedef {import('./schema.js').ClassSchemaConfig} ClassSchemaConfig
|
|
65
|
-
* @typedef {import('./schema.js').PathClassConfig} PathClassConfig
|
|
66
|
-
* @typedef {import('./schema.js').DerivedSummaryScalar} DerivedSummaryScalar
|
|
67
|
-
* @typedef {import('./schema.js').DerivedSummarySelectCaseConfig} DerivedSummarySelectCaseConfig
|
|
68
|
-
* @typedef {import('./schema.js').DerivedSummaryFieldConfig} DerivedSummaryFieldConfig
|
|
69
|
-
* @typedef {import('./schema.js').DerivedSummaryConfig} DerivedSummaryConfig
|
|
70
|
-
* @typedef {import('./schema.js').PatramRepoConfig} PatramRepoConfig
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
49
|
/**
|
|
74
50
|
* Load and validate the repo Patram config.
|
|
75
51
|
*
|
|
@@ -138,7 +114,7 @@ export function parsePatramConfigSource(config_source) {
|
|
|
138
114
|
}
|
|
139
115
|
|
|
140
116
|
/**
|
|
141
|
-
* @param {
|
|
117
|
+
* @param {PatramRepoConfig | null} config
|
|
142
118
|
* @param {PatramDiagnostic[]} diagnostics
|
|
143
119
|
* @returns {LoadPatramConfigResult}
|
|
144
120
|
*/
|
|
@@ -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;
|
|
@@ -29,20 +29,20 @@ export function persistStoredQueryMutation(config_file_path: string, raw_config:
|
|
|
29
29
|
success: false;
|
|
30
30
|
}>;
|
|
31
31
|
/**
|
|
32
|
-
* @param {string}
|
|
32
|
+
* @param {string} query_text
|
|
33
33
|
* @param {string | undefined} description
|
|
34
34
|
* @returns {StoredQueryConfig}
|
|
35
35
|
*/
|
|
36
|
-
export function createStoredQueryDefinition(
|
|
36
|
+
export function createStoredQueryDefinition(query_text: string, description: string | undefined): StoredQueryConfig;
|
|
37
37
|
/**
|
|
38
38
|
* @param {Record<string, unknown> | null} raw_query_value
|
|
39
39
|
* @param {StoredQueryConfig} existing_query
|
|
40
|
-
* @param {{
|
|
40
|
+
* @param {{ cypher?: string, description?: string }} stored_query_mutation
|
|
41
41
|
* @returns {StoredQueryConfig}
|
|
42
42
|
*/
|
|
43
43
|
export function createUpdatedStoredQueryDefinition(raw_query_value: Record<string, unknown> | null, existing_query: StoredQueryConfig, stored_query_mutation: {
|
|
44
|
+
cypher?: string;
|
|
44
45
|
description?: string;
|
|
45
|
-
where?: string;
|
|
46
46
|
}): StoredQueryConfig;
|
|
47
47
|
/**
|
|
48
48
|
* @param {Record<string, unknown>} raw_config
|